michaeluno / admin-page-framework

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

How make APF not to run on all admin pages #114

Closed ChrisPlaneta closed 10 years ago

ChrisPlaneta commented 10 years ago

Hi Michael,

I'm wondering if there's any way not to run APF on all admin pages. I'm making a SaaS platform and when the scale of the project goes up I'm affraid of the performance issues. Also, I need only standard admin pages and not CPTs, taxonomies, custom fields etc. so I see no reason to run APF all the time.

Best regards, Chris

michaeluno commented 10 years ago

In most admin pages, the menu items need to be created, doesn't it? For example, when you access Dashboard, (wp-admin/index.php), you still want to see the menu items of your pages. This means that the methods that defines your pages need to be called in most admin pages.

Though there might be pages that APF class should not be loaded. In that case, just instantiate the APF class with a conditional statement.

if ( ... )  {
   new YourAdminPageClass;
}

If you want the framework not to be loaded inadmin-ajax.php, you may do this.

if ( is_admin() && isset( $GLOBALS['pagenow'] ) && in_array( $GLOBALS['pagenow'], array( 'admin-ajax.php', 'some_other_page.php' ) ) ) {
    new YourAdminPageClass;
}
ChrisPlaneta commented 10 years ago

So easy, so obvious. Thank you for the quick reply and for this great framework!

michaeluno commented 10 years ago

You're welcome, Chris.

Also, I need only standard admin pages and not CPTs, taxonomies, custom fields etc. so I see no reason to run APF all the time.

The custom post type and taxonomy classes are separate classes so unless they are extended and instantiated, they won't do anything so don't worry about them.

Performance issues are something I've been concerned about. If you find some overhead caused by the framework, let me know.