Plugin Directory

Changeset 2711798


Ignore:
Timestamp:
04/20/2022 01:05:31 AM (4 years ago)
Author:
macbookandrew
Message:

Update to version 1.8.1 from GitHub

Location:
wp-youtube-live
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-youtube-live/tags/1.8.1/inc/admin.php

    r2709508 r2711798  
    340340 * @param string $action action to perform.
    341341 * @param string $nonce  security nonce.
    342  * @return string JSON string of upcoming videos
     342 * @return string|void JSON string of upcoming videos
    343343 */
    344344function refresh_youtube_live_upcoming_cache( $action = null, $nonce = null ) {
     
    363363            $output = wp_json_encode( format_upcoming_videos( get_transient( 'youtube-live-upcoming-videos' ) ) );
    364364            if ( $_POST ) {
    365                 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     365                echo wp_kses_post( $output );
    366366                die();
    367367            } else {
     
    385385
    386386    global $wpdb;
    387     $transient_expire_time = $wpdb->get_col(
     387    $transient_expire_time = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- no functions exist to get the transient expiration time, and caching would defeat the purpose of determining the expiration time.
    388388        $wpdb->prepare(
    389             'SELECT option_value FROM %1$soptions WHERE option_name = "%2$s";',
    390             $wpdb->prefix,
     389            'SELECT option_value FROM ' . $wpdb->options . ' WHERE option_name = "%1$s";',
    391390            '_transient_timeout_youtube-live-upcoming-videos'
    392391        ),
  • wp-youtube-live/tags/1.8.1/wp-youtube-live.php

    r2709508 r2711798  
    44 * Plugin URI: https://github.com/macbookandrew/wp-youtube-live
    55 * Description: Displays the current YouTube live video from a specified channel
    6  * Version: 1.8.0
     6 * Version: 1.8.1
    77 * Author: Andrew Minion
    88 * Author URI: https://andrewrminion.com/
     
    1313}
    1414
    15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.0' );
     15define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.1' );
    1616
    1717/**
     
    2626    wp_register_script( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'js/wp-youtube-live.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true );
    2727    wp_register_style( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'css/wp-youtube-live.css', array(), WP_YOUTUBE_LIVE_VERSION );
    28     wp_register_script( 'youtube-iframe-api', 'https://www.youtube.com/iframe_api', array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
     28    wp_register_script( 'youtube-iframe-api', 'https://www.youtube.com/iframe_api', array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- because it’s a third-party script that we can’t version.
    2929}
    3030add_action( 'wp_enqueue_scripts', 'youtube_live_scripts' );
     
    105105
    106106    // set up player.
     107    // phpcs:disable WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
    107108    $youtube_live                     = new EmbedYoutubeLiveStreaming( esc_attr( $youtube_options['youtube_live_channel_id'] ), esc_attr( $youtube_options['youtube_live_api_key'] ) );
    108109    $youtube_live->subdomain          = $youtube_options['subdomain']
    109110        ? esc_attr( $youtube_options['subdomain'] )
    110111        : 'www';
    111     $youtube_live->embed_width        = wp_youtube_live_is_ajax()
    112         ? sanitize_key( wp_unslash( $_POST['width'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     112    $youtube_live->embed_width        = wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST )
     113        ? sanitize_key( wp_unslash( $_POST['width'] ) )
    113114        : sanitize_key( $request_options['width'] );
    114     $youtube_live->embed_height       = wp_youtube_live_is_ajax()
    115         ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     115    $youtube_live->embed_height       = wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST )
     116        ? sanitize_key( wp_unslash( $_POST['height'] ) )
    116117        : sanitize_key( $request_options['height'] );
    117     $youtube_live->embed_autoplay     = wp_youtube_live_is_ajax()
    118         ? sanitize_key( wp_unslash( $_POST['autoplay'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     118    $youtube_live->embed_autoplay     = wp_youtube_live_is_ajax() && array_key_exists( 'autoplay', $_POST )
     119        ? sanitize_key( wp_unslash( $_POST['autoplay'] ) )
    119120        : sanitize_key( $request_options['autoplay'] );
    120     $youtube_live->show_related       = wp_youtube_live_is_ajax()
    121         ? sanitize_key( wp_unslash( $_POST['show_related'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     121    $youtube_live->show_related       = wp_youtube_live_is_ajax() && array_key_exists( 'show_related', $_POST )
     122        ? sanitize_key( wp_unslash( $_POST['show_related'] ) )
    122123        : sanitize_key( $request_options['showRelated'] );
    123     $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    124         ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) )  // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     124    $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST )
     125        ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) )
    125126        : '';
     127    // phpcs:enable WordPress.Security.NonceVerification.Missing
    126128
    127129    if ( strlen( $youtube_live->completed_video_id ) > 0 ) {
     
    184186            <li><strong>Extended help:</strong> ' . wp_kses_post( $error['extendedHelp'] ) . '</li>';
    185187        }
    186         if ( $youtube_options['fallback_behavior'] === 'video' && empty( $youtube_options['fallback_video'] ) ) {
     188        if ( 'video' === $youtube_options['fallback_behavior'] && empty( $youtube_options['fallback_video'] ) ) {
    187189            $error_message .= '<li>Please double-check that you have set a fallback video.</li>';
    188190        }
     
    193195    // debugging.
    194196    if ( get_option( 'youtube_live_settings', 'debugging' ) && is_user_logged_in() ) {
    195         $debugging_code = var_export( $youtube_live, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    196         echo '<!-- YouTube Live debugging: ' . "\n" . $debugging_code . "\n" . ' -->'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     197        $debugging_code = var_export( $youtube_live, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export -- because this is only available for admins if they enable the debug option.
     198        echo '<!-- YouTube Live debugging: ' . "\n" . $debugging_code . "\n" . ' -->'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- because this is only available for admins if they enable the debug option.
    197199        $json_data['error'] . $debugging_code;
    198200    }
     
    236238 * Set default oembed size for video/playlist fallback behavior
    237239 *
    238  * @param  array $size default oembed sizes
    239  * @return array moified oembed size
     240 * @param  array $size Default oembed sizes.
     241 *
     242 * @return array Modified oembed size
    240243 */
    241244function wp_ytl_set_embed_size( $size ) {
    242245    $request_options = get_option( 'youtube_live_settings' );
    243246
    244     $size['width']  = ( wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    245         ? sanitize_key( wp_unslash( $_POST['width'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
     247    // phpcs:disable WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
     248    $size['width']  = ( wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST )
     249        ? sanitize_key( wp_unslash( $_POST['width'] ) )
    246250        : $request_options['default_width'] );
    247     $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    248         ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
     251    $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST )
     252        ? sanitize_key( wp_unslash( $_POST['height'] ) )
    249253        : $request_options['default_height'] );
     254    // phpcs:enable WordPress.Security.NonceVerification.Missing
    250255
    251256    return $size;
     
    288293
    289294    // removed in v1.7.0.
    290     if ( array_key_exists( 'show_channel_if_dead', $request_options ) && 'true' == $request_options['show_channel_if_dead'] ) {
     295    if ( array_key_exists( 'show_channel_if_dead', $request_options ) && 'true' === $request_options['show_channel_if_dead'] ) {
    291296        $request_options['fallback_behavior'] = 'channel';
    292297    }
     
    343348 */
    344349function wp_youtube_live_is_ajax() {
    345     return isset( $_POST['isAjax'] ) && (bool) sanitize_key( wp_unslash( $_POST['isAjax'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
     350    return isset( $_POST['isAjax'] ) && (bool) sanitize_key( wp_unslash( $_POST['isAjax'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
    346351}
    347352
  • wp-youtube-live/trunk/inc/admin.php

    r2709508 r2711798  
    340340 * @param string $action action to perform.
    341341 * @param string $nonce  security nonce.
    342  * @return string JSON string of upcoming videos
     342 * @return string|void JSON string of upcoming videos
    343343 */
    344344function refresh_youtube_live_upcoming_cache( $action = null, $nonce = null ) {
     
    363363            $output = wp_json_encode( format_upcoming_videos( get_transient( 'youtube-live-upcoming-videos' ) ) );
    364364            if ( $_POST ) {
    365                 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     365                echo wp_kses_post( $output );
    366366                die();
    367367            } else {
     
    385385
    386386    global $wpdb;
    387     $transient_expire_time = $wpdb->get_col(
     387    $transient_expire_time = $wpdb->get_col( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- no functions exist to get the transient expiration time, and caching would defeat the purpose of determining the expiration time.
    388388        $wpdb->prepare(
    389             'SELECT option_value FROM %1$soptions WHERE option_name = "%2$s";',
    390             $wpdb->prefix,
     389            'SELECT option_value FROM ' . $wpdb->options . ' WHERE option_name = "%1$s";',
    391390            '_transient_timeout_youtube-live-upcoming-videos'
    392391        ),
  • wp-youtube-live/trunk/wp-youtube-live.php

    r2709508 r2711798  
    44 * Plugin URI: https://github.com/macbookandrew/wp-youtube-live
    55 * Description: Displays the current YouTube live video from a specified channel
    6  * Version: 1.8.0
     6 * Version: 1.8.1
    77 * Author: Andrew Minion
    88 * Author URI: https://andrewrminion.com/
     
    1313}
    1414
    15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.0' );
     15define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.1' );
    1616
    1717/**
     
    2626    wp_register_script( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'js/wp-youtube-live.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true );
    2727    wp_register_style( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'css/wp-youtube-live.css', array(), WP_YOUTUBE_LIVE_VERSION );
    28     wp_register_script( 'youtube-iframe-api', 'https://www.youtube.com/iframe_api', array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
     28    wp_register_script( 'youtube-iframe-api', 'https://www.youtube.com/iframe_api', array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- because it’s a third-party script that we can’t version.
    2929}
    3030add_action( 'wp_enqueue_scripts', 'youtube_live_scripts' );
     
    105105
    106106    // set up player.
     107    // phpcs:disable WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
    107108    $youtube_live                     = new EmbedYoutubeLiveStreaming( esc_attr( $youtube_options['youtube_live_channel_id'] ), esc_attr( $youtube_options['youtube_live_api_key'] ) );
    108109    $youtube_live->subdomain          = $youtube_options['subdomain']
    109110        ? esc_attr( $youtube_options['subdomain'] )
    110111        : 'www';
    111     $youtube_live->embed_width        = wp_youtube_live_is_ajax()
    112         ? sanitize_key( wp_unslash( $_POST['width'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     112    $youtube_live->embed_width        = wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST )
     113        ? sanitize_key( wp_unslash( $_POST['width'] ) )
    113114        : sanitize_key( $request_options['width'] );
    114     $youtube_live->embed_height       = wp_youtube_live_is_ajax()
    115         ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     115    $youtube_live->embed_height       = wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST )
     116        ? sanitize_key( wp_unslash( $_POST['height'] ) )
    116117        : sanitize_key( $request_options['height'] );
    117     $youtube_live->embed_autoplay     = wp_youtube_live_is_ajax()
    118         ? sanitize_key( wp_unslash( $_POST['autoplay'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     118    $youtube_live->embed_autoplay     = wp_youtube_live_is_ajax() && array_key_exists( 'autoplay', $_POST )
     119        ? sanitize_key( wp_unslash( $_POST['autoplay'] ) )
    119120        : sanitize_key( $request_options['autoplay'] );
    120     $youtube_live->show_related       = wp_youtube_live_is_ajax()
    121         ? sanitize_key( wp_unslash( $_POST['show_related'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     121    $youtube_live->show_related       = wp_youtube_live_is_ajax() && array_key_exists( 'show_related', $_POST )
     122        ? sanitize_key( wp_unslash( $_POST['show_related'] ) )
    122123        : sanitize_key( $request_options['showRelated'] );
    123     $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    124         ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) )  // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
     124    $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST )
     125        ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) )
    125126        : '';
     127    // phpcs:enable WordPress.Security.NonceVerification.Missing
    126128
    127129    if ( strlen( $youtube_live->completed_video_id ) > 0 ) {
     
    184186            <li><strong>Extended help:</strong> ' . wp_kses_post( $error['extendedHelp'] ) . '</li>';
    185187        }
    186         if ( $youtube_options['fallback_behavior'] === 'video' && empty( $youtube_options['fallback_video'] ) ) {
     188        if ( 'video' === $youtube_options['fallback_behavior'] && empty( $youtube_options['fallback_video'] ) ) {
    187189            $error_message .= '<li>Please double-check that you have set a fallback video.</li>';
    188190        }
     
    193195    // debugging.
    194196    if ( get_option( 'youtube_live_settings', 'debugging' ) && is_user_logged_in() ) {
    195         $debugging_code = var_export( $youtube_live, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export
    196         echo '<!-- YouTube Live debugging: ' . "\n" . $debugging_code . "\n" . ' -->'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
     197        $debugging_code = var_export( $youtube_live, true ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_var_export -- because this is only available for admins if they enable the debug option.
     198        echo '<!-- YouTube Live debugging: ' . "\n" . $debugging_code . "\n" . ' -->'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- because this is only available for admins if they enable the debug option.
    197199        $json_data['error'] . $debugging_code;
    198200    }
     
    236238 * Set default oembed size for video/playlist fallback behavior
    237239 *
    238  * @param  array $size default oembed sizes
    239  * @return array moified oembed size
     240 * @param  array $size Default oembed sizes.
     241 *
     242 * @return array Modified oembed size
    240243 */
    241244function wp_ytl_set_embed_size( $size ) {
    242245    $request_options = get_option( 'youtube_live_settings' );
    243246
    244     $size['width']  = ( wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    245         ? sanitize_key( wp_unslash( $_POST['width'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
     247    // phpcs:disable WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
     248    $size['width']  = ( wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST )
     249        ? sanitize_key( wp_unslash( $_POST['width'] ) )
    246250        : $request_options['default_width'] );
    247     $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
    248         ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing
     251    $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST )
     252        ? sanitize_key( wp_unslash( $_POST['height'] ) )
    249253        : $request_options['default_height'] );
     254    // phpcs:enable WordPress.Security.NonceVerification.Missing
    250255
    251256    return $size;
     
    288293
    289294    // removed in v1.7.0.
    290     if ( array_key_exists( 'show_channel_if_dead', $request_options ) && 'true' == $request_options['show_channel_if_dead'] ) {
     295    if ( array_key_exists( 'show_channel_if_dead', $request_options ) && 'true' === $request_options['show_channel_if_dead'] ) {
    291296        $request_options['fallback_behavior'] = 'channel';
    292297    }
     
    343348 */
    344349function wp_youtube_live_is_ajax() {
    345     return isset( $_POST['isAjax'] ) && (bool) sanitize_key( wp_unslash( $_POST['isAjax'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
     350    return isset( $_POST['isAjax'] ) && (bool) sanitize_key( wp_unslash( $_POST['isAjax'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- because we have to allow unauthenticated users the ability to check for live videos, as well as handle statically-cached markup that might contain a stale nonce.
    346351}
    347352
Note: See TracChangeset for help on using the changeset viewer.