Skip to content

Commit

Permalink
Merge pull request #21 from macbookandrew/bugfix/undefined-index-errors
Browse files Browse the repository at this point in the history
release 1.8.4
  • Loading branch information
macbookandrew committed Sep 3, 2022
2 parents 19f0fa6 + 68eba92 commit dfc2555
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Tags:** youtube, live, video, embed
**Requires at least:** 3.6
**Tested up to:** 5.9.3
**Stable tag:** 1.8.3
**Stable tag:** 1.8.4
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -180,6 +180,11 @@ Because this plugin helps you use the YouTube service, you should refer to these

## Changelog ##

### 1.8.4 ###

- Fix “undefined index” issue in debug logs
- Fix persistent update notice

### 1.8.3 ###

- Escape admin-visible debug output
Expand Down
6 changes: 2 additions & 4 deletions inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Enqueue backend assets
*/
function youtube_live_backend_assets() {
wp_register_script( 'wp-youtube-live-backend', plugin_dir_url( __FILE__ ) . '../js/wp-youtube-live-backend.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true );
wp_enqueue_script( 'wp-youtube-live-backend', plugin_dir_url( __FILE__ ) . '../js/wp-youtube-live-backend.min.js', array( 'jquery' ), WP_YOUTUBE_LIVE_VERSION, true );
}
add_action( 'admin_enqueue_scripts', 'youtube_live_backend_assets' );

Expand Down Expand Up @@ -126,8 +126,6 @@ function youtube_live_settings_init() {
* Print API Key field
*/
function youtube_live_api_key_render() {
wp_enqueue_script( 'wp-youtube-live-backend' );

$options = get_option( 'youtube_live_settings' ); ?>
<input type="text" name="youtube_live_settings[youtube_live_api_key]" placeholder="AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI" size="45" value="<?php echo esc_attr( $options['youtube_live_api_key'] ); ?>">

Expand Down Expand Up @@ -467,6 +465,6 @@ function wp_youtube_live_admin_notices_1714() {
* @since 1.8.0
*/
function wp_youtube_live_dismiss_notice_1714() {
update_option( 'wp-youtube-live-1714-notice-dismissed', 1, false );
update_option( 'wp-youtube-live-1714-notice-dismissed', true, false );
}

6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://cash.me/$AndrewRMinionDesign
Tags: youtube, live, video, embed
Requires at least: 3.6
Tested up to: 5.9.3
Stable tag: 1.8.3
Stable tag: 1.8.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -178,6 +178,10 @@ Because this plugin helps you use the YouTube service, you should refer to these

== Changelog ==

= 1.8.4 =
- Fix “undefined index” issue in debug logs
- Fix persistent update notice

= 1.8.3 =
- Escape admin-visible debug output

Expand Down
10 changes: 5 additions & 5 deletions wp-youtube-live.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: YouTube Live
* Plugin URI: https://github.com/macbookandrew/wp-youtube-live
* Description: Displays the current YouTube live video from a specified channel
* Version: 1.8.3
* Version: 1.8.4
* Author: Andrew Minion
* Author URI: https://andrewrminion.com/
*/
Expand Down Expand Up @@ -50,7 +50,7 @@ function output_youtube_live( $atts ) {
'width' => $settings['default_width'],
'height' => $settings['default_height'],
'autoplay' => $settings['autoplay'],
'showRelated' => $settings['show_related'],
'show_related' => $settings['show_related'],
'js_only' => false,
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'auto_refresh' => $settings['auto_refresh'],
Expand Down Expand Up @@ -120,7 +120,7 @@ function get_youtube_live_content( $request_options ) {
: sanitize_key( $request_options['autoplay'] );
$youtube_live->show_related = wp_youtube_live_is_ajax() && array_key_exists( 'show_related', $_POST )
? sanitize_key( wp_unslash( $_POST['show_related'] ) )
: sanitize_key( $request_options['showRelated'] );
: sanitize_key( $request_options['show_related'] );
$youtube_live->completed_video_id = wp_youtube_live_is_ajax() && array_key_exists( 'completedVideoID', $_POST )
? sanitize_key( wp_unslash( $_POST['completedVideoID'] ) )
: '';
Expand All @@ -138,7 +138,7 @@ function get_youtube_live_content( $request_options ) {
}

if ( $youtube_live->isLive ) {
if ( 'true' !== $request_options['js_only'] || ( 'true' === $request_options['js_only'] && wp_youtube_live_is_ajax() ) ) {
if ( ( array_key_exists( 'js_only', $request_options ) && 'true' !== $request_options['js_only'] ) || ( array_key_exists( 'js_only', $request_options ) && 'true' === $request_options['js_only'] && wp_youtube_live_is_ajax() ) ) {
$is_live = true;
// TODO: load a placeholder or nothing on initial page load?
echo $youtube_live->embedCode(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in the method.
Expand Down Expand Up @@ -196,7 +196,7 @@ function get_youtube_live_content( $request_options ) {
if ( get_option( 'youtube_live_settings', 'debugging' ) && is_user_logged_in() ) {
$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.
echo '<!-- YouTube Live debugging: ' . PHP_EOL . wp_kses_post( $debugging_code ) . PHP_EOL . ' -->';
$json_data['error'] . $debugging_code;
$json_data['error'] = $debugging_code;
}

if ( 'no_message' !== $youtube_options['fallback_behavior'] ) {
Expand Down

0 comments on commit dfc2555

Please sign in to comment.