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
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
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 {

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

    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 {

    function setUp() {
        
        $this->setRootMenuPage( 'My Settings' );   // create a root page 
        $this->addSubMenuItem(
            array(
                'title' => 'My First Form',
                '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;

Requires: 3.3 or higher
Compatible up to: 3.9.1
Last Updated: 2014-7-17
Downloads: 8,369

Ratings

4 stars
4.6 out of 5 stars

Support

3 of 5 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

1 person says 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