WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Admin Page Framework

Provides simpler means of building administration pages for plugin and theme developers.

Getting Started

Step 1 - Include admin-page-framework.min.php

You need to include the library file in your PHP script. The file is located in the library folder of the uncompressed plugin file.

if ( ! class_exists( 'AdminPageFramework' ) ) {
    include_once( dirname( __FILE__ ) . '/library/admin-page-framework.min.php' );
}
Step 2 - Extend the Library Class
class APF_GettingStarted extends AdminPageFramework {
}
Step 3 - Define the setUp() Method
public function setUp() {
    $this->setRootMenuPage( 'Settings' );  // specifies to which parent menu to belong.
    $this->addSubMenuItem(
        array(
            'title'       =>   'My First Page',
            'page_slug'   =>   'myfirstpage',
        )
    ); 
}
Step 4 - Define the Methods for Hooks
public function do_myfirstpage() {  // do_{page slug}    
    ?>
    <h3>Say Something</h3>
    <p>This is my first admin page!</p>
    <?php
}
Step 5 - Instantiate the Class
new APF;
Example Code - Getting Started
<?php
/* Plugin Name: Admin Page Framework - Getting Started */ 

if ( ! class_exists( 'AdminPageFramework' ) ) {
    include_once( dirname( __FILE__ ) . '/library/admin-page-framework.min.php' );
}
    
class APF extends AdminPageFramework {

    public function setUp() {
        
        $this->setRootMenuPage( 'Settings' );  // where to belong
        $this->addSubMenuItem(
            array(
                'title'       =>   'My First Page',
                'page_slug'   =>   'myfirstpage'
            )
        );
            
    }

    public function do_myfirstpage() {  // do_{page slug}
        ?>
        <h3>Say Something</h3>
        <p>This is my first admin page!</p>
        <?php   
    }
    
}
new APF;

Create a Form

<?php
/* Plugin Name: Admin Page Framework - My First Form */ 

if ( ! class_exists( 'AdminPageFramework' ) ) {
    include_once( dirname( __FILE__ ) . '/library/admin-page-framework.min.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.
     */
    public function load_my_first_form( $oAdminPage ) { // load_{page slug}
    
        $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;

Requires: 3.3 or higher
Compatible up to: 3.9.2
Last Updated: 2014-8-13
Downloads: 8,896

Ratings

4 stars
4.6 out of 5 stars

Support

4 of 6 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