diff --git a/php/class-video-thumbnails-settings.php b/php/class-video-thumbnails-settings.php index 7321648..e69a30d 100755 --- a/php/class-video-thumbnails-settings.php +++ b/php/class-video-thumbnails-settings.php @@ -30,7 +30,7 @@ class Video_Thumbnails_Settings { function __construct() { // Activation and deactivation hooks register_activation_hook( VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php', array( &$this, 'plugin_activation' ) ); - register_deactivation_hook( VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php', array( &$this, 'plugin_deactivation' ) ); + register_uninstall_hook( VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php', array( &$this, 'plugin_deactivation' ) ); // Set current options add_action( 'plugins_loaded', array( &$this, 'set_options' ) ); // Add options page to menu @@ -86,7 +86,7 @@ function upgrade_options( $options ) { $post_types = get_option( 'video_thumbnails_post_types' ); // If there is a a post type option we know there should be others - if ( $post_types !== false ) { + if ( false !== $post_types ) { $options['post_types'] = $post_types; delete_option( 'video_thumbnails_post_types' ); @@ -124,8 +124,8 @@ function upgrade_options( $options ) { function admin_menu() { add_options_page( - __( 'Video Thumbnails Options', 'video-thumbnails' ), - __( 'Video Thumbnails', 'video-thumbnails' ), + esc_html__( 'Video Thumbnails Options', 'video-thumbnails' ), + esc_html__( 'Video Thumbnails', 'video-thumbnails' ), 'manage_options', 'video_thumbnails', array( &$this, 'options_page' ) @@ -133,15 +133,15 @@ function admin_menu() { } function admin_scripts( $hook ) { - if ( 'settings_page_video_thumbnails' == $hook ) { + if ( 'settings_page_video_thumbnails' === $hook ) { wp_enqueue_style( 'video-thumbnails-settings-css', plugins_url( '/css/settings.css', VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php' ), false, VIDEO_THUMBNAILS_VERSION ); wp_enqueue_script( 'video_thumbnails_settings', plugins_url( 'js/settings.js' , VIDEO_THUMBNAILS_PATH . '/video-thumbnails.php' ), array( 'jquery' ), VIDEO_THUMBNAILS_VERSION ); wp_localize_script( 'video_thumbnails_settings', 'video_thumbnails_settings_language', array( - 'detection_failed' => __( 'We were unable to find a video in the custom fields of your most recently updated post.', 'video-thumbnails' ), - 'working' => __( 'Working...', 'video-thumbnails' ), - 'retest' => __( 'Retest', 'video-thumbnails' ), - 'ajax_error' => __( 'AJAX Error:', 'video-thumbnails' ), - 'clear_all_confirmation' => __( 'Are you sure you want to clear all video thumbnails? This cannot be undone.', 'video-thumbnails' ), + 'detection_failed' => esc_html__( 'We were unable to find a video in the custom fields of your most recently updated post.', 'video-thumbnails' ), + 'working' => esc_html__( 'Working...', 'video-thumbnails' ), + 'retest' => esc_html__( 'Retest', 'video-thumbnails' ), + 'ajax_error' => esc_html__( 'AJAX Error:', 'video-thumbnails' ), + 'clear_all_confirmation' => esc_html__( 'Are you sure you want to clear all video thumbnails? This cannot be undone.', 'video-thumbnails' ), ) ); global $video_thumbnails; $provider_slugs = array(); @@ -194,10 +194,10 @@ function ajax_clear_all_callback() { foreach ( $media_library_items as $item ) { wp_delete_attachment( $item, true ); } - echo '

' . sprintf( _n( '1 attachment deleted', '%s attachments deleted', count( $media_library_items ), 'video-thumbnails' ), count( $media_library_items ) ) . '

'; + echo '

' . sprintf( esc_html( _n( '1 attachment deleted', '%s attachments deleted', count( $media_library_items ), 'video-thumbnails' ) ), count( $media_library_items ) ) . '

'; // Clear custom fields $custom_fields_cleared = $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key='_video_thumbnail'" ); - echo '

' . sprintf( _n( '1 custom field cleared', '%s custom fields cleared', $custom_fields_cleared, 'video-thumbnails' ), $custom_fields_cleared ) . '

'; + echo '

' . sprintf( esc_html( _n( '1 custom field cleared', '%s custom fields cleared', $custom_fields_cleared, 'video-thumbnails' ) ), $custom_fields_cleared ) . '

'; } else { echo '

' . __( 'Error: Could not verify nonce.', 'video-thumbnails' ) . '

'; } @@ -225,46 +225,47 @@ function provider_test_callback() { - - - + + + providers[$_POST['provider_slug']]; + $failed = 0; foreach ( $provider->get_test_cases() as $test_case ) { echo ''; - echo ''; + echo ''; $markup = apply_filters( 'the_content', $test_case['markup'] ); $result = $video_thumbnails->get_first_thumbnail_url( $markup ); if ( is_wp_error( $result ) ) { $error_string = $result->get_error_message(); - echo ''; + echo ''; echo ''; $failed++; } else { $result_hash = false; - if ( $result == $test_case['expected'] ) { + if ( $result === $test_case['expected'] ) { $matched = true; } else { $result_hash = $this->get_file_hash( $result ); - $matched = ( $result_hash == $test_case['expected_hash'] ? true : false ); + $matched = ( $result_hash === $test_case['expected_hash'] ? true : false ); } if ( $matched ) { - echo ''; + echo ''; } else { - echo ''; + echo ''; } echo ''; } @@ -286,10 +287,10 @@ function image_download_test_callback() { } else { update_post_meta( $attachment_id, 'video_thumbnail_test_image', '1' ); $image = wp_get_attachment_image_src( $attachment_id, 'full' ); - echo ''; - echo '

' . __( 'Attachment created', 'video-thumbnails' ) . '

'; - echo '

' . __( 'View in Media Library', 'video-thumbnails' ) . '

'; - echo '' . __( 'View full size', 'video-thumbnails' ) . ''; + echo ''; + echo '

' . esc_html__( 'Attachment created', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'View in Media Library', 'video-thumbnails' ) . '

'; + echo '' . esc_html__( 'View full size', 'video-thumbnails' ) . ''; echo ''; } @@ -312,7 +313,7 @@ function delete_test_images_callback() { foreach ( $media_library_items as $item ) { wp_delete_attachment( $item, true ); } - echo '

' . sprintf( _n( '1 attachment deleted', '%s attachments deleted', count( $media_library_items ), 'video-thumbnails' ), count( $media_library_items ) ) . '

'; + echo '

' . sprintf( esc_html( _n( '1 attachment deleted', '%s attachments deleted', count( $media_library_items ), 'video-thumbnails' ) ), count( $media_library_items ) ) . '

'; die(); } // End delete test images callback @@ -325,31 +326,31 @@ function markup_detection_test_callback() { global $video_thumbnails; - $markup = apply_filters( 'the_content', stripslashes( $_POST['markup'] ) ); + $markup = apply_filters( 'the_content', wp_kses_post( $_POST['markup'] ) ); $new_thumbnail = $video_thumbnails->get_first_thumbnail_url( $markup ); - if ( $new_thumbnail == null ) { + if ( null === $new_thumbnail ) { // No thumbnail - echo '

' . __( 'No thumbnail found', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'No thumbnail found', 'video-thumbnails' ) . '

'; } elseif ( is_wp_error( $new_thumbnail ) ) { // Error finding thumbnail - echo '

' . __( 'Error Details:', 'video-thumbnails' ) . ' ' . $new_thumbnail->get_error_message() . '

'; + echo '

' . esc_html__( 'Error Details:', 'video-thumbnails' ) . ' ' . $new_thumbnail->get_error_message() . '

'; } else { // Found a thumbnail $remote_response = wp_remote_head( $new_thumbnail ); if ( is_wp_error( $remote_response ) ) { // WP Error trying to read image from remote server - echo '

' . __( 'Thumbnail found, but there was an error retrieving the URL.', 'video-thumbnails' ) . '

'; - echo '

' . __( 'Error Details:', 'video-thumbnails' ) . ' ' . $remote_response->get_error_message() . '

'; - } elseif ( $remote_response['response']['code'] != '200' ) { + echo '

' . esc_html__( 'Thumbnail found, but there was an error retrieving the URL.', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'Error Details:', 'video-thumbnails' ) . ' ' . $remote_response->get_error_message() . '

'; + } elseif ( '200' !== $remote_response['response']['code'] ) { // Response code isn't okay - echo '

' . __( 'Thumbnail found, but it may not exist on the source server. If opening the URL below in your web browser returns an error, the source is providing an invalid URL.', 'video-thumbnails' ) . '

'; - echo '

' . __( 'Thumbnail URL:', 'video-thumbnails' ) . ' ' . $new_thumbnail . ''; + echo '

' . esc_html__( 'Thumbnail found, but it may not exist on the source server. If opening the URL below in your web browser returns an error, the source is providing an invalid URL.', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'Thumbnail URL:', 'video-thumbnails' ) . ' ' . esc_html( $new_thumbnail ) . ''; } else { // Everything is okay! - echo '

' . __( 'Thumbnail found! Image should appear below.', 'video-thumbnails' ) . ' ' . __( 'View full size', 'video-thumbnails' ) . '

'; - echo '

'; + echo '

' . esc_html__( 'Thumbnail found! Image should appear below.', 'video-thumbnails' ) . ' ' . esc_html__( 'View full size', 'video-thumbnails' ) . '

'; + echo '

'; } } @@ -359,19 +360,19 @@ function markup_detection_test_callback() { function initialize_options() { add_settings_section( 'general_settings_section', - __( 'General Settings', 'video-thumbnails' ), + esc_html__( 'General Settings', 'video-thumbnails' ), array( &$this, 'general_settings_callback' ), 'video_thumbnails' ); $this->add_checkbox_setting( 'save_media', - __( 'Save Thumbnails to Media Library', 'video-thumbnails' ), - __( 'Checking this option will download video thumbnails to your server', 'video-thumbnails' ) + esc_html__( 'Save Thumbnails to Media Library', 'video-thumbnails' ), + esc_html__( 'Checking this option will download video thumbnails to your server', 'video-thumbnails' ) ); $this->add_checkbox_setting( 'set_featured', - __( 'Automatically Set Featured Image', 'video-thumbnails' ), - __( 'Check this option to automatically set video thumbnails as the featured image (requires saving to media library)', 'video-thumbnails' ) + esc_html__( 'Automatically Set Featured Image', 'video-thumbnails' ), + esc_html__( 'Check this option to automatically set video thumbnails as the featured image (requires saving to media library)', 'video-thumbnails' ) ); // Get post types $post_types = get_post_types( null, 'names' ); @@ -379,13 +380,13 @@ function initialize_options() { $post_types = array_diff( $post_types, array( 'attachment', 'revision', 'nav_menu_item' ) ); $this->add_multicheckbox_setting( 'post_types', - __( 'Post Types', 'video-thumbnails' ), + esc_html__( 'Post Types', 'video-thumbnails' ), $post_types ); $this->add_text_setting( 'custom_field', __( 'Custom Field (optional)', 'video-thumbnails' ), - '' . __( 'Automatically Detect', 'video-thumbnails' ) . ' ' . __( 'Enter the name of the custom field where your embed code or video URL is stored.', 'video-thumbnails' ) + '' . esc_html__( 'Automatically Detect', 'video-thumbnails' ) . ' ' . esc_html__( 'Enter the name of the custom field where your embed code or video URL is stored.', 'video-thumbnails' ) ); register_setting( 'video_thumbnails', 'video_thumbnails', array( &$this, 'sanitize_callback' ) ); } @@ -396,7 +397,7 @@ function sanitize_callback( $input ) { // General settings if ( !isset( $input['provider_options'] ) ) { foreach( $current_settings as $key => $value ) { - if ( $key == 'version' OR $key == 'providers' ) { + if ( 'version' === $key || 'providers' === $key ) { $output[$key] = $current_settings[$key]; } elseif ( isset( $input[$key] ) ) { $output[$key] = $input[$key]; @@ -415,7 +416,7 @@ function sanitize_callback( $input ) { } function general_settings_callback() { - echo '

' . __( 'These options configure where the plugin will search for videos and what to do with thumbnails once found.', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'These options configure where the plugin will search for videos and what to do with thumbnails once found.', 'video-thumbnails' ) . '

'; } function add_checkbox_setting( $slug, $name, $description ) { @@ -433,7 +434,7 @@ function add_checkbox_setting( $slug, $name, $description ) { } function checkbox_callback( $args ) { - $html = ''; + $html = ''; echo $html; } @@ -459,8 +460,8 @@ function multicheckbox_callback( $args ) { } $html = ''; foreach ( $args['options'] as $option ) { - $checked = ( in_array( $option, $selected_types ) ? 'checked="checked"' : '' ); - $html .= '
'; + $checked = ( in_array( $option, $selected_types, true ) ? 'checked="checked"' : '' ); + $html .= '
'; } echo $html; } @@ -480,39 +481,39 @@ function add_text_setting( $slug, $name, $description ) { } function text_field_callback( $args ) { - $html = ''; - $html .= ''; + $html = ''; + $html .= ''; echo $html; } function options_page() { if ( ! current_user_can( 'manage_options' ) ) { - wp_die( __( 'You do not have sufficient permissions to access this page.', 'video-thumbnails' ) ); + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'video-thumbnails' ) ); } global $video_thumbnails; ?>
-

+

-

+

-

+

Video Thumbnails on the official plugin directory.', 'video-thumbnails' ); ?>

@@ -526,7 +527,7 @@ function options_page() { // End main settings } // Provider Settings - if ( $active_tab == 'provider_settings' ) { + if ( 'provider_settings' === $active_tab ) { ?>
@@ -540,19 +541,19 @@ function options_page() { // End provider settings } // Scan all posts - if ( $active_tab == 'mass_actions' ) { + if ( 'mass_actions' === $active_tab ) { ?> -

+

-

+

-

+

-

+

-

+

-

+

@@ -560,28 +561,28 @@ function options_page() { // End scan all posts } // Debugging - if ( $active_tab == 'debugging' ) { + if ( 'debugging' === $active_tab ) { ?> -

+

- + -

+

-

+

- - + + - - + + - - + + - - + + - - + + - + @@ -701,7 +702,7 @@ function options_page() { // End debugging } // Support - if ( $active_tab == 'support' ) { + if ( 'support' === $active_tab ) { Video_Thumbnails::no_video_thumbnail_troubleshooting_instructions(); @@ -718,13 +719,11 @@ public static function settings_footer() { ?>
-

-

+

+

\ No newline at end of file diff --git a/php/extensions/automatic-youtube-video-posts.php b/php/extensions/automatic-youtube-video-posts.php index 2d26bec..736331a 100755 --- a/php/extensions/automatic-youtube-video-posts.php +++ b/php/extensions/automatic-youtube-video-posts.php @@ -69,5 +69,3 @@ function ayvp_new_video_thumbnail_url_filter( $new_thumbnail, $post_id ) { remove_filter( 'post_thumbnail_html', 'WP_ayvpp_thumbnail' ); remove_filter( 'post_thumbnail_size', 'WP_ayvpp_thumbnail_size' ); } - -?> \ No newline at end of file diff --git a/php/extensions/extensions.php b/php/extensions/extensions.php index de562d7..9df576b 100644 --- a/php/extensions/extensions.php +++ b/php/extensions/extensions.php @@ -19,5 +19,3 @@ require_once( VIDEO_THUMBNAILS_PATH . '/php/extensions/automatic-youtube-video-posts.php' ); require_once( VIDEO_THUMBNAILS_PATH . '/php/extensions/simple-video-embedder.php' ); require_once( VIDEO_THUMBNAILS_PATH . '/php/extensions/wp-robot.php' ); - -?> \ No newline at end of file diff --git a/php/extensions/simple-video-embedder.php b/php/extensions/simple-video-embedder.php index b75cd98..67f697e 100755 --- a/php/extensions/simple-video-embedder.php +++ b/php/extensions/simple-video-embedder.php @@ -27,5 +27,3 @@ function simple_video_embedder_video_thumbnail_markup_filter( $markup, $post_id // Add filter to modify markup add_filter( 'video_thumbnail_markup', 'simple_video_embedder_video_thumbnail_markup_filter', 10, 2 ); - -?> \ No newline at end of file diff --git a/php/extensions/wp-robot.php b/php/extensions/wp-robot.php index 6c2e8b0..b8908e2 100644 --- a/php/extensions/wp-robot.php +++ b/php/extensions/wp-robot.php @@ -31,5 +31,3 @@ function video_thumbnails_wpr_after_post_action( $post_id ) { } add_action( 'wpr_after_post', 'video_thumbnails_wpr_after_post_action', 10, 1 ); - -?> \ No newline at end of file diff --git a/php/providers/class-blip-thumbnails.php b/php/providers/class-blip-thumbnails.php index bb8fc3f..fbe0236 100755 --- a/php/providers/class-blip-thumbnails.php +++ b/php/providers/class-blip-thumbnails.php @@ -62,17 +62,15 @@ public static function get_test_cases() { 'markup' => 'http://blip.tv/cranetv/illustrator-katie-scott-6617917', 'expected' => 'http://a.images.blip.tv/CraneTV-IllustratorKatieScott610.jpg', 'expected_hash' => '26a622f72bd4bdb3f8189f85598dd95d', - 'name' => __( 'Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'Video URL', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://a.images.blip.tv/GeekCrashCourse-TheAvengersMarvelMovieCatchUpGeekCrashCourse331.png', 'expected_hash' => '87efa9f6b0d9111b0826ae4fbdddec1b', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-collegehumor-thumbnails.php b/php/providers/class-collegehumor-thumbnails.php index bf0354c..a8fc8ad 100755 --- a/php/providers/class-collegehumor-thumbnails.php +++ b/php/providers/class-collegehumor-thumbnails.php @@ -58,17 +58,15 @@ public static function get_test_cases() { 'markup' => '

CollegeHumor\'s Favorite Funny Videos

', 'expected' => 'http://2.media.collegehumor.cvcdn.com/62/99/20502ca0d5b2172421002b52f437dcf8-mitt-romney-style-gangnam-style-parody.jpg', 'expected_hash' => 'ceac16f6ee1fa5d8707e813226060a15', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => 'http://www.collegehumor.com/video/6830834/mitt-romney-style-gangnam-style-parody', 'expected' => 'http://2.media.collegehumor.cvcdn.com/62/99/20502ca0d5b2172421002b52f437dcf8-mitt-romney-style-gangnam-style-parody.jpg', 'expected_hash' => 'ceac16f6ee1fa5d8707e813226060a15', - 'name' => __( 'Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'Video URL', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-dailymotion-thumbnails.php b/php/providers/class-dailymotion-thumbnails.php index fe8b29a..d204be5 100755 --- a/php/providers/class-dailymotion-thumbnails.php +++ b/php/providers/class-dailymotion-thumbnails.php @@ -60,17 +60,15 @@ public static function get_test_cases() { 'markup' => '
Adam Yauch of the Beastie Boys Dies at 47by associatedpress', 'expected' => 'http://s1.dmcdn.net/AMjdy.jpg', 'expected_hash' => '077888b97839254892a377f51c06e642', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '
Adam Yauch of the Beastie Boys Dies at 47by associatedpress', 'expected' => 'http://s1.dmcdn.net/AMjdy.jpg', 'expected_hash' => '077888b97839254892a377f51c06e642', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-facebook-thumbnails.php b/php/providers/class-facebook-thumbnails.php index 6dec87e..437f576 100755 --- a/php/providers/class-facebook-thumbnails.php +++ b/php/providers/class-facebook-thumbnails.php @@ -68,23 +68,21 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/p160x160/50796_2560034672650_2560032632599_65313_313_b.jpg?oh=e8c767b1efafa6d8a4b672bad7be38d6&oe=55364081&__gda__=1428807476_a4d83140019b11ad602f2ef9960a364e', 'expected_hash' => '6b033d8f16dbf273048c5771d32ede64', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xap1/v/t15.0-10/p160x160/50796_2560034672650_2560032632599_65313_313_b.jpg?oh=e8c767b1efafa6d8a4b672bad7be38d6&oe=55364081&__gda__=1428807476_a4d83140019b11ad602f2ef9960a364e', 'expected_hash' => '6b033d8f16dbf273048c5771d32ede64', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '
Post by Peter Jackson.
', 'expected' => 'https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-xfa1/v/t15.0-10/p128x128/244423_10150326375786807_10150326323406807_4366_759_b.jpg?oh=013ce21bb54de51c383071598b269a91&oe=552CD270&__gda__=1428479462_339647870ec32227c391e98000935aec', 'expected_hash' => '184d20db21ac8edef9c9cee291be5ee6', - 'name' => __( 'FBML Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'FBML Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-funnyordie-thumbnails.php b/php/providers/class-funnyordie-thumbnails.php index e64cc19..64fbea2 100755 --- a/php/providers/class-funnyordie-thumbnails.php +++ b/php/providers/class-funnyordie-thumbnails.php @@ -59,17 +59,15 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg', 'expected_hash' => '5aafa4a5f27bd4aead574db38a9e8b2b', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://t.fod4.com/t/5325b03b52/c480x270_17.jpg', 'expected_hash' => '5aafa4a5f27bd4aead574db38a9e8b2b', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-googledrive-thumbnails.php b/php/providers/class-googledrive-thumbnails.php index 9a463c0..499badd 100644 --- a/php/providers/class-googledrive-thumbnails.php +++ b/php/providers/class-googledrive-thumbnails.php @@ -83,29 +83,27 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'https://lh3.googleusercontent.com/QL3d7Wh7V_qcXnMpXT6bio77RS0veyCZZ0zQbMX6gd-qH7aeIXBkXlcSJVDEyftiiA=s480', 'expected_hash' => '3bc674d8d77b342e633ab9e93e345462', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'https://lh6.googleusercontent.com/WeOdCsaplJ3am25To1uLZiVYkyrilAQ5rxzhjnyyFc5GAF4QeCF1eq3EMpbP7O5dFg=s480', 'expected_hash' => 'f120755bbd1d35e381cb84a829ac0dfa', - 'name' => __( 'iFrame Embed (Apps account)', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed (Apps account)', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'https://lh3.googleusercontent.com/U_lqaX1o7E9iU75XwCrHZ4pdSi-Vch2F_GK5Ib7WAxgwKTvTl0kMHXm2GxKo1Pcp3Q=s480', 'expected_hash' => '31cf8e05f981c1beb6e04823ad54d267', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'https://lh5.googleusercontent.com/mHn5gESachhZHi-kbPCRbR6RVXZm3bR7oNNXL97LyYjpzV3Eqty71J2Waw0DPnXKKw=s480', 'expected_hash' => '2d0ad4881e4b38de0510a103d2f40dd1', - 'name' => __( 'Flash Embed (YouTube player)', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed (YouTube player)', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-kaltura-thumbnails.php b/php/providers/class-kaltura-thumbnails.php index 23075b4..9898870 100755 --- a/php/providers/class-kaltura-thumbnails.php +++ b/php/providers/class-kaltura-thumbnails.php @@ -65,11 +65,9 @@ public static function get_test_cases() { array( 'markup' => '', 'expected' => 'http://example.com/thumbnail.jpg', - 'name' => __( 'Auto Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Auto Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-livestream-thumbnails.php b/php/providers/class-livestream-thumbnails.php index 5880c5f..4be2f53 100644 --- a/php/providers/class-livestream-thumbnails.php +++ b/php/providers/class-livestream-thumbnails.php @@ -51,11 +51,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://thumbnail.api.livestream.com/thumbnail?name=WFMZ_Traffic', 'expected_hash' => '1be02799b2fab7a4749b2187f7687412', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-metacafe-thumbnails.php b/php/providers/class-metacafe-thumbnails.php index 8eaf880..e83c4c9 100755 --- a/php/providers/class-metacafe-thumbnails.php +++ b/php/providers/class-metacafe-thumbnails.php @@ -60,11 +60,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://s4.mcstatic.com/thumb/8456223/22479418/4/catalog_item5/0/1/men_in_black_3_trailer_2.jpg', 'expected_hash' => '977187bfb00df55b39724d7de284f617', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-mpora-thumbnails.php b/php/providers/class-mpora-thumbnails.php index 13777cf..8b33204 100755 --- a/php/providers/class-mpora-thumbnails.php +++ b/php/providers/class-mpora-thumbnails.php @@ -51,17 +51,15 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://ugc4.mporatrons.com/thumbs/wEr2CBooV_640x360_0000.jpg', 'expected_hash' => '95075bd4941251ebecbab3b436a90c49', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://ugc4.mporatrons.com/thumbs/AAdfegovdop0_640x360_0000.jpg', 'expected_hash' => '45db22a2ba5ef20163f52ba562b89259', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-rutube-thumbnails.php b/php/providers/class-rutube-thumbnails.php index fb8030c..33812df 100644 --- a/php/providers/class-rutube-thumbnails.php +++ b/php/providers/class-rutube-thumbnails.php @@ -62,17 +62,15 @@ public static function get_test_cases() { 'markup' => 'http://rutube.ru/video/ca8607cd4f7ef28516e043dde0068564/', 'expected' => 'http://pic.rutube.ru/video/3a/c8/3ac8c1ded16501002d20fa3ba3ed3d61.jpg', 'expected_hash' => '85ad79c118ee82c7c2a756ba29a96354', - 'name' => __( 'Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'Video URL', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://pic.rutube.ru/video/3a/c8/3ac8c1ded16501002d20fa3ba3ed3d61.jpg', 'expected_hash' => '85ad79c118ee82c7c2a756ba29a96354', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-sapo-thumbnails.php b/php/providers/class-sapo-thumbnails.php index 329dd53..af2ce16 100644 --- a/php/providers/class-sapo-thumbnails.php +++ b/php/providers/class-sapo-thumbnails.php @@ -68,11 +68,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://cache02.stormap.sapo.pt/vidstore14/thumbnais/e9/08/37/7038489_l5VMt.jpg', 'expected_hash' => 'd8a74c3d4e054263a37abe9ceed782fd', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-ted-thumbnails.php b/php/providers/class-ted-thumbnails.php index 450f603..048d9ac 100755 --- a/php/providers/class-ted-thumbnails.php +++ b/php/providers/class-ted-thumbnails.php @@ -58,17 +58,15 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://images.ted.com/images/ted/341053090f8bac8c324c75be3114b673b4355e8a_480x360.jpg?lang=en', 'expected_hash' => 'f2a5f6af49e841b4f9c7b95d6ca0372a', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://images.ted.com/images/ted/b1f1183311cda4df9e1b65f2b363e0b806bff914_480x360.jpg?lang=en', 'expected_hash' => 'ff47c99c9eb95e3d6c4b986b18991f22', - 'name' => __( 'Custom Language', 'video-thumbnails' ) + 'name' => esc_html__( 'Custom Language', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-tudou-thumbnails.php b/php/providers/class-tudou-thumbnails.php index db3f407..ea87ecd 100644 --- a/php/providers/class-tudou-thumbnails.php +++ b/php/providers/class-tudou-thumbnails.php @@ -82,11 +82,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://g3.tdimg.com/83fedbc41cf9055dce9182a0c07da601/w_2.jpg', 'expected_hash' => '3a5e656f8c302ae5b23665f22d296ae1', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-twitch-thumbnails.php b/php/providers/class-twitch-thumbnails.php index 2b25cbe..3178bbf 100644 --- a/php/providers/class-twitch-thumbnails.php +++ b/php/providers/class-twitch-thumbnails.php @@ -60,17 +60,15 @@ public static function get_test_cases() { 'markup' => 'http://www.twitch.tv/jodenstone/c/5793313', 'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-605904705-320x240.jpg', 'expected_hash' => '1b2c51fc7380c74d1b2d34751d73e4cb', - 'name' => __( 'Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'Video URL', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://static-cdn.jtvnw.net/jtv.thumbs/archive-605904705-320x240.jpg', 'expected_hash' => '1b2c51fc7380c74d1b2d34751d73e4cb', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-video-thumbnails-provider.php b/php/providers/class-video-thumbnails-provider.php index 1305f57..c05b3d7 100755 --- a/php/providers/class-video-thumbnails-provider.php +++ b/php/providers/class-video-thumbnails-provider.php @@ -58,8 +58,8 @@ function settings_section_callback() { function text_setting_callback( $args ) { $value = ( isset( $this->options[$args['slug']] ) ? $this->options[$args['slug']] : '' ); - $html = ''; - $html .= ''; + $html = ''; + $html .= ''; echo $html; } @@ -110,5 +110,3 @@ function construct_info_retrieval_error( $request, $response ) { // } } - -?> \ No newline at end of file diff --git a/php/providers/class-vimeo-thumbnails.php b/php/providers/class-vimeo-thumbnails.php index 759083f..ecfc4dc 100755 --- a/php/providers/class-vimeo-thumbnails.php +++ b/php/providers/class-vimeo-thumbnails.php @@ -673,5 +673,3 @@ public static function url_encode_rfc3986($input) if( !class_exists( 'VimeoAPIException' ) ) { class VimeoAPIException extends Exception {} } - -?> \ No newline at end of file diff --git a/php/providers/class-vine-thumbnails.php b/php/providers/class-vine-thumbnails.php index 385a952..ddb97e2 100644 --- a/php/providers/class-vine-thumbnails.php +++ b/php/providers/class-vine-thumbnails.php @@ -66,11 +66,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'https://v.cdn.vine.co/v/thumbs/D6DDE013-F8DA-4929-9BED-49568F424343-184-00000008A20C1AEC_1.0.6.mp4.jpg', 'expected_hash' => '7cca5921108abe15b8c1c1f884a5b3ac', - 'name' => __( 'iFrame Embed/Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed/Video URL', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-vk-thumbnails.php b/php/providers/class-vk-thumbnails.php index da42fed..71268de 100644 --- a/php/providers/class-vk-thumbnails.php +++ b/php/providers/class-vk-thumbnails.php @@ -68,11 +68,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://cs540302.vk.me/u220943440/video/l_afc9770f.jpg', 'expected_hash' => 'fd8c2af4ad5cd4e55afe129d80b42d8b', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-wistia-thumbnails.php b/php/providers/class-wistia-thumbnails.php index 825acb5..ed20831 100755 --- a/php/providers/class-wistia-thumbnails.php +++ b/php/providers/class-wistia-thumbnails.php @@ -82,17 +82,15 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'https://embed-ssl.wistia.com/deliveries/6928fcba8355e38de4d95863a659e1de23cb2071.jpg', 'expected_hash' => 'bc4a2cec9ac97e2ccdae2c7387a01cb4', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '
', 'expected' => 'https://embed-ssl.wistia.com/deliveries/a086707fe096e7f3fbefef1d1dcba1488d23a3e9.jpg', 'expected_hash' => '4c63d131604bfc07b5178413ab245813', - 'name' => __( 'JavaScript Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'JavaScript Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-yahooscreen-thumbnails.php b/php/providers/class-yahooscreen-thumbnails.php index 90e36d7..13ca986 100644 --- a/php/providers/class-yahooscreen-thumbnails.php +++ b/php/providers/class-yahooscreen-thumbnails.php @@ -66,11 +66,9 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://media.zenfs.com/en-US/video/video.abcnewsplus.com/7c70071008e3711818517f19b6ad9629', 'expected_hash' => '22c2b172b297cf09511d832ddab7b9f5', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-youku-thumbnails.php b/php/providers/class-youku-thumbnails.php index d08a332..47ac418 100755 --- a/php/providers/class-youku-thumbnails.php +++ b/php/providers/class-youku-thumbnails.php @@ -60,23 +60,21 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://g1.ykimg.com/1100641F464F0FB57407E2053DFCBC802FBBC4-E4C5-7A58-0394-26C366F10493', 'expected_hash' => 'deac7bb89058a8c46ae2350da9d33ba8', - 'name' => __( 'iFrame Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://g1.ykimg.com/1100641F464F0FB57407E2053DFCBC802FBBC4-E4C5-7A58-0394-26C366F10493', 'expected_hash' => 'deac7bb89058a8c46ae2350da9d33ba8', - 'name' => __( 'Flash Embed', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed', 'video-thumbnails' ) ), array( 'markup' => 'http://v.youku.com/v_show/id_XMzQyMzk5MzQ4.html', 'expected' => 'http://g1.ykimg.com/1100641F464F0FB57407E2053DFCBC802FBBC4-E4C5-7A58-0394-26C366F10493', 'expected_hash' => 'deac7bb89058a8c46ae2350da9d33ba8', - 'name' => __( 'Video URL', 'video-thumbnails' ) + 'name' => esc_html__( 'Video URL', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/class-youtube-thumbnails.php b/php/providers/class-youtube-thumbnails.php index 255576c..5d18466 100755 --- a/php/providers/class-youtube-thumbnails.php +++ b/php/providers/class-youtube-thumbnails.php @@ -61,29 +61,27 @@ public static function get_test_cases() { 'markup' => '', 'expected' => 'http://img.youtube.com/vi/Fp0U2Vglkjw/maxresdefault.jpg', 'expected_hash' => 'c66256332969c38790c2b9f26f725e7a', - 'name' => __( 'iFrame Embed HD', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed HD', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://img.youtube.com/vi/Fp0U2Vglkjw/maxresdefault.jpg', 'expected_hash' => 'c66256332969c38790c2b9f26f725e7a', - 'name' => __( 'Flash Embed HD', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed HD', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://img.youtube.com/vi/vv_AitYPjtc/0.jpg', 'expected_hash' => '6c00b9ab335a6ea00b0fb964c39a6dc9', - 'name' => __( 'iFrame Embed SD', 'video-thumbnails' ) + 'name' => esc_html__( 'iFrame Embed SD', 'video-thumbnails' ) ), array( 'markup' => '', 'expected' => 'http://img.youtube.com/vi/vv_AitYPjtc/0.jpg', 'expected_hash' => '6c00b9ab335a6ea00b0fb964c39a6dc9', - 'name' => __( 'Flash Embed SD', 'video-thumbnails' ) + 'name' => esc_html__( 'Flash Embed SD', 'video-thumbnails' ) ), ); } } - -?> \ No newline at end of file diff --git a/php/providers/providers.php b/php/providers/providers.php index 1915535..3c0a248 100755 --- a/php/providers/providers.php +++ b/php/providers/providers.php @@ -63,5 +63,3 @@ add_filter( 'video_thumbnail_providers', array( 'Yahooscreen_Thumbnails', 'register_provider' ) ); add_filter( 'video_thumbnail_providers', array( 'Livestream_Thumbnails', 'register_provider' ) ); // add_filter( 'video_thumbnail_providers', array( 'Kaltura_Thumbnails', 'register_provider' ) ); - -?> \ No newline at end of file diff --git a/video-thumbnails.php b/video-thumbnails.php index 6883bb6..3f34ac3 100755 --- a/video-thumbnails.php +++ b/video-thumbnails.php @@ -69,7 +69,7 @@ function __construct() { add_action( 'xmlrpc_publish_post', 'get_video_thumbnail', 10, 1 ); // Add action for Ajax reset script on edit pages - if ( in_array( basename( $_SERVER['PHP_SELF'] ), apply_filters( 'video_thumbnails_editor_pages', array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' ) ) ) ) { + if ( in_array( basename( $_SERVER['PHP_SELF'] ), apply_filters( 'video_thumbnails_editor_pages', array( 'post-new.php', 'page-new.php', 'post.php', 'page.php' ) ), true ) ) { add_action( 'admin_head', array( &$this, 'ajax_reset_script' ) ); } @@ -109,7 +109,7 @@ function admin_menu() { */ function admin_scripts( $hook ) { // Bulk tool page - if ( 'tools_page_video-thumbnails-bulk' == $hook ) { + if ( 'tools_page_video-thumbnails-bulk' === $hook ) { wp_enqueue_script( 'video-thumbnails-bulk-js', plugins_url( '/js/bulk.js' , __FILE__ ), array( 'jquery' ), VIDEO_THUMBNAILS_VERSION ); wp_localize_script( 'video-thumbnails-bulk-js', 'video_thumbnails_bulk_language', array( 'working' => __( 'Working...', 'video-thumbnails' ), @@ -151,28 +151,28 @@ function meta_box() { add_thickbox(); ?> ID ); if ( isset( $custom[VIDEO_THUMBNAILS_FIELD][0] ) ) $video_thumbnail = $custom[VIDEO_THUMBNAILS_FIELD][0]; - if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) { - echo '

'; } + if ( isset( $video_thumbnail ) && '' !== $video_thumbnail ) { + echo '

'; } - if ( get_post_status() == 'publish' || get_post_status() == 'private' ) { - if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) { - echo '

' . __( 'Reset Video Thumbnail', 'video-thumbnails' ) . '

'; + if ( get_post_status() === 'publish' || get_post_status() === 'private' ) { + if ( isset( $video_thumbnail ) && '' !== $video_thumbnail ) { + echo '

' . esc_html__( 'Reset Video Thumbnail', 'video-thumbnails' ) . '

'; } else { - echo '

' . __( 'No video thumbnail for this post.', 'video-thumbnails' ) . '

'; - echo '

' . __( 'Search Again', 'video-thumbnails' ) . ' ' . __( 'Troubleshoot', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'No video thumbnail for this post.', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'Search Again', 'video-thumbnails' ) . ' ' . esc_html__( 'Troubleshoot', 'video-thumbnails' ) . '

'; } } else { - if ( isset( $video_thumbnail ) && $video_thumbnail != '' ) { - echo '

' . __( 'Reset Video Thumbnail', 'video-thumbnails' ) . '

'; + if ( isset( $video_thumbnail ) && '' !== $video_thumbnail ) { + echo '

' . esc_html__( 'Reset Video Thumbnail', 'video-thumbnails' ) . '

'; } else { - echo '

' . __( 'A video thumbnail will be found for this post when it is published.', 'video-thumbnails' ) . '

'; + echo '

' . esc_html__( 'A video thumbnail will be found for this post when it is published.', 'video-thumbnails' ) . '

'; } } } @@ -182,13 +182,13 @@ function meta_box() { */ public static function no_video_thumbnail_troubleshooting_instructions() { ?> -

+

    -
  1. +
  2. settings page. If you don\'t know the name of the field your video is being saved in, please contact the developer of that theme or plugin.', 'video-thumbnails' ), admin_url( 'options-general.php?page=video_thumbnails' ) ); ?>
  3. Debugging page. If this doesn\'t find the thumbnail, you\'ll want to be sure to include the embed code you scanned when you request support. If it does find a thumbnail, please double check that you have the Custom Field set correctly in the settings page if you are using a a plugin or theme that stores videos in a special location.', 'video-thumbnails' ), admin_url( 'options-general.php?page=video_thumbnails&tab=debugging' ), admin_url( 'options-general.php?page=video_thumbnails' ) ); ?>
  4. Debugging page and click "Test Image Downloading" to test your server\'s ability to save an image from a video source.', 'video-thumbnails' ), admin_url( 'options-general.php?page=video_thumbnails&tab=debugging' ) ); ?>
  5. -
  6. +
  7. support threads to see if anyone has had the same issue.', 'video-thumbnails' ); ?>
  8. start a thread with a good descriptive title ("Error" or "No thumbnails" is a bad title) and be sure to include the results of your testing as well. Also be sure to include the name of your theme, any video plugins you\'re using, and any other details you can think of.', 'video-thumbnails' ); ?>
