From 4076ba0f29c6561582b80e718eaa6c72c346b90e Mon Sep 17 00:00:00 2001 From: dikiyforester Date: Sat, 4 Apr 2020 13:21:38 +0500 Subject: [PATCH 1/6] Don't use deprecated hook 'contextual_help' --- AdminPage.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/AdminPage.php b/AdminPage.php index 7eb4c3b..fb0be04 100644 --- a/AdminPage.php +++ b/AdminPage.php @@ -135,7 +135,7 @@ public function __construct( $file = false, $options = null ) { } add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] ); - add_filter( 'contextual_help', array( $this, '_contextual_help' ), 10, 2 ); + add_action( 'current_screen', array( $this, '_contextual_help' ) ); if ( $file ) { $this->file = $file; @@ -534,23 +534,17 @@ private function check_args() { /** * Adds contextual help. * - * @param string $help - * @param string|object $screen + * @param WP_Screen $screen * * @return string */ - public function _contextual_help( $help, $screen ) { - if ( is_object( $screen ) ) { - $screen = $screen->id; - } + public function _contextual_help( $screen ) { $actual_help = $this->page_help(); - if ( $screen == $this->pagehook && $actual_help ) { - return $actual_help; + if ( $screen->id == $this->pagehook && $actual_help ) { + $screen::add_old_compat_help( $screen, $actual_help ); } - - return $help; } /** From 383690d39106b36f7ff03c2380b0dc48833d46d9 Mon Sep 17 00:00:00 2001 From: dikiyforester Date: Sat, 4 Apr 2020 13:59:20 +0500 Subject: [PATCH 2/6] Better compatibility with scbAdminPage subclasses that implement _contextual_help() method. --- AdminPage.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/AdminPage.php b/AdminPage.php index fb0be04..f4fb7f2 100644 --- a/AdminPage.php +++ b/AdminPage.php @@ -135,7 +135,7 @@ public function __construct( $file = false, $options = null ) { } add_action( 'admin_menu', array( $this, 'page_init' ), $this->args['admin_action_priority'] ); - add_action( 'current_screen', array( $this, '_contextual_help' ) ); + add_action( 'current_screen', array( $this, '_contextual_help_compat' ) ); if ( $file ) { $this->file = $file; @@ -534,14 +534,34 @@ private function check_args() { /** * Adds contextual help. * - * @param WP_Screen $screen + * @param string $help + * @param string|object $screen * * @return string */ - public function _contextual_help( $screen ) { + public function _contextual_help( $help, $screen ) { + if ( is_object( $screen ) ) { + $screen = $screen->id; + } $actual_help = $this->page_help(); + if ( $screen == $this->pagehook && $actual_help ) { + return $actual_help; + } + + return $help; + } + + /** + * Sets the old string-based contextual help for the screen for backward compatibility. + * + * @param WP_Screen $screen + */ + public function _contextual_help_compat( $screen ) { + + $actual_help = $this->_contextual_help( '', $screen ); + if ( $screen->id == $this->pagehook && $actual_help ) { $screen::add_old_compat_help( $screen, $actual_help ); } From 4e6422c1c13db02bd744625c722096f6ffb1e666 Mon Sep 17 00:00:00 2001 From: Andrzej Piotrowski Date: Mon, 23 Nov 2020 13:07:59 +0100 Subject: [PATCH 3/6] fix passing extra data to radio and multi checkbox fields --- Forms.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Forms.php b/Forms.php index 43c4cd1..80637b6 100644 --- a/Forms.php +++ b/Forms.php @@ -842,6 +842,9 @@ class scbRadiosField extends scbSelectField { * @return string */ protected function _render_specific( $args ) { + $args = wp_parse_args( $args, array( + 'extra' => array(), + ) ); if ( array( 'foo' ) === $args['selected'] ) { // radio buttons should always have one option selected @@ -857,6 +860,7 @@ protected function _render_specific( $args ) { 'type' => 'radio', 'value' => $value, 'checked' => ( $value == $args['selected'] ), + 'extra' => $args['extra'], 'desc' => $title, 'desc_pos' => 'after', ) ); @@ -895,6 +899,7 @@ protected function _render( $args ) { $args = wp_parse_args( $args, array( 'numeric' => false, // use numeric array instead of associative 'checked' => null, + 'extra' => array(), ) ); if ( ! is_array( $args['checked'] ) ) { @@ -908,6 +913,7 @@ protected function _render( $args ) { 'type' => 'checkbox', 'value' => $value, 'checked' => in_array( $value, $args['checked'] ), + 'extra' => $args['extra'], 'desc' => $title, 'desc_pos' => 'after', ) ); From 9b465d0d1f9a0f386f5b126b4b6a4b92f903620c Mon Sep 17 00:00:00 2001 From: dikiyforester Date: Fri, 12 Feb 2021 12:00:11 +0500 Subject: [PATCH 4/6] Fixed deprecated in PHP8 method parameters order --- .gitignore | 1 + Cron.php | 6 +++++- Forms.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 90ec22b..24d637e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .svn +/nbproject/ diff --git a/Cron.php b/Cron.php index 27341bf..4cdc553 100644 --- a/Cron.php +++ b/Cron.php @@ -21,7 +21,11 @@ class scbCron { * * @return void */ - public function __construct( $file = false, $args ) { + public function __construct( $file = false, $args = array() ) { + + if ( empty( $args ) ) { + return; + } // Set time & schedule if ( isset( $args['time'] ) ) { diff --git a/Forms.php b/Forms.php index 80637b6..82ece4c 100644 --- a/Forms.php +++ b/Forms.php @@ -62,7 +62,7 @@ public static function form_table( $rows, $formdata = null ) { * * @return string */ - public static function form( $inputs, $formdata = null, $nonce ) { + public static function form( $inputs, $formdata = null, $nonce = 'update_options' ) { $output = ''; foreach ( $inputs as $input ) { $output .= self::input( $input, $formdata ); From b7fae89201aa575cddc3541ff3bb22b2b3e3a14c Mon Sep 17 00:00:00 2001 From: meloniq Date: Tue, 7 May 2024 21:34:52 +0200 Subject: [PATCH 5/6] fix creation of dynamic property is deprecated --- AdminPage.php | 2 ++ PostMetabox.php | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/AdminPage.php b/AdminPage.php index f4fb7f2..d6c68c7 100644 --- a/AdminPage.php +++ b/AdminPage.php @@ -35,6 +35,8 @@ abstract class scbAdminPage { // l10n protected $textdomain; + protected $nonce; + // ____________REGISTRATION COMPONENT____________ diff --git a/PostMetabox.php b/PostMetabox.php index bfae253..8f58843 100644 --- a/PostMetabox.php +++ b/PostMetabox.php @@ -28,6 +28,18 @@ class scbPostMetabox { */ private $post_data = array(); + /** + * Metabox context. + * @var string + */ + private $context; + + /** + * Metabox priority. + * @var string + */ + private $priority; + /** * Action hooks. * @var array From 8aa8c527155d5918063c1d831a73e3f16f91fcf4 Mon Sep 17 00:00:00 2001 From: meloniq Date: Thu, 16 May 2024 19:24:54 +0200 Subject: [PATCH 6/6] correct doc url --- AdminPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AdminPage.php b/AdminPage.php index d6c68c7..f0432b0 100644 --- a/AdminPage.php +++ b/AdminPage.php @@ -10,7 +10,7 @@ abstract class scbAdminPage { * $menu_title (string) (default: $page_title) * $submenu_title (string) (default: $menu_title) * $page_slug (string) (default: sanitized $page_title) - * $toplevel (string) If not empty, will create a new top level menu (for expected values see http://codex.wordpress.org/Administration_Menus#Using_add_submenu_page) + * $toplevel (string) If not empty, will create a new top level menu (for expected values see https://codex.wordpress.org/Administration_Menus#Using_add_submenu_page) * - $icon_url (string) URL to an icon for the top level menu * - $position (int) Position of the toplevel menu (caution!) * $screen_icon (string) The icon type to use in the screen header