Overwriting a filter
- This topic has 4 replies, 2 voices, and was last updated 7 years, 3 months ago by
tsquez.
-
AuthorPosts
-
December 16, 2017 at 12:35 AM #7854
tsquez
ParticipantOK so I generated this metabox which will be included in my theme:
function themename_page_options_metabox( $meta_boxes ) { $prefix = 'themename_'; $meta_boxes[] = array( 'id' => 'page-options', 'title' => esc_html__('Hide Stuff','themename'), 'post_types' => array('post','page'), 'context' => 'side', 'priority' => 'default', 'autosave' => true, 'fields' => array( array( 'id' => $prefix . 'hide_stuff', 'name' => esc_html__('Hide This','themename'), 'type' => 'checkbox', 'desc' => esc_html__('This is the description','themename'), ), ), ); return $meta_boxes; } add_filter('rwmb_meta_boxes','themename_page_options_metabox');
So after they install the theme, they use a plugin that will add more choices. How would I overwrite the filter above to add more choices when the plugin is added and activated, like this:
function themename_page_options_metabox( $meta_boxes ) { $prefix = 'themename_'; $meta_boxes[] = array( 'id' => 'page-options', 'title' => esc_html__( 'Hide Stuff', 'themename' ), 'post_types' => array( 'post', 'page' ), 'context' => 'side', 'priority' => 'default', 'autosave' => true, 'fields' => array( array( 'id' => $prefix . 'hide_this', 'name' => esc_html__('Hide This','themename'), 'type' => 'checkbox', 'desc' => esc_html__('This is the description','themename'), ), array( 'id' => $prefix . 'hide_that', 'name' => esc_html__('Hide That','themename'), 'type' => 'checkbox', 'desc' => esc_html__('This is the description','themename'), ), array( 'id' => $prefix . 'hide_and_the_other', 'name' => esc_html__('Hide This, That and the Other','themename'), 'type' => 'checkbox', 'desc' => esc_html__('This is the description','themename'), ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'themename_page_options_metabox' );
December 19, 2017 at 2:37 PM #7877Anh Tran
KeymasterHi Thomas,
I replied you on Github. To edit existing meta boxes, please just follow this instruction.
December 23, 2017 at 2:39 AM #7951tsquez
ParticipantYes I saw it on GitHub,
Thank you. I will have a look this weekend, however I am really not sure I understand...lol. I am really new to all of this metabox stuff but I find it very interesting.
I especially like everything your plugin offers and I plan on putting it to good use 😉
Thanks again. I may have some additional questions..lol
December 23, 2017 at 3:39 PM #7959Anh Tran
KeymasterNo problem :). If you find anything confused or need help, please just post here. I will try my best to explain it the easy way.
Merry Christmas!
December 23, 2017 at 11:38 PM #7965tsquez
ParticipantJust wanted to let you know that the information you had me read was SPOT ON!!!
After playing around with it, I got it working exactly the way I needed it to. Thank you so much and I appreciate the help. Merry Christmas to you and yours as well and very Happy and Prosperous New Year!
Thanks again 😉
-
AuthorPosts
- The topic ‘Overwriting a filter’ is closed to new replies.