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 */
if ( ! class_exists( 'AdminPageFramework' ) ) {
include( dirname( __FILE__ ) . '/library/admin-page-framework/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 */
if ( ! class_exists( 'AdminPageFramework' ) ) {
include( dirname( __FILE__ ) . '/library/admin-page-framework/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
.
- Create an Admin Page
- Create a Form
- Create a Page Group
- Create In-page Tabs
- Organize a Form with Sections
- Use Section Tabs and Repeatable Sections
- Validate Submitted Form Data of a Single Field
- Validate Submitted Form Data of Multiple Fields
- Add a Meta Box in an Admin Page
- Add a Page Meta Box Specific to an In-page Tab
- Add a Meta Box for Posts
- Create a Custom Post Type and Custom Taxonomy
- Add a Meta Box to a Custom Post Type
In order to modify the framework development files, you need to clone the repository files.
Simply clone the repository from either of the following addresses.
ssh:
git@github.com:michaeluno/admin-page-framework.git
https:
https://github.com/michaeluno/admin-page-framework.git
With Composer, create a composer.json
file with the following contents and perform php composer.phar install
.
{
"require": {
"michaeluno/admin-page-framework": "dev-master"
}
}
The core files are in the development
directory.
- Make sure the constant
WP_DEBUG
is set totrue
in thewp-config.php
file of your development site. If this isfalse
, the loader plugin will load the complied files in thelibrary
directory. - Modify the core files and make sure your changes take effect.
- If you add class files, make sure to run
run.sh
intool/inclusion_class_list
to generate inclusion file lists. - After all the modifications are done, run
php-class-files-beautifier.sh
intool/beautifier
to compile the files.
If you find an issue, let us know here!
This is a developer's portal for Admin Page Framework and should not be used for support. Please visit the support forums.
Anyone is welcome to contribute to Admin Page Framework. There are various ways you can contribute:
- Try the open beta version and report issues you encounter.
- Post ideas on enhancements.
- Raise an Issue on GitHub.
- 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 by modifying the CSS rules.
- Translate the language files in the language directory to your native language.
If you like the library, please rate and review it in the WordPress Plugin Directory. Also donation would be greatly appreciated. Thank you!
Released under the MIT license. Copyright © 2013-2015 Michael Uno
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
http://opensource.org/licenses/MIT
Released under the GPL v2 or later. Copyright © 2013-2015 Michael Uno
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.