Admin Page Framework Documentation

Packages

  • AdminPageFramework
    • Common
      • Factory
      • Form
        • FieldType
      • Utility
    • Factory
      • AdminPage
      • MetaBox
      • NetworkAdmin
      • PageMetaBox
      • PostType
      • TaxonomyField
      • TermMeta
      • UserMeta
      • Widget
    • Utility

Classes

  • AdminPageFramework_Widget
  • AdminPageFramework_Widget_Controller
  • AdminPageFramework_Widget_View

Resources

  • Tutorials
  • Support
  • Reporting Issues

Widget

Widget

Widget

Provides an abstract base to create widgets and their forms.

This factory class lets the user create a widget and define the outputs based on the form field inputs.

Creating a Widget and Form Fields

  1. Extend the AdminPageFramework_Widget factory class.
  2. Define the form in AdminPageFramework_Widget_Controller::load() method. By adding a text field with the field ID of title, a title output will be inserted above the widget output in the front end defined in the content() method.
  3. Instantiate the class by passing the widget title in the first parameter.

Displaying Widget Contents by Retrieving Widget Form Data

Define the front-end output of the widget in AdminPageFramework_Widget_View::content() method.

Example

class APFDoc_ExampleWidget extends AdminPageFramework_Widget {

    public function load( $oAdminWidget ) {

        $this->addSettingFields(
            array(
                'field_id'      => 'title',
                'type'          => 'text',
                'title'         => 'Title',
            ),
            array(
                'field_id'      => 'image',
                'type'          => 'image',
                'title'         => 'Image',
            )
        );

    }

    public function content( $sContent, $aArguments, $aFormData ) {

        $_sImageURL = esc_url( $this->oUtil->getElement( $aFormData, 'image' ) );
        return $sContent
            . "<img src='{$_sImageURL}' />";

    }

}
new APFDoc_ExampleWidget(
    'APF Documentation Example',    // widget title
    array(
        'description'   => 'Shows an image.',
    )
);

Hooks

See the Hooks section of the Factory package summary page.

Classes

AdminPageFramework_Widget Provides methods for creating widgets.
AdminPageFramework_Widget_Controller Provides methods of views for the widget factory class.
AdminPageFramework_Widget_View Provides methods of views for the widget factory class.

If you find undocumented functionality, please report it here.

Admin Page Framework