Skip to content

Commit

Permalink
Set default priority to 10 for options pages. Fixes CMB2#1410
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Mar 4, 2021
1 parent a804c91 commit 95274dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion includes/CMB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 95274dc

Please sign in to comment.