MB Settings
Support › MB Settings Page › MB Settings
- This topic has 7 replies, 2 voices, and was last updated 9 years, 3 months ago by
Anh Tran.
-
AuthorPosts
-
December 21, 2015 at 7:51 AM #1943
carassius
ParticipantI thought I would try using the new MB Settings Extension in my plugin, but it does not seem to want to work..I am sure I am doing something wrong.
I have the mb-settings-page folder in my root directory (along with the meta-box folder) and am trying to load it via this function
function fp_add_meta() { if( !class_exists( 'RW_Meta_Box' ) ) { include( plugin_dir_path( __FILE__ ) . 'meta-box/meta-box.php'); } if( !class_exists( 'MB_Settings_Page' ) ) { include( plugin_dir_path( __FILE__ ) . 'mb-settings-page/mb-settings-page.php'); } } add_action( 'init', 'fp_add_meta' );
The meta-box is loading fine, as the metaboxes are working in my CPT, however I have the following function to create the settings page, but cannot see it in my admin panel at all
function bl_plugin_page( $settings_pages ) { $settings_pages[] = array( 'id' => 'bl-settings', 'menu_title' => __( 'BeaverLodge Options', 'textdomain' ), 'icon_url' => 'dashicons-admin-generic', ); return $settings_pages; } add_filter( 'mb_settings_pages', 'bl_plugin_page' );
December 21, 2015 at 8:07 AM #1944carassius
ParticipantOk, I installed the settings page as per a normal plugin and it failed so it is loading in my plugin, so my
fp_add_meta()
function is working.That means my
bl_plugin_page
function is not.I tried the example code (which by the way is wrong)
add_filter( 'mb_settings_pages', 'prefix_settings_pages' ); function prefix_settings_pages( $settings_pages ) { $settings_pages[] = array( 'id' => 'my-options', 'option_name' => 'my_options', 'menu_title' => __( 'Options', 'textdomain' ), 'icon_url' => 'dashicons-images-alt', 'submenu_title' => __( 'Settings', 'textdomain' ), // Note this ); $settings_pages[] = array( 'id' => 'my-options-im', 'option_name' => 'my_options', 'menu_title' => __( 'Import', 'textdomain' ), 'parent' => 'my-options', // Note this ); $settings_pages[] = array( 'id' => 'my-options-ex', 'option_name' => 'my_options', 'menu_title' => __( 'Export', 'textdomain' ), 'parent' => 'my-options', ); return $settings_pages; } ); // why does this end in );?
And still no joy, so clearly something must be wrong??
December 21, 2015 at 12:41 PM #1947Anh Tran
KeymasterHi carassius,
Can you try replacing
init
byplugins_loaded
.init
is too late for the settings page extension.January 6, 2016 at 9:09 PM #2054carassius
Participanti still cannot get this to work
February 2, 2016 at 11:46 AM #2259carassius
ParticipantAnyone able to help me get this thing to work? Hello?
February 2, 2016 at 11:56 AM #2260carassius
ParticipantLet me revisit this with you
I have my bl-settings.php file in the root directory of my plugin
I also have the mb-settings-page folder in my plugins root directoryThis is how I am trying to call them
// Settings function fp_add_meta_settings() { if( !class_exists( 'MB_Settings_Page' ) ) { include( plugin_dir_path( __FILE__ ) . 'mb-settings-page/mb-settings-page.php'); } } add_action( 'plugins_loaded', 'fp_add_meta_settings' ); include( dirname( __FILE__ ) . '/bl-settings.php');
In my bl-settings.php i am trying to load my settings page as a sub-directory for the Plugins page, so i have the following code
function bl_settings_pages( $settings_pages ) { $settings_pages[] = array( 'id' => 'bl-options', 'option_name' => 'bl_options', 'parent' => 'plugins.php', 'submenu_title' => __( 'BeaverLodge HQ', 'fl-builder' ), ); return $settings_pages; } add_filter( 'mb_settings_pages', 'bl_settings_pages' ); function bl_options_meta_boxes( $meta_boxes ) { $meta_boxes[] = array( 'id' => 'fotoplugins', 'title' => __( 'Fotoplugins Settings', 'fl-builder' ), 'settings_pages' => 'bl-options', 'fields' => array( array( 'name' => __( 'Disable Gallery CPT', 'fl-builder' ), 'id' => 'gallery_cpt', 'type' => 'select', 'syd' => 'no', 'options' => array( 'no' => 'No', 'yes' => 'Yes', ), ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'bl_options_meta_boxes' );
I am getting really frustrated getting this to work, someone help please
February 2, 2016 at 5:05 PM #2263Anh Tran
KeymasterSorry for the delay. I'm replicating the problem on my localhost now.
February 2, 2016 at 5:36 PM #2264Anh Tran
KeymasterI've just checked the code and here is what I did:
1. This is how I structure a "test" plugin:
2. This is the code in the
test.php
file (similar to your 1st file):<?php /** * Plugin Name: Test * Plugin URI: https://metabox.io * Description: Test * Version: 0.0.1 * Author: Rilwis * Author URI: http://www.deluxeblogtips.com */ // Load meta box and settings page extension include plugin_dir_path( __FILE__ ) . 'meta-box/meta-box.php'; include plugin_dir_path( __FILE__ ) . 'mb-settings-page/mb-settings-page.php'; // Load configuration include plugin_dir_path( __FILE__ ) . 'bl-settings.php';
3. This is the content of the settings file:
<?php function bl_settings_pages( $settings_pages ) { $settings_pages[] = array( 'id' => 'bl-options', 'option_name' => 'bl_options', 'parent' => 'plugins.php', 'menu_title' => 'Test', 'submenu_title' => __( 'BeaverLodge HQ', 'fl-builder' ), ); return $settings_pages; } add_filter( 'mb_settings_pages', 'bl_settings_pages' ); function bl_options_meta_boxes( $meta_boxes ) { $meta_boxes[] = array( 'id' => 'fotoplugins', 'title' => __( 'Fotoplugins Settings', 'fl-builder' ), 'settings_pages' => 'bl-options', 'fields' => array( array( 'name' => __( 'Disable Gallery CPT', 'fl-builder' ), 'id' => 'gallery_cpt', 'type' => 'select', 'syd' => 'no', 'options' => array( 'no' => 'No', 'yes' => 'Yes', ), ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'bl_options_meta_boxes' );
Note:menu_title in the settings file, so the menu appears in HTML but not visible cause it doesn't have a text.
4. This is the result:
-
AuthorPosts
- The topic ‘MB Settings’ is closed to new replies.