Changeset 2711798
- Timestamp:
- 04/20/2022 01:05:31 AM (4 years ago)
- Location:
- wp-youtube-live
- Files:
-
- 8 edited
- 1 copied
-
assets/banner-1544x500.png (modified) (previous)
-
assets/banner-772x250.png (modified) (previous)
-
assets/icon-128x128.png (modified) (previous)
-
assets/icon-256x256.png (modified) (previous)
-
tags/1.8.1 (copied) (copied from wp-youtube-live/trunk)
-
tags/1.8.1/inc/admin.php (modified) (3 diffs)
-
tags/1.8.1/wp-youtube-live.php (modified) (9 diffs)
-
trunk/inc/admin.php (modified) (3 diffs)
-
trunk/wp-youtube-live.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-youtube-live/tags/1.8.1/inc/admin.php
r2709508 r2711798 340 340 * @param string $action action to perform. 341 341 * @param string $nonce security nonce. 342 * @return string JSON string of upcoming videos342 * @return string|void JSON string of upcoming videos 343 343 */ 344 344 function refresh_youtube_live_upcoming_cache( $action = null, $nonce = null ) { … … 363 363 $output = wp_json_encode( format_upcoming_videos( get_transient( 'youtube-live-upcoming-videos' ) ) ); 364 364 if ( $_POST ) { 365 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped365 echo wp_kses_post( $output ); 366 366 die(); 367 367 } else { … … 385 385 386 386 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. 388 388 $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";', 391 390 '_transient_timeout_youtube-live-upcoming-videos' 392 391 ), -
wp-youtube-live/tags/1.8.1/wp-youtube-live.php
r2709508 r2711798 4 4 * Plugin URI: https://github.com/macbookandrew/wp-youtube-live 5 5 * Description: Displays the current YouTube live video from a specified channel 6 * Version: 1.8. 06 * Version: 1.8.1 7 7 * Author: Andrew Minion 8 8 * Author URI: https://andrewrminion.com/ … … 13 13 } 14 14 15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8. 0' );15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.1' ); 16 16 17 17 /** … … 26 26 wp_register_script( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'js/wp-youtube-live.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true ); 27 27 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. 29 29 } 30 30 add_action( 'wp_enqueue_scripts', 'youtube_live_scripts' ); … … 105 105 106 106 // 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. 107 108 $youtube_live = new EmbedYoutubeLiveStreaming( esc_attr( $youtube_options['youtube_live_channel_id'] ), esc_attr( $youtube_options['youtube_live_api_key'] ) ); 108 109 $youtube_live->subdomain = $youtube_options['subdomain'] 109 110 ? esc_attr( $youtube_options['subdomain'] ) 110 111 : '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.InputNotValidated112 $youtube_live->embed_width = wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST ) 113 ? sanitize_key( wp_unslash( $_POST['width'] ) ) 113 114 : 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.InputNotValidated115 $youtube_live->embed_height = wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) 116 ? sanitize_key( wp_unslash( $_POST['height'] ) ) 116 117 : 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.InputNotValidated118 $youtube_live->embed_autoplay = wp_youtube_live_is_ajax() && array_key_exists( 'autoplay', $_POST ) 119 ? sanitize_key( wp_unslash( $_POST['autoplay'] ) ) 119 120 : 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.InputNotValidated121 $youtube_live->show_related = wp_youtube_live_is_ajax() && array_key_exists( 'show_related', $_POST ) 122 ? sanitize_key( wp_unslash( $_POST['show_related'] ) ) 122 123 : 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.Missing124 ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated124 $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST ) 125 ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) ) 125 126 : ''; 127 // phpcs:enable WordPress.Security.NonceVerification.Missing 126 128 127 129 if ( strlen( $youtube_live->completed_video_id ) > 0 ) { … … 184 186 <li><strong>Extended help:</strong> ' . wp_kses_post( $error['extendedHelp'] ) . '</li>'; 185 187 } 186 if ( $youtube_options['fallback_behavior'] === 'video'&& empty( $youtube_options['fallback_video'] ) ) {188 if ( 'video' === $youtube_options['fallback_behavior'] && empty( $youtube_options['fallback_video'] ) ) { 187 189 $error_message .= '<li>Please double-check that you have set a fallback video.</li>'; 188 190 } … … 193 195 // debugging. 194 196 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. 197 199 $json_data['error'] . $debugging_code; 198 200 } … … 236 238 * Set default oembed size for video/playlist fallback behavior 237 239 * 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 240 243 */ 241 244 function wp_ytl_set_embed_size( $size ) { 242 245 $request_options = get_option( 'youtube_live_settings' ); 243 246 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'] ) ) 246 250 : $request_options['default_width'] ); 247 $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing248 ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing251 $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) 252 ? sanitize_key( wp_unslash( $_POST['height'] ) ) 249 253 : $request_options['default_height'] ); 254 // phpcs:enable WordPress.Security.NonceVerification.Missing 250 255 251 256 return $size; … … 288 293 289 294 // 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'] ) { 291 296 $request_options['fallback_behavior'] = 'channel'; 292 297 } … … 343 348 */ 344 349 function 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. 346 351 } 347 352 -
wp-youtube-live/trunk/inc/admin.php
r2709508 r2711798 340 340 * @param string $action action to perform. 341 341 * @param string $nonce security nonce. 342 * @return string JSON string of upcoming videos342 * @return string|void JSON string of upcoming videos 343 343 */ 344 344 function refresh_youtube_live_upcoming_cache( $action = null, $nonce = null ) { … … 363 363 $output = wp_json_encode( format_upcoming_videos( get_transient( 'youtube-live-upcoming-videos' ) ) ); 364 364 if ( $_POST ) { 365 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped365 echo wp_kses_post( $output ); 366 366 die(); 367 367 } else { … … 385 385 386 386 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. 388 388 $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";', 391 390 '_transient_timeout_youtube-live-upcoming-videos' 392 391 ), -
wp-youtube-live/trunk/wp-youtube-live.php
r2709508 r2711798 4 4 * Plugin URI: https://github.com/macbookandrew/wp-youtube-live 5 5 * Description: Displays the current YouTube live video from a specified channel 6 * Version: 1.8. 06 * Version: 1.8.1 7 7 * Author: Andrew Minion 8 8 * Author URI: https://andrewrminion.com/ … … 13 13 } 14 14 15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8. 0' );15 define( 'WP_YOUTUBE_LIVE_VERSION', '1.8.1' ); 16 16 17 17 /** … … 26 26 wp_register_script( 'wp-youtube-live', plugin_dir_url( __FILE__ ) . 'js/wp-youtube-live.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true ); 27 27 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. 29 29 } 30 30 add_action( 'wp_enqueue_scripts', 'youtube_live_scripts' ); … … 105 105 106 106 // 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. 107 108 $youtube_live = new EmbedYoutubeLiveStreaming( esc_attr( $youtube_options['youtube_live_channel_id'] ), esc_attr( $youtube_options['youtube_live_api_key'] ) ); 108 109 $youtube_live->subdomain = $youtube_options['subdomain'] 109 110 ? esc_attr( $youtube_options['subdomain'] ) 110 111 : '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.InputNotValidated112 $youtube_live->embed_width = wp_youtube_live_is_ajax() && array_key_exists( 'width', $_POST ) 113 ? sanitize_key( wp_unslash( $_POST['width'] ) ) 113 114 : 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.InputNotValidated115 $youtube_live->embed_height = wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) 116 ? sanitize_key( wp_unslash( $_POST['height'] ) ) 116 117 : 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.InputNotValidated118 $youtube_live->embed_autoplay = wp_youtube_live_is_ajax() && array_key_exists( 'autoplay', $_POST ) 119 ? sanitize_key( wp_unslash( $_POST['autoplay'] ) ) 119 120 : 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.InputNotValidated121 $youtube_live->show_related = wp_youtube_live_is_ajax() && array_key_exists( 'show_related', $_POST ) 122 ? sanitize_key( wp_unslash( $_POST['show_related'] ) ) 122 123 : 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.Missing124 ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated124 $youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST ) 125 ? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) ) 125 126 : ''; 127 // phpcs:enable WordPress.Security.NonceVerification.Missing 126 128 127 129 if ( strlen( $youtube_live->completed_video_id ) > 0 ) { … … 184 186 <li><strong>Extended help:</strong> ' . wp_kses_post( $error['extendedHelp'] ) . '</li>'; 185 187 } 186 if ( $youtube_options['fallback_behavior'] === 'video'&& empty( $youtube_options['fallback_video'] ) ) {188 if ( 'video' === $youtube_options['fallback_behavior'] && empty( $youtube_options['fallback_video'] ) ) { 187 189 $error_message .= '<li>Please double-check that you have set a fallback video.</li>'; 188 190 } … … 193 195 // debugging. 194 196 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. 197 199 $json_data['error'] . $debugging_code; 198 200 } … … 236 238 * Set default oembed size for video/playlist fallback behavior 237 239 * 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 240 243 */ 241 244 function wp_ytl_set_embed_size( $size ) { 242 245 $request_options = get_option( 'youtube_live_settings' ); 243 246 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'] ) ) 246 250 : $request_options['default_width'] ); 247 $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) // phpcs:ignore WordPress.Security.NonceVerification.Missing248 ? sanitize_key( wp_unslash( $_POST['height'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing251 $size['height'] = ( wp_youtube_live_is_ajax() && array_key_exists( 'height', $_POST ) 252 ? sanitize_key( wp_unslash( $_POST['height'] ) ) 249 253 : $request_options['default_height'] ); 254 // phpcs:enable WordPress.Security.NonceVerification.Missing 250 255 251 256 return $size; … … 288 293 289 294 // 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'] ) { 291 296 $request_options['fallback_behavior'] = 'channel'; 292 297 } … … 343 348 */ 344 349 function 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. 346 351 } 347 352
Note: See TracChangeset
for help on using the changeset viewer.