\AdminPageFramework_PostType

Provides methods for registering custom post types.

Hooks

The class automatically creates WordPress action and filter hooks associated with the class methods. The class methods corresponding to the name of the below actions and filters can be extended to modify the page output. Those methods are the callbacks of the filters and actions.

Methods and Action Hooks

  • start_ + extended class name – triggered at the end of the class constructor.

Methods and Filter Hooks

  • cell_ + post type + _ + column key – receives the output string for the listing table of the custom post type's post. The first parameter: output string. The second parameter: the post ID.

Remarks

The slugs must not contain a dot(.) or a hyphen(-) since it is used in the callback method name.

Summary

Methods
Properties
Constants
__construct()
setUp()
setColumnHeader()
setSortableColumns()
addStyle()
registerPostType()
registerTaxonomies()
removeTexonomySubmenuPages()
disableAutoSave()
addAuthorTableFilter()
addTaxonomyTableFilter()
setTableFilterQuery()
setColumnCell()
__call()
No public properties found
No constants found
setAutoSave()
addTaxonomy()
setAuthorTableFilter()
setPostTypeArgs()
setFooterInfoLeft()
setFooterInfoRight()
No protected properties found
N/A
getStylesForPostTypeScreenIcon()
No private properties found
N/A

Methods

__construct()

__construct(string $strPostType, array $arrArgs, string $strCallerPath, string $strTextDomain) : void

Constructs the class object, AdminPageFramework_PostType.

Example

new APF_PostType( 'apf_posts', // post type slug array( // argument - for the array structure, refer to http://codex.wordpress.org/Function_Reference/register_post_type#Arguments 'labels' => array( 'name' => 'Admin Page Framework', 'singular_name' => 'Admin Page Framework', 'add_new' => 'Add New', 'add_new_item' => 'Add New APF Post', 'edit' => 'Edit', 'edit_item' => 'Edit APF Post', 'new_item' => 'New APF Post', 'view' => 'View', 'view_item' => 'View APF Post', 'search_items' => 'Search APF Post', 'not_found' => 'No APF Post found', 'not_found_in_trash' => 'No APF Post found in Trash', 'parent' => 'Parent APF Post' ), 'public' => true, 'menu_position' => 110, 'supports' => array( 'title' ), 'taxonomies' => array( '' ), 'menu_icon' => null, 'has_archive' => true, 'show_admin_column' => true, // for custom taxonomies ) );

Parameters

string $strPostType

The post type slug.

array $arrArgs

The argument array passed to register_post_type().

string $strCallerPath

The path of the caller script. This is used to retrieve the script information to insert it into the footer. If not set, the framework tries to detect it.

string $strTextDomain

The text domain of the caller script.

setUp()

setUp()

The method for all necessary set-ups.

Example

public function setUp() { $this->setAutoSave( false ); $this->setAuthorTableFilter( true ); $this->addTaxonomy( 'sample_taxonomy', // taxonomy slug array( // argument - for the argument array keys, refer to : http://codex.wordpress.org/Function_Reference/register_taxonomy#Arguments 'labels' => array( 'name' => 'Genre', 'add_new_item' => 'Add New Genre', 'new_item_name' => "New Genre" ), 'show_ui' => true, 'show_tagcloud' => false, 'hierarchical' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_table_filter' => true, // framework specific key 'show_in_sidebar_menus' => false, // framework specific key ) ); }

setColumnHeader()

setColumnHeader( $arrColumnHeaders) : void

Defines the column header items in the custom post listing table.

Parameters

$arrColumnHeaders

setSortableColumns()

setSortableColumns( $arrColumns)

Defines the sortable column items in the custom post listing table.

Parameters

$arrColumns

addStyle()

addStyle()

registerPostType()

registerPostType()

registerTaxonomies()

registerTaxonomies()

removeTexonomySubmenuPages()

removeTexonomySubmenuPages()

disableAutoSave()

disableAutoSave()

addAuthorTableFilter()

addAuthorTableFilter()

Adds a dorpdown list to filter posts by author, placed above the post type listing table.

addTaxonomyTableFilter()

addTaxonomyTableFilter()

Adds drop-down lists to filter posts by added taxonomies, placed above the post type listing table.

setTableFilterQuery()

setTableFilterQuery( $oQuery)

Parameters

$oQuery

setColumnCell()

setColumnCell( $strColumnTitle,  $intPostID)

Parameters

$strColumnTitle
$intPostID

__call()

__call( $strMethodName,  $arrArgs)

Parameters

$strMethodName
$arrArgs

setAutoSave()

setAutoSave(boolean $fEnableAutoSave)

Enables or disables the auto-save feature in the custom post type's post submission page.

Example

$this->setAutoSave( false );

Parameters

boolean $fEnableAutoSave

If true, it enables the auto-save; othwerwise, it disables it. return void

addTaxonomy()

addTaxonomy(string $strTaxonomySlug, array $arrArgs) : void

Adds a custom taxonomy to the class post type.

Example

$this->addTaxonomy( 'sample_taxonomy', // taxonomy slug array( // argument 'labels' => array( 'name' => 'Genre', 'add_new_item' => 'Add New Genre', 'new_item_name' => "New Genre" ), 'show_ui' => true, 'show_tagcloud' => false, 'hierarchical' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_table_filter' => true, // framework specific key 'show_in_sidebar_menus' => false, // framework specific key ) );

Parameters

string $strTaxonomySlug

The taxonomy slug.

array $arrArgs

The taxonomy argument array passed to the second parameter of the register_taxonomy() function.

setAuthorTableFilter()

setAuthorTableFilter(boolean $fEnableAuthorTableFileter) : void

Sets whether the author dropdown filter is enabled/disabled in the post type post list table.

Example

this->setAuthorTableFilter( true );

Parameters

boolean $fEnableAuthorTableFileter

If true, it enables the author filter; otherwise, it disables it.

setPostTypeArgs()

setPostTypeArgs(array $arrArgs) : void

Sets the post type arguments.

This is only necessary if it is not set to the constructor.

Parameters

array $arrArgs

The array of arguments to be passed to the second parameter of the register_post_type() function.

setFooterInfoLeft()

setFooterInfoLeft(string $strHTML, boolean $fAppend) : void

Sets the given HTML text into the footer on the left hand side.

Example

$this->setFooterInfoLeft( '<br />Custom Text on the left hand side.' );

Parameters

string $strHTML

The HTML code to insert.

boolean $fAppend

If true, the text will be appended; otherwise, it will replace the default text.

setFooterInfoRight()

setFooterInfoRight(string $strHTML, boolean $fAppend) : void

Sets the given HTML text into the footer on the right hand side.

Example

$this->setFooterInfoRight( '<br />Custom Text on the right hand side.' );

Parameters

string $strHTML

The HTML code to insert.

boolean $fAppend

If true, the text will be appended; otherwise, it will replace the default text.

getStylesForPostTypeScreenIcon()

getStylesForPostTypeScreenIcon( $strSRC)

Sets the given screen icon to the post type screen icon.

Parameters

$strSRC