Skip to content

Conversation

@lipemat
Copy link
Contributor

@lipemat lipemat commented Jun 10, 2018

v2.3.0 as well as tested against trunk.

Issue
Taxonomy fields accept a 'remove_default' parameter which unregisters the default term meta box on the post edit screens. This parameter works fine if you are using a standard meta box context when registering the meta box. However if you use another context such as 'after_title' this 'remove_default' parameter does nothing.

To Recreate:
Use a context when registering a box such as 'after_title'
Add a field of a taxonomy type and pass 'remove_default' to the field
See the default taxonomy meta box still exists on post edit screens

Solution
This pull request decouples the remove_default_tax_metabox() method from the add_metaboxes() method and calls it on it's own independent 'add_meta_boxes' action which allows the 'remove_default' param to work from any context.

@tw2113
Copy link
Contributor

tw2113 commented Sep 21, 2018

As a whole, I don't see anything drastically wrong with this. I am curious if the new add_action line would be better a few lines up in the switch statement section for the default case. The only other place I think it would be potentially needed is alongside add_action( 'add_meta_boxes_comment', array( $this, 'add_metaboxes' ) ); but hard to say for sure.

Thoughts @lipemat ?

@lipemat
Copy link
Contributor Author

lipemat commented Sep 28, 2018

If we move it up into the switch, it won't work for any of the alternate contexts. Letting it run outside the switch ensures that it will run no matter which context is selected and in cases where there is only an alternate context used. 😄

@tw2113
Copy link
Contributor

tw2113 commented Sep 28, 2018

The mentions being the different possible positions within the post editor screen alone, or post editor vs options page vs taxonomy term edit screen vs user profile? Just making sure I am comprehending correctly.

@lipemat
Copy link
Contributor Author

lipemat commented Sep 28, 2018

The different possible positions of the post editing screen. For instance if you add some fields to 'after_title' and want to remove the default taxonomy meta box (because you added a new field which contains a more appropriate way to set a term for your use case)

@tw2113
Copy link
Contributor

tw2113 commented Sep 28, 2018

Just making sure.

@jtsternberg jtsternberg merged commit e5d8751 into CMB2:trunk Dec 3, 2018
jtsternberg added a commit that referenced this pull request Dec 3, 2018
jtsternberg added a commit that referenced this pull request Dec 3, 2018
@jtsternberg
Copy link
Member

Nice catch, nice fix. Thank you!

lipemat added a commit to lipemat/CMB2 that referenced this pull request Jul 19, 2019
…ng-for-groups

* upstream/trunk:
  Add props for CMB2#1147
  Some additional cleanup on CMB2#1147
  Add props for CMB2#1187
  Pull in the nodename, and default to div
  Make field description color accessible (fix color contrast ratio). h/t @rianrietveld. Fixes CMB2#1193
  Add optional mb_callback_args box property which allows defining args for add_meta_box. Closes CMB2#1191
  Update changelong to give @staurand props for CMB2#1190 (Fixes CMB2#1156)
  Revert file changes from CMB2#1190 and move gutenberg compatibility callback to main cmb JS file
  Update assets
  Fix tests: add cmb2-wysiwyg-gutenberg-fix as js dependency
  Fix CMB2#1156 / Update Gruntfile
  Fix CMB2#1156
  Updates 1187 - explicitly specifiy closing bracket when adding a new row to group
  support any type of markup when repeating group row
  Fix PR urls in changelog
  Add props for CMB2#1179
  Qa/phpcs cleanup (CMB2#1179)
  add our minimum required php version to the readme
  Update changelong to give props for CMB2#1177
  Another instance where we should use call_user_func() instead of direct call
  use call_user_func() instead of direct call.
  Add 3 custom field types from @scottsawyer to readme resources. Closes CMB2#1171
  update some more 3rd party resource items
  cleanup phpdocs for `php_to_js_dateformat`
  update 3rd party resources to include Leaflet Map field type. Props @villeristi
  Minor correction in URL
  Added new custom field type
  Tweak inline comments, and update changelog to give props for CMB2#1166
  Add CMB2_Field::get_rest_value method for sending value through several filters before sending to REST request
  WP_Http class constants were added in WP 4.5
  Doing it CMB2 way
  Fix the issue in WP prior to 4.7
  Add Switch Button field type to resources. Closes CMB2#1151
  make remove_default_tax_metaboxes method public so it may be called by hooks
  Call remove_default_tax_metaboxes from any type of post_hooks
  Add Props for CMB2#1142
  Update the draggable state's border style
  Fix docblock for CMB2_Type_Base::__call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants