# [Admin Page Framework](http://wordpress.org/plugins/admin-page-framework/) #

### Welcome to our GitHub Repository

Admin Page Framework is an OOP based open source WordPress library that facilitates theme and plugin development. 

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/michaeluno/admin-page-framework/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/michaeluno/admin-page-framework/?branch=master)

## Screenshots ##

<p align="center">
	<a href="https://lh6.googleusercontent.com/-U_29dZp26Yw/VCFc0cDPGSI/AAAAAAAABtM/0l9klA6JFcg/s0/built-in%2520field%2520types.png" title="Admin Page Framework - Text, Password, and Textarea">
		<img src="https://lh6.googleusercontent.com/-U_29dZp26Yw/VCFc0cDPGSI/AAAAAAAABtM/0l9klA6JFcg/s600/built-in%2520field%2520types.png" alt="Admin Page Framework - Text, Password, and Textarea" />
	</a>
</p>

<div style="margin:20px; float:left">
	<a href="https://lh4.googleusercontent.com/-EuQbXCx4HhI/VCFc441vgCI/AAAAAAAABuE/KeKVd3t5PSc/s0/selectors.png" title="Admin Page Framework - Selectors">
		<img src="https://lh4.googleusercontent.com/-EuQbXCx4HhI/VCFc441vgCI/AAAAAAAABuE/KeKVd3t5PSc/s144/selectors.png" alt="Admin Page Framework - Selectors" />
	</a>
	&nbsp;
	<a href="https://lh6.googleusercontent.com/-LjEY_hZLGX0/VCFc4Kh4BRI/AAAAAAAABt4/2ZOt-J3LpgM/s0/files.png" title="Admin Page Framework - Image, Media Library, and File Uploads">
		<img src="https://lh6.googleusercontent.com/-LjEY_hZLGX0/VCFc4Kh4BRI/AAAAAAAABt4/2ZOt-J3LpgM/s144/files.png" alt="Admin Page Framework - Image, Media Library, and File Uploads" />
	</a>
	&nbsp;
	<a href="https://lh3.googleusercontent.com/-fbuQOuBSSJ0/VCFc0CTx3rI/AAAAAAAABtI/jYYMxH07T-Q/s0/checklist.png" title="Admin Page Framework - Taxonomies and Post Types Checklist">
		<img src="https://lh3.googleusercontent.com/-fbuQOuBSSJ0/VCFc0CTx3rI/AAAAAAAABtI/jYYMxH07T-Q/s144/checklist.png" alt="Admin Page Framework - Taxonomies and Post Types Checklist" />
	</a>
	&nbsp;
	<a href="https://lh6.googleusercontent.com/-D2tssBl00fw/VCFc16XZ1CI/AAAAAAAABtY/uBBqQkWqG4w/s0/misc.png" title="Admin Page Framework - Misc">
		<img src="https://lh6.googleusercontent.com/-D2tssBl00fw/VCFc16XZ1CI/AAAAAAAABtY/uBBqQkWqG4w/s144/misc.png" alt="Admin Page Framework - Misc" />
	</a>
	&nbsp;
	<a href="https://lh5.googleusercontent.com/-gbd0VdjjKQQ/VCFc49JM_tI/AAAAAAAABuA/4FbHz_pMW2Y/s0/verification.png" title="Admin Page Framework - Form Input Verification">
		<img src="https://lh5.googleusercontent.com/-gbd0VdjjKQQ/VCFc49JM_tI/AAAAAAAABuA/4FbHz_pMW2Y/s144/verification.png" alt="Admin Page Framework - Form Input Verification" />
	</a>
	&nbsp;
	<a href="https://lh6.googleusercontent.com/-cmgLpnx3iIA/UtDfHZdsxvI/AAAAAAAABfk/BklgC-MnqWY/s0/admin_page_framework_v3_export_%2526_import.png" title="Admin Page Framework - Export and Import Options">
		<img src="https://lh6.googleusercontent.com/-cmgLpnx3iIA/UtDfHZdsxvI/AAAAAAAABfk/BklgC-MnqWY/s144/admin_page_framework_v3_export_%2526_import.png" alt="Admin Page Framework - Export and Import Options" />
	</a>
	&nbsp;
	<a href="https://lh5.googleusercontent.com/-YujIDW7LMdU/UtDfGcrDjrI/AAAAAAAABfM/EMA4NF3WgYU/s0/admin_page_framework_help_pane.png" title="Admin Page Framework - Contextual Help Pane">
		<img src="https://lh5.googleusercontent.com/-YujIDW7LMdU/UtDfGcrDjrI/AAAAAAAABfM/EMA4NF3WgYU/s144/admin_page_framework_help_pane.png" alt="Admin Page Framework - Contextual Help Pane" />
	</a>
	&nbsp;
	<a href="https://lh5.googleusercontent.com/-qYgg41nH2_s/VCFc2rSlOQI/AAAAAAAABtg/XQSLHSUX5yA/s0/meta_boxes.png" title="Admin Page Framework - Custom Post Type and Meta Box">
		<img src="https://lh5.googleusercontent.com/-qYgg41nH2_s/VCFc2rSlOQI/AAAAAAAABtg/XQSLHSUX5yA/s144/meta_boxes.png" alt="Admin Page Framework - Custom Post Type and Meta Box" />
	</a>
	&nbsp;
	<a href="https://lh3.googleusercontent.com/-omMuKSVYLPw/VCFc3Kg1okI/AAAAAAAABto/e51rB0qvlC8/s0/page_metabox.png" title="Admin Page Framework - Meta Boxes in Pages Added by the Framework">
		<img src="https://lh3.googleusercontent.com/-omMuKSVYLPw/VCFc3Kg1okI/AAAAAAAABto/e51rB0qvlC8/s144/page_metabox.png" alt="Admin Page Framework - Meta Boxes in Pages Added by the Framework" />
	</a>	
	&nbsp;
	<a href="https://lh6.googleusercontent.com/-FGum6Tjts9k/UtyrddRYdBI/AAAAAAAABhA/LvY_3wgkvyo/s0/form_fields_in_taxonomy_page.png" title="Admin Page Framework - Form Fields in Taxonomy Page">
		<img src="https://lh6.googleusercontent.com/-FGum6Tjts9k/UtyrddRYdBI/AAAAAAAABhA/LvY_3wgkvyo/s144/form_fields_in_taxonomy_page.png" alt="Admin Page Framework - Form Fields in Taxonomy Page" />
	</a>	
	&nbsp;
	<a href="https://lh3.googleusercontent.com/-g-JYTcEDTmQ/VCFc4dXs1_I/AAAAAAAABt8/occvS1fFTBM/s0/sections.png" title="Admin Page Framework - Form Sections in Tabbed Boxes and Repeatable Option">
		<img src="https://lh3.googleusercontent.com/-g-JYTcEDTmQ/VCFc4dXs1_I/AAAAAAAABt8/occvS1fFTBM/s144/sections.png" alt="Admin Page Framework - Form Sections in Tabbed Boxes and Repeatable Option" />
	</a>
	&nbsp;
	<a href="https://lh6.googleusercontent.com/-S8C4xm8BALg/VCFczgOWr6I/AAAAAAAABtE/RTdJuwLOdpI/s0/autocomplete.png" title="Admin Page Framework - Auto-complete Custom Field Type">
		<img src="https://lh6.googleusercontent.com/-S8C4xm8BALg/VCFczgOWr6I/AAAAAAAABtE/RTdJuwLOdpI/s144/autocomplete.png" alt="Admin Page Framework - Auto-complete Custom Field Type" />
	</a>
	&nbsp;
	<a href="https://lh5.googleusercontent.com/-LOY1iOGFSmY/VCMHVoQfwGI/AAAAAAAABuc/V9zdtpWvVbA/s0/widgets.png" title="Admin Page Framework - Widget Form Fields">
		<img src="https://lh5.googleusercontent.com/-LOY1iOGFSmY/VCMHVoQfwGI/AAAAAAAABuc/V9zdtpWvVbA/s144/widgets.png" alt="Admin Page Framework - Widget Form Fields" />
	</a>        
