From 17545553792359f7ab34eedb587ede8c4e396e9b Mon Sep 17 00:00:00 2001 From: Mykyta Synelnikov Date: Sat, 9 Sep 2023 02:56:11 +0300 Subject: [PATCH] - fixed the issue with `UM()->metabox()->edit_mode_value` variable. We need to flush it after each `field_input()`; - wpcs for Admin_Metabox() class; --- includes/admin/core/class-admin-metabox.php | 201 +++++++++----------- 1 file changed, 86 insertions(+), 115 deletions(-) diff --git a/includes/admin/core/class-admin-metabox.php b/includes/admin/core/class-admin-metabox.php index 776e25a8..934577e0 100644 --- a/includes/admin/core/class-admin-metabox.php +++ b/includes/admin/core/class-admin-metabox.php @@ -93,7 +93,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { */ function hide_metabox_restrict_content_shop( $hide ) { if ( function_exists( 'wc_get_page_id' ) && ! empty( $_GET['post'] ) && - absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) { + absint( $_GET['post'] ) == wc_get_page_id( 'shop' ) ) { return true; } @@ -220,7 +220,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { public function save_metabox_custom( $post_id, $post ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_custom_nonce'] ) || - ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) { + ! wp_verify_nonce( $_POST['um_admin_save_metabox_custom_nonce'], basename( __FILE__ ) ) ) { return; } @@ -324,7 +324,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { function save_metabox_restrict_content( $post_id, $post ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) || - ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) { + ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) { return; } @@ -351,7 +351,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { function save_attachment_metabox_restrict_content( $post_id ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_restrict_content_nonce'] ) - || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) { + || ! wp_verify_nonce( $_POST['um_admin_save_metabox_restrict_content_nonce'], basename( __FILE__ ) ) ) { return; } @@ -1166,7 +1166,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { // validate nonce if ( ! isset( $_POST['um_admin_save_metabox_form_nonce'] ) || - ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) { + ! wp_verify_nonce( $_POST['um_admin_save_metabox_form_nonce'], basename( __FILE__ ) ) ) { return; } @@ -1254,7 +1254,6 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } } - /** * Show field input for edit at modal field * @@ -1262,7 +1261,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { * @param null $form_id * @param array $field_args */ - function field_input( $attribute, $form_id = null, $field_args = array() ) { + public function field_input( $attribute, $form_id = null, $field_args = array() ) { if ( $this->in_edit == true ) { // we're editing a field $real_attr = substr( $attribute, 1 ); @@ -1270,9 +1269,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { } switch ( $attribute ) { - default: - /** * UM hook * @@ -1299,7 +1296,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { case '_visibility': ?> -

+

+ +

+ - +    +

- - - - - - - - -    -

- - - -

- -

- - +

+ +

+ - -

- -

- - +

+ +

+ + ?> -

- -

+

+ +

- @@ -1470,62 +1455,49 @@ if ( ! class_exists( 'um\admin\core\Admin_Metabox' ) ) { break; case '_icon': - - if ( $this->set_field_type == 'row' ) { + if ( 'row' === $this->set_field_type ) { $back = 'UM_edit_row'; - ?> +

+ -

+ edit_mode_value ) ) { ?> - + - edit_mode_value ) { ?> - - - - edit_mode_value ) { ?> + edit_mode_value ) ) { ?> -

- - in_edit ) { $back = 'UM_edit_field'; } else { $back = 'UM_add_field'; } - ?> -
+

+ -

+ - + edit_mode_value ) ) { ?> - edit_mode_value ) { ?> + - - - edit_mode_value ) { ?> + edit_mode_value ) ) { ?> -

-
- edit_mode_value = null; } - } }