From 95274dce3c9f18b1610d92935cfea8b781471c8a Mon Sep 17 00:00:00 2001 From: Justin Sternberg Date: Wed, 3 Mar 2021 20:41:58 -0500 Subject: [PATCH] Set default priority to 10 for options pages. Fixes #1410 --- CHANGELOG.md | 3 +++ includes/CMB2.php | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ba18eb6b..1662f7d24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file. ### Enhancements * Fixes PHP warnings on repeatable ColorPicker with an array as default. Props [@rubengc](https://github.com/rubengc) ([#1340](https://github.com/CMB2/CMB2/pull/1340)). +### Bug Fixes +* Fix issue with options-pages being changed to register on a hook priority of `5` instead of the default `10`, causing some back-compatibility issues. Fixes [#1410](https://github.com/CMB2/CMB2/issues/1410). + ## [2.8.0 - 2020-01-21](https://github.com/CMB2/CMB2/releases/tag/v2.7.0) ### Enhancements diff --git a/includes/CMB2.php b/includes/CMB2.php index e8e08cbdd..33c320d97 100644 --- a/includes/CMB2.php +++ b/includes/CMB2.php @@ -74,7 +74,7 @@ class CMB2 extends CMB2_Base { * Comments screen contexts include 'normal' and 'side'. Default is 'normal'. */ 'context' => 'normal', - 'priority' => 'high', + 'priority' => 'high', // Or 10 for options pages. 'show_names' => true, // Show field names on the left. 'show_on_cb' => null, // Callback to determine if metabox should display. 'show_on' => array(), // Post IDs or page templates to display this metabox. overrides 'show_on_cb'. @@ -208,6 +208,15 @@ public function __construct( $config, $object_id = 0 ) { $this->object_id( $object_id ); if ( $this->is_options_page_mb() ) { + + // Check initial priority. + if ( empty( $config['priority'] ) ) { + + // If not explicitly defined, Reset the priority to 10 + // Fixes https://github.com/CMB2/CMB2/issues/1410. + $this->meta_box['priority'] = 10; + } + $this->init_options_mb(); }