</div>

## Installation ##

There are mainly two ways to include the framework.

- Use the framework loader plugin. 
    - The latest development version can be found [here](https://github.com/michaeluno/admin-page-framework/branches). 
    - The latest stable version can be downloaded [here](http://downloads.wordpress.org/plugin/admin-page-framework.latest-stable.zip).

- 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.

## Example ##

### Create a Page

<p align="center">
	<a href="https://lh5.googleusercontent.com/-v-XvdGmQH1k/Uty9YC3kqwI/AAAAAAAABhk/Ti2R_i6JbhU/s0/my_first_page.png" title="Admin Page Framework - Getting Started">
		<img src="https://lh5.googleusercontent.com/-v-XvdGmQH1k/Uty9YC3kqwI/AAAAAAAABhk/Ti2R_i6JbhU/s400/my_first_page.png" alt="Admin Page Framework - Getting Started" />
	</a>
</p>

```PHP
<?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;
```

### Create a Form

<p align="center">
    <a href="https://lh6.googleusercontent.com/-T5_iUiJAlR8/Uty9YKlpkzI/AAAAAAAABhg/8mcpt6h_XHU/s0/my_first_form.png" title="Admin Page Framework - My First Form">
        <img src="https://lh6.googleusercontent.com/-T5_iUiJAlR8/Uty9YKlpkzI/AAAAAAAABhg/8mcpt6h_XHU/s400/my_first_form.png" alt="Admin Page Framework - My First Form" />
    </a>
</p>

```PHP
<?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`.

## Documentation ##
[Online documentation](http://admin-page-framework.michaeluno.jp/en/v3/)

### Tutorials ###
[Online tutorials](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/)

1. [Create an Admin Page](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/01-create-an-admin-page/)
2. [Create a Form](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/02-create-a-form/)
3. [Create a Page Group](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/03-create-a-page-group/)
4. [Create In-page Tabs](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/04-create-inpage-tabs/)
5. [Organize a Form with Sections](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/05-organize-a-form-with-sections/)
6. [Use Section Tabs and Repeatable Sections](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/06-use-section-tabs-and-repeatable-sections/)
7. [Validate Submitted Form Data of a Single Field](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/07-validate-submitted-form-data-of-a-single-field/)
8. [Validate Submitted Form Data of Multiple Fields](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/08-validate-submitted-form-data-of-multiple-fields/)
9. [Add a Meta Box in an Admin Page](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/09-add-a-meta-box-in-an-admin-page/)
10. [Add a Page Meta Box Specific to an In-page Tab](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/10-add-a-page-meta-box-specific-to-an-in-page-tab/)
11. [Add a Meta Box for Posts](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/11-add-a-meta-box-for-posts/)
12. [Create a Custom Post Type and Custom Taxonomy](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/12-create-a-custom-post-type-and-custom-taxonomy/)
13. [Add a Meta Box to a Custom Post Type](http://en.michaeluno.jp/admin-page-framework/tutorials-v3/13-add-a-meta-box-for-a-custom-post-type/)

## Getting Framework Core Files ##
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"
    }
}
```

## Modifying Framework Core Files ##
The core files are in the `development` directory. 

1. Make sure the constant `WP_DEBUG` is set to `true` in the `wp-config.php` file of your development site. If this is `false`, the loader plugin will load the complied files in the `library` directory.
2. Modify the core files and make sure your changes take effect. 
3. If you add class files, make sure to run `run.sh` in `tool/inclusion_class_list` to generate inclusion file lists.
4. After all the modifications are done, run `php-class-files-beautifier.sh` in `tool/beautifier` to compile the files.

## Bugs ##
If you find an issue, let us know [here](https://github.com/michaeluno/admin-page-framework/issues)!

## Support ##
This is a developer's portal for Admin Page Framework and should _not_ be used for support. Please visit the [support forums](http://wordpress.org/support/plugin/admin-page-framework).

## Contributions ##
Anyone is welcome to contribute to Admin Page Framework. There are various ways you can contribute:

- Try the open [beta version](https://github.com/michaeluno/admin-page-framework/labels/Beta%20Stage) and report issues you encounter.
- Post ideas on [enhancements](https://github.com/michaeluno/admin-page-framework/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open).
- Raise an [Issue](https://github.com/michaeluno/admin-page-framework/issues) on GitHub.
- Send us a Pull Request with your bug fixes and/or new features.
- Write a [custom field type](http://admin-page-framework.michaeluno.jp/en/v3/package-AdminPageFramework.FieldType.html). 
- Write [test cases](test/readme.md).
- Improve the [documentation](https://github.com/michaeluno/admin-page-framework/blob/master/documentation_guideline.md).
- Tweak the styling of the framework page elements by modifying the [CSS rules](https://github.com/michaeluno/admin-page-framework/blob/master/development/_model/AdminPageFramework_CSS.php).
- Translate the language files in the [language](https://github.com/michaeluno/admin-page-framework/tree/master/language) directory to your native language.

## Supporting Future Development ##

If you like the library, please rate and review it in the [WordPress Plugin Directory](http://wordpress.org/support/view/plugin-reviews/admin-page-framework?filter=5). Also donation would be greatly appreciated. Thank you!

[![Donate with PayPal](https://www.paypal.com/en_US/i/btn/x-click-but04.gif)](http://en.michaeluno.jp/donate) 

## Copyright and License ##

### Admin Page Framework (Framework Files)###
Released under the [MIT license](./development/MIT-LICENSE.txt).
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](http://opensource.org/licenses/MIT)

### Admin Page Framework - Loader (WordPress Plugin) ###
Released under the [GPL v2](./LICENSE.txt) 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.