is it possible run use meta-box and setting page generator from plugin?

Support MB User Meta is it possible run use meta-box and setting page generator from plugin?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5761
    like-nixlike-nix
    Participant

    hello dear support team and all developers.

    i try run code like this from plugin. setting menu and page well generated, but metaboxes doesn't.

    https://drive.google.com/open?id=0B8TDEl003_XNM3diUzN0M2UxeU0no metaboxes

    help me please.

    #5765
    like-nixlike-nix
    Participant

    this code work if write in theme function.php file, but not from any plugin file. filter rwmb_meta_boxes doesn't work in plugin. tell me why?

    add_filter( 'mb_settings_pages', 'prefix_options_page' );
    function prefix_options_page( $settings_pages )
    {
    	$settings_pages[] = array(
    		'id'          => 'pencil',
    		'option_name' => 'pencil',
    		'menu_title'  => __( 'Pencil', 'textdomain' ),
    		'icon_url'    => 'dashicons-edit',
    		'style'       => 'no-boxes',
    		'columns'     => 1,
    		'tabs'        => array(
    			'general' => __( 'General Settings', 'textdomain' ),
    			'design'  => __( 'Design Customization', 'textdomain' ),
    			'faq'     => __( 'FAQ & Help', 'textdomain' ),
    		),
    		'position'    => 68,
    	);
    	return $settings_pages;
    }
    // Register meta boxes and fields for settings page
    add_filter( 'rwmb_meta_boxes', 'prefix_options_meta_boxes' );
    function prefix_options_meta_boxes( $meta_boxes )
    {
    	$meta_boxes[] = array(
    		'id'             => 'general',
    		'title'          => __( 'General', 'textdomain' ),
    		'settings_pages' => 'pencil',
    		'tab'            => 'general',
    		'fields' => array(
    			array(
    				'name' => __( 'Logo', 'textdomain' ),
    				'id'   => 'logo',
    				'type' => 'file_input',
    			),
    			array(
    				'name'    => __( 'Layout', 'textdomain' ),
    				'id'      => 'layout',
    				'type'    => 'image_select',
    				'options' => array(
    					'sidebar-left'  => 'http://i.imgur.com/Y2sxQ2R.png',
    					'sidebar-right' => 'http://i.imgur.com/h7ONxhz.png',
    					'no-sidebar'    => 'http://i.imgur.com/m7oQKvk.png',
    				),
    			),
    		),
    	);
    	$meta_boxes[] = array(
    		'id'             => 'colors',
    		'title'          => __( 'Colors', 'textdomain' ),
    		'settings_pages' => 'pencil',
    		'tab'            => 'design',
    		'fields' => array(
    			array(
    				'name' => __( 'Heading Color', 'textdomain' ),
    				'id'   => 'heading-color',
    				'type' => 'color',
    			),
    			array(
    				'name' => __( 'Text Color', 'textdomain' ),
    				'id'   => 'text-color',
    				'type' => 'color',
    			),
    		),
    	);
    	$meta_boxes[] = array(
    		'id'             => 'info',
    		'title'          => __( 'Theme Info', 'textdomain' ),
    		'settings_pages' => 'pencil',
    		'tab'            => 'faq',
    		'fields'         => array(
    			array(
    				'type' => 'custom_html',
    				'std'  => __( '<strong>Having questions?</strong><br><br><a href="https://metabox.io/docs/" target="_blank" class="button-primary">Go to our documentation</a>', 'textdomain' ),
    			),
    		),
    	);
    	return $meta_boxes;
    }
    #5769
    Anh TranAnh Tran
    Keymaster

    Probably your plugin loads the file that contains rwmb_meta_boxes too late. Make sure to load it before init hook.

    #5771
    like-nixlike-nix
    Participant

    Anh Tran, thank you. Right, i load rwmb_meta_boxes after init. Problem solved.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘is it possible run use meta-box and setting page generator from plugin?’ is closed to new replies.