WordPress.org

Plugin Directory

Admin Page Framework

Facilitates WordPress plugin and theme development.

About the Project

What is this for?

This is a PHP class-based WordPress library that helps to create option pages and form fields in the administration area. In addition, it helps to manage to save, export, and import options.

Who needs it?

WordPress plugin/theme developers who want to speed up creating setting forms, widgets, contact form etc. and don't want to require their users to install extra dependencies.

Do my plugin/theme users have to install Admin Page Framework?

No. Include the generated framework files in your distribution package. You can generate your own framework files via Dashboard -> Admin Page Framework -> Tools -> Generator.

Where can I get the framework files to include?

Go to Dashboard -> Admin Page Framework -> Tools -> Generator and download the files.

Does my commercial product incorporating your framework library have to be released under GPL2v+?

No. The loader plugin is released under GPLv2 or later but the library itself is released under MIT. Make sure to include only the library file.

Does the framework work with WordPress Multi-site?

Yes, it works with WordPress MU.

Technical Questions

Can I set a custom post type as a root page?

Yes. For built-in root menu items or create your own ones, you need to use the setRootMenuPage() method. For root pages of custom post types, use setRootMenuPageBySlug().

$this->setRootMenuPageBySlug( 'edit.php?post_type=apf_posts' );
How do I retrieve the stored options?

The framework stores them as an organized multidimensional array in the options table in a single row. So use the get_option() function and pass the instantiated class name as the key or the custom key if you specify one in the constructor.

For instance, if your instantiated class name is APF then the code would be

$my_options = get_option( 'APF' );

Alternatively, use the AdminPageFramework::getOption() static method.

Is it possible to use a custom options data for the form instead of the ones used by the framework?

Yes, there are two main means to achieve that.

  1. Use the value argument in the field definition array to suppress the displaying value in the field. See an example. https://gist.github.com/michaeluno/fb4088b922b71710c7fb

  2. Override the options array set to the entire form using the options_{instantiated class name}. See an example. https://gist.github.com/michaeluno/fcfac27825aa8a35b90f

When you go with the second method, make sure to pass an empty string, '' to the first parameter of the constructor so that it disables the ability to store submitted form data into the options table.

new MyAdminPage( '' );
How can I add sub-menu pages to the top-level page created by the framework in a separate script?

Say, in your main plugin, your class MyAdminPageClassA created a top-level page. In your extension plugin, you want to add sub-menu pages from another instance MyAdminPageClassB.

In the setUp() method of MyAdminPageClasB, pass the instantiated class name of the main plugin that created the root menu, MyAdminPageClassA, to the setRootMenuPageBySlug() method.

$this->setRootMenuPageBySlug( 'MyAdminPageClassA' );
Can I create pages in the network admin area?

Yes, See the demo.

Some of my users claim they cannot save options. What would be a possible cause?
  • max_input_vars of PHP settings. If this value is small and the there are lots of form input elements, the user may not be able to save the options.

To increase the value, edit php.ini and add the following line where 10000 is the increased number.

max_input_vars = 10000
  • max_allowed_packet of MySQL settings. Try increasing this value in the my.ini or my.cnf file.

The 500M in the following line is where the increased value should be set.

max_allowed_packet=500M

Please keep in mind that these are just a few of many possibilities. If you encounter a situation that prevented the user from saving options, please report.

I cannot find what I'd like to do in tutorials and documentation. Where else should I look for more information?
  • You may directly read the code of the demo plugin. The demo plugin code is located in the example directory.
  • Ask questions in the support forum.

Supporting the Project

I've written a useful class, functions, and even custom field types that will be useful for others! Do you want to include it?

The GitHub repository is available. Raise an issue first and we'll see if changes can be made.

How can I contribute to improving the documentation?

You are welcome to submit documentation. Please follow the Documentation Guideline.

In addition, your tutorials and snippets for the framework can be listed in the manual. Let us know it here.

More FAQ Items

Check out the questions tagged as FAQ on GitHub.

Tutorials

Index

Requires: 3.3 or higher
Compatible up to: 4.2.3
Last Updated: 2015-7-14
Active Installs: 300+

Ratings

4.8 out of 5 stars

Support

12 of 18 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1
100,2,2 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1
100,1,1
100,1,1
100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1
100,3,3 100,1,1 100,1,1
100,1,1
100,1,1 100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1
100,2,2 100,1,1 100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1