Overwriting a filter

Support General Overwriting a filter

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #7854
    tsqueztsquez
    Participant

    OK 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' );
    #7877
    Anh TranAnh Tran
    Keymaster

    Hi Thomas,

    I replied you on Github. To edit existing meta boxes, please just follow this instruction.

    #7951
    tsqueztsquez
    Participant

    Yes 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

    #7959
    Anh TranAnh Tran
    Keymaster

    No 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!

    #7965
    tsqueztsquez
    Participant

    Just 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 😉

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Overwriting a filter’ is closed to new replies.