Skip to:
Content
Pages
Categories
Search
Top
Bottom

Example / Skeleton Admin options pane

  • @azznonimous

    Participant

    Hi all

    I’m using WPMU 2.8.2/ BP 1.0.3.

    I have some small plugins based on the example skeleton. To ease our work, I reduced them just leaving the classes, widgets and/or admin options pages. They basically work as a class/function include set to add some functionallity all over the site.

    In first stages of the skeleton I remember to see an options pane (at wp-admin), and a settings pane (at blog profile settings > example).

    The case is that, after some time working on other stuff, once back to them, both disappeared. Checking the code I’ve found that at bp-example-admin.php:68 eclipse states a bad closed <tr> tag:

    </tr>
    <tr><!-- here -->
    <th scope="row"><label for="target_uri">

    Once fixed, the @blog profile settings for the example plugin appeared. However, I’m unable to make appear again the options defined here:

    $setting_one = get_option( 'example-setting-one' );
    $setting_two = get_option( 'example-setting-two' );

    Please, can someone point me right?

    Thank you so much in advance!

Viewing 9 replies - 1 through 9 (of 9 total)
  • @azznonimous

    Participant

    further investigation lead me to:

    function bp_example_check_installed() {

    ...

    /***
    * If you call your admin functionality here, it will only be loaded when the user is in the
    * wp-admin area, not on every page load.
    */
    require ( WP_PLUGIN_DIR . '/bp-example/bp-example-admin.php' );

    Checking WP_PLUGIN_DIR returns a full path that looks like it’s the key of all the problem. If I use just require ( 'bp-example/bp-example-admin.php' ); the require looks to work …

    … still looking at this …

    @jeffsayre

    Participant

    require ( WP_PLUGIN_DIR . '/bp-example/bp-example-admin.php' );

    Checking WP_PLUGIN_DIR returns a full path that looks like it’s the key of all the problem. If I use just

    require ( 'bp-example/bp-example-admin.php' );

    the require looks to work

    Make sure your component is in /wp-content/plugins/ and not /plugins/buddypress/. If you do that, then using WP_PLUGIN_DIR will lead to the correct pathing.

    @azznonimous

    Participant

    Thanks Jeff. I’m using the new folder and structure. The WP_PLUGIN_DIR is just what comes along with the skeleton 1.2.2.

    I’m working on this (I have a workaround working) and feedback again once I have it absolutely clear.

    @azznonimous

    Participant

    … by the way, the skeleton/example admin options should appear under the WPMU > BuddyPress pane, right ?

    @azznonimous

    Participant

    I’ve seen that this:

    bp-example-admin.php:

    add_action( 'admin_menu', 'bp_example_add_admin_menu' );

    This add_action is right after the definition of the same bp_example_add_admin_menu function.

    From my understanding, once the require at the bp-example page is called, the add_action executes the function, am I right ? if so this doesn’t work, however, if I call bp_example_add_admin_menu right after the require it works fine loading the menu option right under the BuddyPress pane.

    This is the propper behaviour ?

    @jeffsayre

    Participant

    It depends on what your plugin does, but in general, I would assume that BuddyPress plugins that have options a site admin can set would be listed as a submenu under the BuddyPress menu grouping.

    In add_submenu_page( ), just make sure to set the first parameter to ‘bp-core.php’ if you want it to appear under the “BuddyPress” menu grouping. If you want the menu to instead appear under the “Site Admin” menu grouping, you would then set the first parameter to ‘wpmu-admin.php’.

    @jeffsayre

    Participant

    I have had issues with the call to add_submenu_page working when placed within the bp-example-admin.php file. Instead, I place my …add_admin_menu() within the main file, bp-example.php.

    function bp_example_add_admin_menu() {
    global $wpdb, $bp;

    if ( !is_site_admin() )
    return false;

    add_submenu_page( 'bp-core.php', __("Example Settings", 'bp-example'),
    __("Example Settings", 'bp-example'), 1, __FILE__, "bp_example_admin_settings" );
    }
    add_action( 'admin_menu', 'bp_example_add_admin_menu' );

    @azznonimous

    Participant

    Hi Jeff

    The add_submenu_page works fine. The problem it’s focused at add_action. It does not work at the example plugin, nor at my plugin. I do a workaround calling the …_add_admin_menu functions, but the add_action/filter_actions does not execute the paired function (here I’m just reporting or asking if anyoneelse has the same issue with the Admin side from Skeleton 1.2.2 component).

    If, as you state, I place both, the functions and add_action in the main file, they work fine.

    I was looking to build/fix the base for my plugins and make them wpmu/bp-future-proof.

    Thank you so much Jeff!

    @azznonimous

    Participant

    … Just the last comment, the add_action works fine this way (last line, moved from the bp-example-admin.php to bp-example.php):

    function bp_example_check_installed() {
    global $wpdb, $bp;

    if ( !is_site_admin() )
    return false;

    /***
    * If you call your admin functionality here, it will only be loaded when the user is in the
    * wp-admin area, not on every page load.
    */
    require ( WP_PLUGIN_DIR . '/bp-example/bp-example-admin.php' );

    /* Need to check db tables exist, activate hook no-worky in mu-plugins folder. */
    if ( get_site_option('bp-example-db-version') < BP_EXAMPLE_DB_VERSION )
    bp_example_install();
    }
    add_action( 'admin_menu', 'bp_example_check_installed' );
    add_action( 'admin_menu', 'bp_example_add_admin_menu' );

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Example / Skeleton Admin options pane’ is closed to new replies.
Skip to toolbar