';
- echo '| ' . $test_case['name'] . ' | ';
+ echo '' . esc_html( $test_case['name'] ) . ' | ';
$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 '✗ ' . __( 'Failed', 'video-thumbnails' ) . ' | ';
+ echo '✗ ' . esc_html__( 'Failed', 'video-thumbnails' ) . ' | ';
echo '';
- echo '';
+ echo '' . esc_html( $error_string ) . ' ';
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 '✔ ' . __( 'Passed', 'video-thumbnails' ) . ' | ';
+ echo '✔ ' . esc_html__( 'Passed', 'video-thumbnails' ) . ' | ';
} else {
- echo '✗ ' . __( 'Failed', 'video-thumbnails' ) . ' | ';
+ echo '✗ ' . esc_html__( 'Failed', 'video-thumbnails' ) . ' | ';
}
echo '';
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 ' | ';
}
@@ -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 ( $new_thumbnail === null ) {
// 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() . '
';
+ 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 ( $remote_response['response']['code'] != '200' ) {
// 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__( 'Custom Field (optional)', 'video-thumbnails' ),
+ '' . esc_html__( 'Automatically Detect', 'video-thumbnails' ) . ' ' . __( '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' ) );
}
@@ -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' ); ?>
@@ -542,17 +543,17 @@ function options_page() {
// Scan all posts
if ( $active_tab == 'mass_actions' ) {
?>
-
+
-
+
-
+
-
+
-
+
-
+
@@ -563,25 +564,25 @@ function options_page() {
if ( $active_tab == 'debugging' ) {
?>
-
+
-
+
-
+
-
+
providers as $provider ) {
- echo '
';
- echo '
' . $provider->service_name . '
';
+ echo '
';
+ echo '
' . esc_html( $provider->service_name ) . '
';
echo '
';
echo '
';
}
@@ -593,13 +594,13 @@ function options_page() {
-
+
-
+
-
+
@@ -612,13 +613,13 @@ function options_page() {
-
+
-
+
-
+
change file permissions.', 'video-thumbnails' ); ?>
@@ -634,9 +635,9 @@ function options_page() {
-
+
-
+
@@ -650,36 +651,36 @@ function options_page() {
- |
- |
+ |
+ |
|
- |
- |
+ |
+ |
|
- |
- options['version']; ?> |
+ |
+ options['version'] ); ?> |
|
- |
- |
+ |
+ |
|
- |
- ✔ ✖ More info', 'video-thumbnails' ); ?> |
+ |
+ ✔ ✖ More info', 'video-thumbnails' ); ?> |
|
- |
+ |
providers as $provider ) { $provider_names[] = $provider->service_name; }; ?>
- providers ); ?>:
+ providers ); ?>:
|
|
@@ -718,8 +719,8 @@ public static function settings_footer() {
?>
Date: Wed, 17 May 2017 02:44:20 -0300
Subject: [PATCH 4/8] Fixing more PHPCS issues
---
php/class-video-thumbnails-settings.php | 20 +++++++++----------
.../automatic-youtube-video-posts.php | 2 --
php/extensions/extensions.php | 2 --
php/extensions/simple-video-embedder.php | 2 --
php/extensions/wp-robot.php | 2 --
php/providers/class-blip-thumbnails.php | 2 --
.../class-collegehumor-thumbnails.php | 2 --
.../class-dailymotion-thumbnails.php | 2 --
php/providers/class-facebook-thumbnails.php | 2 --
php/providers/class-funnyordie-thumbnails.php | 2 --
.../class-googledrive-thumbnails.php | 2 --
php/providers/class-kaltura-thumbnails.php | 2 --
php/providers/class-livestream-thumbnails.php | 2 --
php/providers/class-metacafe-thumbnails.php | 2 --
php/providers/class-mpora-thumbnails.php | 2 --
php/providers/class-rutube-thumbnails.php | 2 --
php/providers/class-sapo-thumbnails.php | 2 --
php/providers/class-ted-thumbnails.php | 2 --
php/providers/class-tudou-thumbnails.php | 2 --
php/providers/class-twitch-thumbnails.php | 2 --
.../class-video-thumbnails-provider.php | 2 --
php/providers/class-vimeo-thumbnails.php | 2 --
php/providers/class-vine-thumbnails.php | 2 --
php/providers/class-vk-thumbnails.php | 2 --
php/providers/class-wistia-thumbnails.php | 2 --
.../class-yahooscreen-thumbnails.php | 2 --
php/providers/class-youku-thumbnails.php | 2 --
php/providers/class-youtube-thumbnails.php | 2 --
php/providers/providers.php | 2 --
video-thumbnails.php | 2 --
30 files changed, 9 insertions(+), 69 deletions(-)
diff --git a/php/class-video-thumbnails-settings.php b/php/class-video-thumbnails-settings.php
index f6d62c4..3583870 100755
--- a/php/class-video-thumbnails-settings.php
+++ b/php/class-video-thumbnails-settings.php
@@ -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' );
@@ -330,7 +330,7 @@ function markup_detection_test_callback() {
$new_thumbnail = $video_thumbnails->get_first_thumbnail_url( $markup );
- if ( $new_thumbnail === null ) {
+ if ( null === $new_thumbnail ) {
// No thumbnail
echo '✖ ' . esc_html__( 'No thumbnail found', 'video-thumbnails' ) . '
';
} elseif ( is_wp_error( $new_thumbnail ) ) {
@@ -343,7 +343,7 @@ function markup_detection_test_callback() {
// WP Error trying to read image from remote server
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 ( $remote_response['response']['code'] != '200' ) {
+ } elseif ( '200' !== $remote_response['response']['code'] ) {
// Response code isn't okay
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 ) . '';
@@ -397,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];
@@ -509,7 +509,7 @@ function options_page() {
@@ -527,7 +527,7 @@ function options_page() {
// End main settings
}
// Provider Settings
- if ( $active_tab == 'provider_settings' ) {
+ if ( 'provider_settings' === $active_tab ) {
?>