Changeset 3417789
- Timestamp:
- 12/11/2025 10:59:44 PM (2 days ago)
- Location:
- automatic-featured-images-from-videos
- Files:
-
- 9 added
- 4 edited
-
tags/1.2.6 (added)
-
tags/1.2.6/automatic-featured-images-from-videos.php (added)
-
tags/1.2.6/includes (added)
-
tags/1.2.6/includes/ajax.php (added)
-
tags/1.2.6/includes/bulk-operations.php (added)
-
tags/1.2.6/includes/cli.php (added)
-
tags/1.2.6/js (added)
-
tags/1.2.6/js/button.js (added)
-
tags/1.2.6/readme.txt (added)
-
trunk/automatic-featured-images-from-videos.php (modified) (14 diffs)
-
trunk/includes/ajax.php (modified) (4 diffs)
-
trunk/includes/bulk-operations.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-featured-images-from-videos/trunk/automatic-featured-images-from-videos.php
r3265913 r3417789 1 1 <?php 2 /* 2 /** 3 3 * Plugin Name: Automatic Featured Images from YouTube / Vimeo 4 4 * Plugin URI: https://webdevstudios.com 5 * Description: If a YouTube or Vimeo video exists in the first few paragraphs of a post, automatically set the post's featured image to that video's thumbnail.6 * Version: 1.2. 55 * Description: Automatically create featured images from YouTube and Vimeo generated video thumbnails, from above the fold embeds. 6 * Version: 1.2.6 7 7 * Author: WebDevStudios 8 8 * Author URI: https://webdevstudios.com … … 72 72 * @param WP_Post $post Post object. 73 73 */ 74 function wds_set_media_as_featured_image( $post_id,$post ) {74 function wds_set_media_as_featured_image( int $post_id, WP_Post $post ) { 75 75 wds_check_if_content_contains_video( $post_id, $post ); 76 76 _doing_it_wrong( 'wds_set_media_as_feature_image', esc_html__( 'This function has been replaced with wds_check_if_content_contains_video', 'automatic-featured-images-from-videos' ), '4.6' ); … … 84 84 * @since 1.0.5 85 85 * 86 * @param int $post_id ID of the post being saved.87 * @param object $post Post object.88 */ 89 function wds_check_if_content_contains_video( $post_id,$post ) {86 * @param int $post_id ID of the post being saved. 87 * @param WP_Post $post Post object. 88 */ 89 function wds_check_if_content_contains_video( int $post_id, WP_Post $post ) { 90 90 91 91 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { … … 99 99 } 100 100 101 $content = isset( $post->post_content ) ? $post->post_content :'';101 $content = $post->post_content ?? ''; 102 102 103 103 /** … … 185 185 * @param string $video_thumbnail_url URL of the image thumbnail. 186 186 * @param string $video_id Video ID from embed. 187 */ 188 function wds_set_video_thumbnail_as_featured_image( $post_id, $video_thumbnail_url, $video_id = '', $video_title = '' ) { 187 * @param string $video_title Video title from embed 188 */ 189 function wds_set_video_thumbnail_as_featured_image( int $post_id, string $video_thumbnail_url, string $video_id = '', string $video_title = '' ) { 189 190 190 191 // Bail if no valid video thumbnail URL. … … 276 277 * @return mixed 277 278 */ 278 function wds_ms_media_sideload_image_with_new_filename( $url, $post_id, $filename = null, $video_id = null) {279 function wds_ms_media_sideload_image_with_new_filename( string $url, int $post_id, string $filename = '', string $video_id = '' ) { 279 280 280 281 if ( ! $url || ! $post_id ) { … … 364 365 * @return array Video data. 365 366 */ 366 function wds_get_youtube_details( $youtube_id ){367 function wds_get_youtube_details( string $youtube_id ): array { 367 368 $video = []; 368 369 $video_thumbnail_url_string = 'https://img.youtube.com/vi/%s/%s'; … … 408 409 * @return array Video information. 409 410 */ 410 function wds_get_vimeo_details( $vimeo_id ){411 function wds_get_vimeo_details( string $vimeo_id ): array { 411 412 $video = []; 412 413 … … 416 417 $response = json_decode( $vimeo_data['body'] ); 417 418 418 $large = isset( $response[0]->thumbnail_large ) ? $response[0]->thumbnail_large :'';419 $large = $response[0]->thumbnail_large ?? ''; 419 420 if ( $large ) { 420 421 $larger_test = explode( '_', $large ); … … 447 448 * @return bool 448 449 */ 449 function wds_post_has_video( $post_id ) {450 function wds_post_has_video( int $post_id ) { 450 451 if ( ! metadata_exists( 'post', $post_id, '_is_video' ) ) { 451 452 wds_check_if_content_contains_video( $post_id, get_post( $post_id ) ); … … 465 466 * @return string 466 467 */ 467 function wds_get_video_url( $post_id ){468 function wds_get_video_url( int $post_id ): string { 468 469 if ( wds_post_has_video( $post_id ) ) { 469 470 if ( ! metadata_exists( 'post', $post_id, '_video_url' ) ) { … … 486 487 * @return string 487 488 */ 488 function wds_get_embeddable_video_url( $post_id ){489 function wds_get_embeddable_video_url( int $post_id ) : string { 489 490 if ( wds_post_has_video( $post_id ) ) { 490 491 if ( ! metadata_exists( 'post', $post_id, '_video_embed_url' ) ) { … … 501 502 * @author Gary Kovar 502 503 * @since 1.1.0 503 */ 504 function wds_register_display_video_metabox( $post_type, $post ) { 504 * 505 * @param string $post_type Current post type for post being rendered 506 */ 507 function wds_register_display_video_metabox( string $post_type, WP_Post $post ) { 505 508 if ( get_post_meta( $post->ID, '_is_video', true ) ) { 506 509 add_meta_box( … … 535 538 * @return WP_Query WP_Query object 536 539 */ 537 function wds_automatic_featured_images_from_videos_wp_query( $post_type, $posts_per_page ){540 function wds_automatic_featured_images_from_videos_wp_query( string $post_type, int $posts_per_page ): WP_Query { 538 541 $args = [ 539 542 'post_type' => $post_type, -
automatic-featured-images-from-videos/trunk/includes/ajax.php
r3265913 r3417789 17 17 18 18 // Register the script we might use. 19 wp_register_script( 'wds_featured_images_from_video_script', WDSAFI_DIR . 'js/button.js' );19 wp_register_script( 'wds_featured_images_from_video_script', WDSAFI_DIR . 'js/button.js', [], '1.2.6' ); 20 20 21 21 global $post_type; … … 47 47 * @return string 48 48 */ 49 function wds_featured_images_from_video_processing_status( $post_type ) {49 function wds_featured_images_from_video_processing_status( string $post_type ) { 50 50 51 51 // Check if the bulk task has already been scheduled. 52 if ( wp_next_scheduled( 'wds_bulk_process_video_query_init', array( $post_type )) ) {52 if ( wp_next_scheduled( 'wds_bulk_process_video_query_init', [ $post_type ] ) ) { 53 53 return 'running'; 54 54 } … … 57 57 $query = wds_automatic_featured_images_from_videos_wp_query( $post_type, apply_filters( 'wds_featured_images_from_video_posts_bulk_quantity', 10 ) ); 58 58 59 if ( $query->post_count > 1 ) {59 if ( $query->post_count >= 1 ) { 60 60 return 'ready_to_process'; 61 61 } … … 71 71 */ 72 72 function wds_featured_images_from_video_processing_current_disposition() { 73 return esc_html__( 'Processing...', ' wds_automatic_featured_images_from_videos' );73 return esc_html__( 'Processing...', 'automatic-featured-images-from-videos' ); 74 74 } -
automatic-featured-images-from-videos/trunk/includes/bulk-operations.php
r3265913 r3417789 46 46 * @param string $post_type Post type to process. 47 47 */ 48 function wds_bulk_process_video_query( $post_type ) {48 function wds_bulk_process_video_query( string $post_type ) { 49 49 50 50 $post_count = 10; -
automatic-featured-images-from-videos/trunk/readme.txt
r3265913 r3417789 3 3 Contributors: webdevstudios, pluginize 4 4 Donate link: http://webdevstudios.com/ 5 Tags: video, youtube, vimeo, featured image5 Tags: youtube, vimeo, automatic featured image, featured images, video 6 6 Requires at least: 5.0 7 Tested up to: 6. 7.28 Stable tag: 1.2. 57 Tested up to: 6.9 8 Stable tag: 1.2.6 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 Requires PHP: 5.611 Requires PHP: 7.4 12 12 13 13 If a YouTube or Vimeo video embed exists near the start of a post, we'll automatically set the post's featured image to a thumbnail of the video. … … 40 40 41 41 == Changelog == 42 43 = 1.2.6 = 44 * Fixed: bulk processing if only 0ne post was found needing processing. Originally needed 2 or more 45 * Fixed: missed textdomain 46 * Bumped required PHP to 7.4 47 * Confirmed compatibility with WordPress 6.9 42 48 43 49 = 1.2.5 =
Note: See TracChangeset
for help on using the changeset viewer.