Admin Page Framework is an OOP based open source WordPress library that facilitates theme and plugin development.
There are mainly two ways to include the framework.
-
Use the framework loader plugin.
-
Use the generated framework files which can be downloaded via
Dashboard
->Admin Page Framework
->Tools
->Generator
.
For more details, see the Getting Started (Dashboard
-> Admin Page Framework
-> Help
-> Getting Started
) of the admin pages of the loader plugin.
<?php
/* Plugin Name: Admin Page Framework - Getting Started */
include( dirname( __FILE__ ) . '/library/apf/admin-page-framework.php' );
class APF extends AdminPageFramework {
public function setUp() {
$this->setRootMenuPage( 'Settings' ); // where to belong
$this->addSubMenuItem(
array(
'title' => 'My First Page',
'page_slug' => 'myfirstpage'
)
);
}
/**
* @callback action do_{page slug}
*/
public function do_myfirstpage() {
?>
<h3>Say Something</h3>
<p>This is my first admin page!</p>
<?php
}
}
new APF;
<?php
/* Plugin Name: Admin Page Framework - My First Form */
include( dirname( __FILE__ ) . '/library/apf/admin-page-framework.php' );
class APF_MyFirstFrom extends AdminPageFramework {
public function setUp() {
$this->setRootMenuPage( 'My Settings' ); // create a root page
$this->addSubMenuItem(
array(
'title' => 'My First Form',
'page_slug' => 'my_first_form'
)
);
}
/**
* The pre-defined callback method that is triggered when the page loads.
* @callback action load_{page slug}
*/
public function load_my_first_form( $oAdminPage ) {
$this->addSettingSections(
array(
'section_id' => 'my_first_text_section',
'page_slug' => 'my_first_form',
)
);
$this->addSettingFields(
array(
'field_id' => 'text',
'section_id' => 'my_first_text_section',
'title' => 'Text',
'type' => 'text',
'default' => 123456,
),
array(
'field_id' => 'submit',
'type' => 'submit',
)
);
}
}
new APF_MyFirstFrom;
See more code examples in Dashboard
-> AdminPageFramework
-> Help
-> Examples
.
Anyone is welcome to contribute to Admin Page Framework. There are various ways you can contribute:
- Report bugs.
- Post ideas on enhancements.
- Send us a Pull Request with your bug fixes and/or new features.
- Write a custom field type.
- Write test cases.
- Improve the documentation.
- Tweak the styling of the framework page elements.
- Translate the language files in the language directory to your native language.
- Possibly more.
See the contribution guideline.
If you like the library, please rate and review it in the WordPress Plugin Directory. Also donation would be greatly appreciated. Thank you!