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?
- This topic has 3 replies, 2 voices, and was last updated 7 years, 12 months ago by
like-nix.
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
April 29, 2017 at 9:57 PM #5761
like-nix
Participanthello 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_XNM3diUzN0M2UxeU0
help me please.
April 30, 2017 at 4:05 AM #5765like-nix
Participantthis 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; }
May 1, 2017 at 4:01 PM #5769Anh Tran
KeymasterProbably your plugin loads the file that contains
rwmb_meta_boxes
too late. Make sure to load it beforeinit
hook.May 2, 2017 at 4:46 AM #5771like-nix
ParticipantAnh Tran, thank you. Right, i load rwmb_meta_boxes after init. Problem solved.
-
AuthorPosts
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.