• Hi guys, I’m working on a new plugin, it adds sertain menus to admin bar. I read many tutorials on how to create plugins and option pages, but I cant seem to find any information on how to add actual options to the option page.

    Basically what I want to do is to have an enable or disable button or drop down option for specific menu items.. so here’s the code I have from my php file..

    <?php 
    
    //**********************************//
    //  Begin: JobRoller FXtender Menu  //
    //**********************************//
    
    If (is_plugin_active('fxtender-pro-jobroller/fxtender-pro-jobroller.php')) {
    
    // FXtender Menu
    function add_jobroller_fxtender_bar_menu() { global $wp_admin_bar; if ( !is_super_admin() || !is_admin_bar_showing() ) return;
    $wp_admin_bar->add_menu( array( 'id' => 'jobroller_fxtender_links','title' => __('FXtender Menu', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings' ) ));
    
    // FXtender >> General Settings
    $wp_admin_bar->add_menu( array( 'parent' => 'jobroller_fxtender_links', 'id' => 'jobroller_fxtender_settings', 'title' => __('General Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings' ),'meta' => array( 'class' => 'jobroller_fxtender_settings_menu',) ));
    
    // FXtender >> General Settings >> Sub Menu Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_settings','id' => 'jobroller_fxtender_job_publishing','title' => __('Job Publishing', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings#tab2' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_settings','id' => 'jobroller_fxtender_job_submit','title' => __('Job Submit', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings#tab3' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_settings','id' => 'jobroller_fxtender_job_page','title' => __('Job Page', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings#tab4' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_settings','id' => 'jobroller_fxtender_job_listings','title' => __('Job Listings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-settings#tab5' ) ));
    
    // FXtender >> Resume Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_links','id' => 'jobroller_fxtender_resume_options','title' => __('Resume Options', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-resumes' ) ));
    
    // FXtender >> Pricing Settings
    $wp_admin_bar->add_menu( array( 'parent' => 'jobroller_fxtender_links', 'id' => 'jobroller_fxtender_pricing', 'title' => __('Pricing Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing' ),'meta' => array( 'class' => 'jobroller_fxtender_pricing_menu',) ));
    
    // FXtender >> General Settings >> Sub Menu Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_pricing','id' => 'jobroller_fxtender_pricing_gateways','title' => __('Gateways', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing#tab1' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_pricing','id' => 'jobroller_fxtender_pricing_google','title' => __('Google Checkout', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing#tab2' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_pricing','id' => 'jobroller_fxtender_pricing_2checkout','title' => __('2Checkout', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing#tab3' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_pricing','id' => 'jobroller_fxtender_pricing_authorizenet','title' => __('Authorize.Net', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing#tab4' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_pricing','id' => 'jobroller_fxtender_pricing_manual','title' => __('Manual', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-pricing#tab5' ) ));
    
    // FXtender >> Membership Settings
    $wp_admin_bar->add_menu( array( 'parent' => 'jobroller_fxtender_links', 'id' => 'jobroller_fxtender_membership', 'title' => __('Membership Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-membership' ),'meta' => array( 'class' => 'jobroller_fxtender_membership_menu',) ));
    
    // FXtender >> Membership Settings >> Sub Menu Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_membership','id' => 'jobroller_fxtender_membership_s2member','title' => __('S2Member Integration', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-membership#tab1' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_membership','id' => 'jobroller_fxtender_membership_google','title' => __('How To', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-membership#tab2' ) ));
    
    // FXtender >> Notifications Settings
    $wp_admin_bar->add_menu( array( 'parent' => 'jobroller_fxtender_links', 'id' => 'jobroller_fxtender_notifications', 'title' => __('Notifications Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-notifications' ),'meta' => array( 'class' => 'jobroller_fxtender_notifications_menu',) ));
    
    // FXtender >> Notifications Settings >> Sub Menu Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_notifications','id' => 'jobroller_fxtender_notifications_notices','title' => __('Notices', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-notifications#tab1' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_notifications','id' => 'jobroller_fxtender_notifications_email','title' => __('E-mail', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-notifications#tab2' ) ));
    
    // FXtender >> Integration Settings
    $wp_admin_bar->add_menu( array( 'parent' => 'jobroller_fxtender_links', 'id' => 'jobroller_fxtender_integration', 'title' => __('Integration Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-integration' ),'meta' => array( 'class' => 'jobroller_fxtender_integration_menu',) ));
    
    // FXtender >> Integration Settings >> Sub Menu Options
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_integration','id' => 'jobroller_fxtender_integration_linkedin','title' => __('LinkedIn', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-integration#tab1' ) ));
    
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_integration','id' => 'jobroller_fxtender_integration_indeed','title' => __('Indeed (JR 1.4.x or Less)', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-integration#tab2' ) ));
    
    // FXtender >>  Widget Settings
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_links','id' => 'jobroller_fxtender_widgets_options','title' => __('Widget Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/admin.php?page=jr-fx-admin-widgets' ) ));
    
    // FXtender >>  More Settings
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_links','id' => 'jobroller_fxtender_more_options','title' => __('More Settings', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, '/wp-admin/dmin.php?page=jr-fx-admin-more' ) ));
    
    // FXtender >>  System Info
    $wp_admin_bar->add_menu( array('parent' => 'jobroller_fxtender_links','id' => 'jobroller_fxtender_sysinfo_options','title' => __('System Info', 'jraba'),
    'href' =>get_home_url( $blog->userblog_id, 'wp-admin/admin.php?page=jr-fx-admin-sys-info' ) ));
    
    } add_action('admin_bar_menu', 'add_jobroller_fxtender_bar_menu',51); } else { }
    
    ?>

    So in my option page I would like to have the option to turn this menu on and off.. toggle buttons or drop downs for the yes or no..

    additionally I want to add the same options for every sub menu..

    Option Page Example:

    Would you like to have FXtender menu enabled? [yes] or [no]

    If yes, additional options would show up,

    Something like optional settings:

    —–

    Please choose which of the sub menu items you would like to have enabled?

    ——

    General Settings [yes] [no]
    Job Publishing [yes] [no]
    Job Submit [yes] [no]
    Job Page [yes] [no]
    Job Listings [yes] [no]
    Resume Options [yes] [no]
    Pricing Settings [yes] [no]
    Gateways [yes] [no]
    Google Checkout [yes] [no]
    2Checkout [yes] [no]
    Authorize.Net [yes] [no]
    Manual [yes] [no]
    Membership Settings [yes] [no]
    S2Member Integration [yes] [no]
    How To [yes] [no]
    Notifications Settings [yes] [no]
    Notices [yes] [no]
    E-mail [yes] [no]
    Integration Settings [yes] [no]
    LinkedIn [yes] [no]
    Indeed [yes] [no]
    Widget Settings [yes] [no]
    More Settings [yes] [no]
    System Info [yes] [no]

    —–

    The plugin is basically done, it’s my first plugin, and I worked realy hard on it, I just thought it would be nice to take it one step further with the option page to give the user the option of which menu items they would like to have in the admin bar.

    Your help or insight would be extremely appreciated..

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Take a look at Settings API. The checklist for admin bar placement is a good idea. I hate apps that clutter shortcut menus with cruft I never use. You might consider setting this portion up similar to the screen options pull down on many admin panels, since users would rarely need to change these options once selected to their preference. Just a thought, I don’t really intend to give you more work to do.

    Another observation if I may. Are there a lot of settings for each sub menu? Seems like a lot of sub menus. It would be less overwhelming if some of them could be combined. Again, just a thought.

    Thread Starter Alex.R

    (@alexr-1)

    Thank You.. all the submenu options were combined, I thought of that too, since there is so many options. I only made the main links optional in the option page. I’m also looking for a way to give the user the option of ether allowing the admin bar menu options on the front-end or back end, sort of speak..

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need help with adding options to the plugin options page..’ is closed to new replies.