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() {| - | - | + | + | + | |||||
|---|---|---|---|---|---|---|---|---|---|
| ' . $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 ' ' . $error_string . ' ' . esc_html( $error_string ) . ' | ';
$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 '