@@ -246,7 +246,7 @@ function get_first_thumbnail_url( $markup ) { $videos = $this->find_videos( $markup ); foreach ( $videos as $video ) { $thumbnail = $this->providers[$video['provider']]->get_thumbnail_url( $video['id'] ); - if ( $thumbnail != null ) break; + if ( null !== $thumbnail ) break; } return $thumbnail; } @@ -259,10 +259,10 @@ function get_first_thumbnail_url( $markup ) { function get_video_thumbnail( $post_id = null ) { // Get the post ID if none is provided - if ( $post_id == null OR $post_id == '' ) $post_id = get_the_ID(); + if ( null === $post_id || '' ===$post_id ) $post_id = get_the_ID(); // Check to see if thumbnail has already been found - if( ( $thumbnail_meta = get_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, true ) ) != '' ) { + if( ( $thumbnail_meta = get_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, true ) ) !== '' ) { return $thumbnail_meta; } // If the thumbnail isn't stored in custom meta, fetch a thumbnail @@ -272,7 +272,7 @@ function get_video_thumbnail( $post_id = null ) { // Filter for extensions to set thumbnail $new_thumbnail = apply_filters( 'new_video_thumbnail_url', $new_thumbnail, $post_id ); - if ( $new_thumbnail == null ) { + if ( null === $new_thumbnail ) { // Get the post or custom field to search if ( $this->settings->options['custom_field'] ) { $markup = get_post_meta( $post_id, $this->settings->options['custom_field'], true ); @@ -289,10 +289,10 @@ function get_video_thumbnail( $post_id = null ) { } // Return the new thumbnail variable and update meta if one is found - if ( $new_thumbnail != null && !is_wp_error( $new_thumbnail ) ) { + if ( null !== $new_thumbnail && ! is_wp_error( $new_thumbnail ) ) { // Save as Attachment if enabled - if ( $this->settings->options['save_media'] == 1 ) { + if ( 1 === $this->settings->options['save_media'] ) { $attachment_id = $this->save_to_media_library( $new_thumbnail, $post_id ); if ( is_wp_error( $attachment_id ) ) { return $attachment_id; @@ -305,7 +305,7 @@ function get_video_thumbnail( $post_id = null ) { if ( !update_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail ) ) add_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, $new_thumbnail, true ); // Set attachment as featured image if enabled - if ( $this->settings->options['set_featured'] == 1 && $this->settings->options['save_media'] == 1 ) { + if ( 1 === $this->settings->options['set_featured'] && 1 === $this->settings->options['save_media'] ) { // Make sure there isn't already a post thumbnail if ( !ctype_digit( get_post_thumbnail_id( $post_id ) ) ) { set_post_thumbnail( $post_id, $attachment_id ); @@ -320,15 +320,18 @@ function get_video_thumbnail( $post_id = null ) { /** * Gets a video thumbnail when a published post is saved + * * @param int $post_id The post ID + * + * @return null */ function save_video_thumbnail( $post_id ) { // Don't save video thumbnails during autosave or for unpublished posts if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return null; - if ( get_post_status( $post_id ) != 'publish' ) return null; + if ( get_post_status( $post_id ) !== 'publish' ) return null; // Check that Video Thumbnails are enabled for current post type $post_type = get_post_type( $post_id ); - if ( in_array( $post_type, (array) $this->settings->options['post_types'] ) || $post_type == $this->settings->options['post_types'] ) { + if ( in_array( $post_type, (array) $this->settings->options['post_types'], true ) || $post_type === $this->settings->options['post_types'] ) { $this->get_video_thumbnail( $post_id ); } else { return null; @@ -348,7 +351,7 @@ static function construct_filename( $post_id ) { $filename = preg_replace( '/[^a-zA-Z0-9\-]/', '', $filename ); $filename = substr( $filename, 0, 32 ); $filename = trim( $filename, '-' ); - if ( $filename == '' ) $filename = (string) $post_id; + if ( '' === $filename ) $filename = (string) $post_id; return $filename; } @@ -356,7 +359,7 @@ static function construct_filename( $post_id ) { * Saves a remote image to the media library * @param string $image_url URL of the image to save * @param int $post_id ID of the post to attach image to - * @return int ID of the attachment + * @return int|WP_Error ID of the attachment */ public static function save_to_media_library( $image_url, $post_id ) { @@ -369,19 +372,19 @@ public static function save_to_media_library( $image_url, $post_id ) { $image_type = wp_remote_retrieve_header( $response, 'content-type' ); } - if ( $error != '' ) { + if ( '' !== $error ) { return $error; } else { // Translate MIME type into an extension - if ( $image_type == 'image/jpeg' ) { + if ( 'image/jpeg' === $image_type ) { $image_extension = '.jpg'; - } elseif ( $image_type == 'image/png' ) { + } elseif ( 'image/png' === $image_type ) { $image_extension = '.png'; - } elseif ( $image_type == 'image/gif' ) { + } elseif ( 'image/gif' === $image_type ) { $image_extension = '.gif'; } else { - return new WP_Error( 'thumbnail_upload', __( 'Unsupported MIME type:', 'video-thumbnails' ) . ' ' . $image_type ); + return new WP_Error( 'thumbnail_upload', esc_html__( 'Unsupported MIME type:', 'video-thumbnails' ) . ' ' . $image_type ); } // Construct a file name with extension @@ -462,7 +465,7 @@ function ajax_reset_script() { function ajax_reset_callback() { global $wpdb; // this is how you get access to the database - $post_id = $_POST['post_id']; + $post_id = (int) $_POST['post_id']; delete_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD ); @@ -470,10 +473,10 @@ function ajax_reset_callback() { if ( is_wp_error( $video_thumbnail ) ) { echo $video_thumbnail->get_error_message(); - } else if ( $video_thumbnail != null ) { - echo ''; + } else if ( null !== $video_thumbnail ) { + echo ''; } else { - echo __( 'No video thumbnail for this post.', 'video-thumbnails' ); + echo esc_html__( 'No video thumbnail for this post.', 'video-thumbnails' ); } die(); @@ -496,7 +499,7 @@ function bulk_posts_query_callback() { $args = apply_filters( 'video_thumbnails/bulk_posts_query', $args, $form_data ); $query = new WP_Query( $args ); - echo json_encode( $query->posts ); + echo wp_json_encode( $query->posts ); die(); } @@ -505,10 +508,10 @@ function bulk_posts_query_callback() { */ function get_thumbnail_for_post_callback() { - $post_id = $_POST['post_id']; + $post_id = (int) $_POST['post_id']; $thumb = get_post_meta( $post_id, VIDEO_THUMBNAILS_FIELD, true ); - if ( $thumb == '' ) { + if ( '' === $thumb ) { global $video_thumbnails; $thumb = $video_thumbnails->get_video_thumbnail( $post_id ); if ( $thumb ) { @@ -518,7 +521,7 @@ function get_thumbnail_for_post_callback() { $type = 'existing'; } - if ( $thumb != '' ) { + if ( '' !== $thumb ) { $result = array( 'type' => $type, 'url' => $thumb @@ -527,7 +530,7 @@ function get_thumbnail_for_post_callback() { $result = array(); } - echo json_encode( $result ); + echo wp_json_encode( $result ); die(); } @@ -537,15 +540,15 @@ function get_thumbnail_for_post_callback() { function bulk_scanning_page() { if ( ! current_user_can( 'manage_options' ) ) { - wp_die( __( 'You do not have sufficient permissions to access this page.', 'video-thumbnails' ) ); + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'video-thumbnails' ) ); } ?>
-

+

-

+

' . $test_case['name'] . '' . esc_html( $test_case['name'] ) . '✗ ' . __( 'Failed', 'video-thumbnails' ) . '✗ ' . esc_html__( 'Failed', 'video-thumbnails' ) . ''; - echo '

' . $error_string . '

'; + echo '

' . esc_html( $error_string ) . '

'; echo '
✔ ' . __( 'Passed', 'video-thumbnails' ) . '✔ ' . esc_html__( 'Passed', 'video-thumbnails' ) . '✗ ' . __( 'Failed', 'video-thumbnails' ) . '✗ ' . esc_html__( 'Failed', 'video-thumbnails' ) . ''; if ( $result ) { - echo '' . __( 'View Image', 'video-thumbnails' ) . ''; + echo '' . esc_html__( 'View Image', 'video-thumbnails' ) . ''; } if ( $result_hash ) { - echo ' ' . $result_hash . ''; + echo ' ' . esc_html( $result_hash ) . ''; } echo '
options['version']; ?>options['version'] ); ?>
More info', 'video-thumbnails' ); ?> More info', 'video-thumbnails' ); ?>
providers as $provider ) { $provider_names[] = $provider->service_name; }; ?> - providers ); ?>: + providers ); ?>:
@@ -569,9 +572,9 @@ function bulk_scanning_page() {
- - - + + + @@ -604,8 +607,6 @@ function get_video_thumbnail( $post_id = null ) { // Echo thumbnail function video_thumbnail( $post_id = null ) { - if ( ( $video_thumbnail = get_video_thumbnail( $post_id ) ) == null ) { echo plugins_url() . '/video-thumbnails/default.jpg'; } + if ( ( $video_thumbnail = get_video_thumbnail( $post_id ) ) === null ) { echo esc_url( plugins_url() ) . '/video-thumbnails/default.jpg'; } else { echo $video_thumbnail; } } - -?> \ No newline at end of file