Skip to content

Commit

Permalink
Fix issue with options pages not saving when parent_slug was used. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsternberg committed Aug 8, 2017
1 parent ca7d173 commit c701eb6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
### Bug Fixes

* Fix issue in 2.2.5 with non-sortable repeatable groups not having new groups values be emptied on creation/clone. [Support thread](https://wordpress.org/support/topic/the-default-parameter-dont-work-in-group-fields/page/2/)
* Fix issue with options pages not saving when parent_slug was used. Fixes [#1008](https://github.com/CMB2/CMB2/issues/1008).

## [2.2.5.1 - 2017-08-07][https://github.com/CMB2/CMB2/releases/tag/v2.2.5.1]

Expand Down
17 changes: 8 additions & 9 deletions includes/CMB2_Options_Hookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,20 @@ public function options_page_menu_hooks() {
* @since 2.2.5
*/
public function options_page_output() {
$object_id = $this->cmb->object_id();

settings_errors( $object_id . '-notices' );
settings_errors( "{$this->option_key}-notices" );

$callback = $this->cmb->prop( 'display_cb' );
if ( is_callable( $callback ) ) {
return $callback( $this );
}

?>
<div class="wrap cmb2-options-page option-<?php echo $object_id; ?>">
<div class="wrap cmb2-options-page option-<?php echo $this->option_key; ?>">
<?php if ( $this->cmb->prop( 'title' ) ) : ?>
<h2><?php echo wp_kses_post( $this->cmb->prop( 'title' ) ); ?></h2>
<?php endif; ?>
<form class="cmb-form" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" method="POST" id="<?php echo $this->cmb->cmb_id; ?>" enctype="multipart/form-data" encoding="multipart/form-data">
<input type="hidden" name="action" value="<?php echo esc_attr( $object_id ); ?>">
<input type="hidden" name="action" value="<?php echo esc_attr( $this->option_key ); ?>">
<?php $this->options_page_metabox(); ?>
<?php submit_button( esc_attr( $this->cmb->prop( 'save_button' ) ), 'primary', 'submit-cmb' ); ?>
</form>
Expand Down Expand Up @@ -168,11 +167,11 @@ public function save_options() {
$this->can_save( 'options-page' )
// check params
&& isset( $_POST['submit-cmb'], $_POST['action'] )
&& $this->cmb->object_id() === $_POST['action']
&& $this->option_key === $_POST['action']
) {

$updated = $this->cmb
->save_fields( $this->cmb->object_id(), $this->cmb->object_type(), $_POST )
->save_fields( $this->option_key, $this->cmb->object_type(), $_POST )
->was_updated(); // Will be false if no values were changed/updated.

$url = add_query_arg( 'updated', $updated ? 'true' : 'false', $url );
Expand All @@ -188,7 +187,7 @@ public function save_options() {
* @return mixed Value set for the network option.
*/
public function network_get_override( $test, $default = false ) {
return get_site_option( $this->cmb->object_id(), $default );
return get_site_option( $this->option_key, $default );
}

/**
Expand All @@ -197,7 +196,7 @@ public function network_get_override( $test, $default = false ) {
* @return bool Success/Failure
*/
public function network_update_override( $test, $option_value ) {
return update_site_option( $this->cmb->object_id(), $option_value );
return update_site_option( $this->option_key, $option_value );
}

}
4 changes: 2 additions & 2 deletions languages/cmb2.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ msgid ""
msgstr ""
"Project-Id-Version: CMB2 2.2.5.2\n"
"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/cmb2\n"
"POT-Creation-Date: 2017-08-08 14:20:08+00:00\n"
"POT-Creation-Date: 2017-08-08 14:41:40+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2017-8-8 14:20+240\n"
"PO-Revision-Date: 2017-8-8 14:41+240\n"
"Last-Translator: CMB2 Team [email protected]\n"
"Language-Team: CMB2 Team [email protected]\n"
"X-Generator: grunt-wp-i18n 0.4.9\n"
Expand Down

0 comments on commit c701eb6

Please sign in to comment.