From 5cf2359ebe6b828a14884614771e550e647a823a Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Fri, 26 Jan 2024 14:08:52 +0530 Subject: [PATCH 1/8] Fix: Undefined array key sub_type --- includes/admin/api/class-bc-admin-media-api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/admin/api/class-bc-admin-media-api.php b/includes/admin/api/class-bc-admin-media-api.php index db2b7886..ad42d229 100644 --- a/includes/admin/api/class-bc-admin-media-api.php +++ b/includes/admin/api/class-bc-admin-media-api.php @@ -249,8 +249,9 @@ public function bc_ajax_update_video_or_playlist() { } elseif ( 'videos' === $_POST['type'] ) { $type_msg = 'video'; - if ( 'variant' === $_POST['sub_type'] ) { - $status = $this->videos->update_bc_video( $updated_data, sanitize_text_field( $_POST['sub_type'] ) ); + $sub_type = $_POST['sub_type'] ?? ''; + if ( 'variant' === $sub_type ) { + $status = $this->videos->update_bc_video( $updated_data, sanitize_text_field( $sub_type ) ); } else { $status = $this->videos->update_bc_video( $updated_data ); From 89b9aceb02a3168ada453d163a0c6861af6d539d Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Fri, 26 Jan 2024 14:47:32 +0530 Subject: [PATCH 2/8] Fix: Only variables should be passed by reference --- includes/admin/class-bc-admin-labels-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-bc-admin-labels-page.php b/includes/admin/class-bc-admin-labels-page.php index 395636e7..d95a38ae 100644 --- a/includes/admin/class-bc-admin-labels-page.php +++ b/includes/admin/class-bc-admin-labels-page.php @@ -52,7 +52,7 @@ public function render_edit_label_page() { - +

From 638dc70dc19bbd2bf51d83cd1354a972ae1d8c24 Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Tue, 30 Jan 2024 16:11:00 +0530 Subject: [PATCH 3/8] Update code for PHP5 compatibility --- includes/admin/api/class-bc-admin-media-api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin/api/class-bc-admin-media-api.php b/includes/admin/api/class-bc-admin-media-api.php index ad42d229..6f9fbb42 100644 --- a/includes/admin/api/class-bc-admin-media-api.php +++ b/includes/admin/api/class-bc-admin-media-api.php @@ -249,9 +249,9 @@ public function bc_ajax_update_video_or_playlist() { } elseif ( 'videos' === $_POST['type'] ) { $type_msg = 'video'; - $sub_type = $_POST['sub_type'] ?? ''; + $sub_type = isset( $_POST['sub_type'] ) ? sanitize_text_field( $_POST['sub_type'] ) : ''; if ( 'variant' === $sub_type ) { - $status = $this->videos->update_bc_video( $updated_data, sanitize_text_field( $sub_type ) ); + $status = $this->videos->update_bc_video( $updated_data, $sub_type ); } else { $status = $this->videos->update_bc_video( $updated_data ); From 9e68966126d13b224dda114e05e5c4c6e66acf66 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 13 Feb 2024 11:39:18 +0500 Subject: [PATCH 4/8] Fix: Don't show 'Label added' message if label data is empty (#374) --- includes/class-bc-labels.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/class-bc-labels.php b/includes/class-bc-labels.php index be6fcc5d..d48197d0 100644 --- a/includes/class-bc-labels.php +++ b/includes/class-bc-labels.php @@ -137,8 +137,15 @@ public function add_label() { ) { $label_name = sanitize_text_field( $_POST['label-name'] ); $label_path = ! empty( $_POST['label-path'] ) ? $_POST['label-path'] : ''; - $this->cms_api->add_label( $label_name, $label_path ); - wp_safe_redirect( admin_url( 'admin.php?page=brightcove-labels&add_label=1&refresh_labels=1' ) ); + + $redirect_url = admin_url( 'admin.php?page=brightcove-labels&refresh_labels=1' ); + + if ( ! empty( $label_name ) || ! empty( $label_path ) ) { + $this->cms_api->add_label( $label_name, $label_path ); + $redirect_url = add_query_arg( 'add_label', '1', $redirect_url ); + } + + wp_safe_redirect( $redirect_url ); exit; } } From 8b0bb8b6304d8731629448f60343dde349966bbd Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Thu, 15 Feb 2024 17:17:42 +0530 Subject: [PATCH 5/8] Assign the value to a variable --- includes/admin/class-bc-admin-labels-page.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/admin/class-bc-admin-labels-page.php b/includes/admin/class-bc-admin-labels-page.php index d95a38ae..a06475fb 100644 --- a/includes/admin/class-bc-admin-labels-page.php +++ b/includes/admin/class-bc-admin-labels-page.php @@ -35,6 +35,7 @@ public function __construct() { * Renders html of the edit labels page */ public function render_edit_label_page() { + $label_name = $_GET['update_label'] ?? ''; ?>

@@ -46,13 +47,13 @@ public function render_edit_label_page() {
- + - + From 4e0a24b27e964e09feace421f7d0cf2d4b11acb8 Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Thu, 15 Feb 2024 17:52:18 +0530 Subject: [PATCH 6/8] PHP5 compatibility --- includes/admin/class-bc-admin-labels-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-bc-admin-labels-page.php b/includes/admin/class-bc-admin-labels-page.php index a06475fb..d675e86c 100644 --- a/includes/admin/class-bc-admin-labels-page.php +++ b/includes/admin/class-bc-admin-labels-page.php @@ -35,7 +35,7 @@ public function __construct() { * Renders html of the edit labels page */ public function render_edit_label_page() { - $label_name = $_GET['update_label'] ?? ''; + $label_name = isset( $_GET['update_label'] ) ? $_GET['update_label'] : ''; ?>

From bc77f97e6e107c2f0c2978818d55580e0c4a12ad Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Thu, 15 Feb 2024 18:17:55 +0530 Subject: [PATCH 7/8] Fix lint issues --- includes/admin/class-bc-admin-labels-page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-bc-admin-labels-page.php b/includes/admin/class-bc-admin-labels-page.php index d675e86c..a774accf 100644 --- a/includes/admin/class-bc-admin-labels-page.php +++ b/includes/admin/class-bc-admin-labels-page.php @@ -35,7 +35,7 @@ public function __construct() { * Renders html of the edit labels page */ public function render_edit_label_page() { - $label_name = isset( $_GET['update_label'] ) ? $_GET['update_label'] : ''; + $label_name = isset( $_GET['update_label'] ) ? $_GET['update_label'] : ''; // phpcs:ignore WordPress.Security.NonceVerification ?>

@@ -47,7 +47,7 @@ public function render_edit_label_page() { - +

- +

From 28f9217e5c2b46ce79b947b1b64c3792c29508c5 Mon Sep 17 00:00:00 2001 From: "mohammed.razzaq" Date: Thu, 15 Feb 2024 18:31:53 +0530 Subject: [PATCH 8/8] Add feedback --- includes/admin/class-bc-admin-labels-page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-bc-admin-labels-page.php b/includes/admin/class-bc-admin-labels-page.php index a774accf..9b7a1a3f 100644 --- a/includes/admin/class-bc-admin-labels-page.php +++ b/includes/admin/class-bc-admin-labels-page.php @@ -53,7 +53,7 @@ public function render_edit_label_page() {
- +