michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
337 stars 71 forks source link

How to disable the visuals of the loader plugin (silent mode) #222

Closed ivandotv closed 8 years ago

ivandotv commented 8 years ago

I've downloaded the framework, and it seems that it has a lot of options and it is very powerfull. However, if I'm not mistaken, in order to use the framework your plugin generates custom namespace/class names to be used in my theme. However, that posses a problem for upstream changes in the framework. How am I supposed to integrate the changes/bugfixes to the framewook ? I need to go through the process of downloading the framework plugin and generating new classes every time ? I'm wondering why you haven't gone the way of just creating the plugin that would be used via it's API in other themes and custom plugins.

michaeluno commented 8 years ago

Hi,

I need to go through the process of downloading the framework plugin and generating new classes every time ?

That's the safest. If you don't want to do it, you can just use the loader plugin. If you publish your plugins or themes, it is recommended you use the generator.

I'm wondering why you haven't gone the way of just creating the plugin that would be used via it's API in other themes and custom plugins.

I'm not sure what you mean but I guess you are looking for the loader plugin. Just use the loader plugin.

ivandotv commented 8 years ago

You mean if I have the plugin active, I can program directly agains your API e.g. AdminPageFramework , instead of creating my classes.

michaeluno commented 8 years ago

You mean if I have the plugin active, I can program directly agains your API e.g. AdminPageFramework , instead of creating my classes.

Yes.

Then it would be cool if the plugin could work in a way that it doesn't have any visuals in the admin area, so the user can't access tools add ons Help

You can disable the admin pages via the plugin action link, Disable Admin Pages, in the plugin listing table in plugins.php.

I guess you want to toggle it programmatically. In that case, try this code.

class APFTest_DisableLoaderVisuals {

    /**
     * Sets up hooks.
     */
    public function __construct() {
        add_filter( 'option_' . 'admin_page_framework_loader', array( $this, 'replyToModifyOpiton' ) );
    }

    /**
     * @return      array       The modified framework loader options.
     */
    public function replyToModifyOpiton( $aOptions ) {

        $aOptions = is_array( $aOptions )
            ? $aOptions
            : array();
        $aOptions[ 'enable_admin_pages' ] = false;
        return $aOptions;

    }

}
new APFTest_DisableLoaderVisuals;
ivandotv commented 8 years ago

Great, that is exactly what I was thinking of. So, basically all I need now is to install the plugin, and start coding directly against original api, and it will all be transparent to the end user (similar how some other admin frameworks do it) Think about the idea of creating the action hook when the plugin is initialized, so people can use the plugin inside their own plugin, without including the code.

michaeluno commented 8 years ago

Glad it helped!

As for an idea of creating an action hook for something, I do not understand what you mean. Maybe you can create a new topic about it. Thank you.

ivandotv commented 8 years ago

What I mean is, how would I go about using the framework inside my own plugin, without using embeded classes? I believe there would be a race condition. My plugin could be initialized before yours, so that's why I would need a hook , so I can know when I can start using the framework inside my plugin without errors.

michaeluno commented 8 years ago

Can you create a new topic about it? Thank you.

michaeluno commented 8 years ago

As of v3.6.4, this can be done by defining the APFL_SILENT_MODE constant.

define( 'APFL_SILENT_MODE', true );
ivandotv commented 8 years ago

Nice :+1: