Admin Page Framework Documentation

Packages

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

Classes

  • AdminPageFramework_PostType
  • AdminPageFramework_PostType_Controller
  • AdminPageFramework_PostType_View

Resources

  • Tutorials
  • Support
  • Reporting Issues

Class AdminPageFramework_PostType

Provides methods for registering custom post types.

Abstract
Package: AdminPageFramework\Factory\PostType
Since: 2.0.0
Located at factory/post_type/AdminPageFramework_PostType.php

Methods summary

public
# __construct( string $sPostType, array $aArguments = array(), string $sCallerPath = null, string $sTextDomain = 'admin-page-framework' )

The constructor of the class object.

Registers necessary hooks and sets up internal properties.

Example

new APF_PostType(
    'apf_posts',     // post type slug
      array(
          'labels' => array(
              'name'               => 'Demo',
              'all_items'          => __( 'Sample Posts', 'admin-page-framework-demo' ),
              'singular_name'      => 'Demo',
              'add_new'            => __( 'Add New', 'admin-page-framework-demo' ),
              'add_new_item'       => __( 'Add New APF Post', 'admin-page-framework-demo' ),
              'edit'               => __( 'Edit', 'admin-page-framework-demo' ),
              'edit_item'          => __( 'Edit APF Post', 'admin-page-framework-demo' ),
              'new_item'           => __( 'New APF Post', 'admin-page-framework-demo' ),
              'view'               => __( 'View', 'admin-page-framework-demo' ),
              'view_item'          => __( 'View APF Post', 'admin-page-framework-demo' ),
              'search_items'       => __( 'Search APF Post', 'admin-page-framework-demo' ),
              'not_found'          => __( 'No APF Post found', 'admin-page-framework-demo' ),
              'not_found_in_trash' => __( 'No APF Post found in Trash', 'admin-page-framework-demo' ),
              'parent'             => __( 'Parent APF Post', 'admin-page-framework-demo' ),

              // (framework specific)
              'plugin_action_link' => __( 'APF Posts', 'admin-page-framework-demo' ), // framework specific key. [3.7.3+]
          ),
          'public'            => true,
          'menu_position'     => 110,
          'supports'          => array( 'title' ), // e.g. array( 'title', 'editor', 'comments', 'thumbnail', 'excerpt' ),
          'taxonomies'        => array( '' ),
          'has_archive'       => true,
          'show_admin_column' => true, // [3.5+ core] this is for custom taxonomies to automatically add the column in the listing table.
          'menu_icon'         => $this->oProp->bIsAdmin
              ? (
                  version_compare( $GLOBALS['wp_version'], '3.8', '>=' )
                      ? 'dashicons-wordpress'
                      : plugins_url( 'asset/image/wp-logo_16x16.png', APFDEMO_FILE )
              )
              : null, // do not call the function in the front-end.

          // (framework specific) this sets the screen icon for the post type for WordPress v3.7.1 or below.
          // a file path can be passed instead of a url, plugins_url( 'asset/image/wp-logo_32x32.png', APFDEMO_FILE )
          'screen_icon' => dirname( APFDEMO_FILE  ) . '/asset/image/wp-logo_32x32.png',

          // [3.5.10+] (framework specific) default: true
          'show_submenu_add_new'  => true,

          // [3.7.4+] (framework specific) default: 10
          'submenu_order_manage'  => 20,
          'submenu_order_addnew'  => 21,

      )
);

Framework Specific Post Type Arguments

In addition to the post type argument structure defined by the WordPress core, there are arguments defined by the framework.
  • screen_icon - For WordPress 3.7.x or below, set an icon url or path for the 32x32 screen icon displayed in the post listing page.
  • show_submenu_add_new - [3.5.10+] (boolean) Whether the sub-menu item of Add New should be displayed.
  • submenu_order_manage - [3.7.4+] (numeric) The menu position of the Manage sub-menu item which gets automatically crated by the system when the admin ui is enabled. Default: 5
  • submenu_order_addnew - [3.7.4+] (numeric) The menu position of the Manage sub-menu item which gets automatically crated by the system when the admin ui is enabled. Default: 10

Framework Specific Post Type Label Arguments

  • plugin_listing_table_title_cell_link' - [3.0.6+] Deprecated [3.7.3] use the plugin_action_link argument instead.
  • plugin_action_link' - [3.7.3+] If the caller script is a plugin, this determines the label of the action link embedded in the plugin listing page (plugins.php).

To disable the action link, set an empty string ''.

Parameters

$sPostType
string
The post type slug.
$aArguments
array
The argument array passed to register_post_type().
$sCallerPath
string
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.
$sTextDomain
string
The text domain of the caller script.

Since

2.0.0
2.1.6 Added the $sTextDomain parameter.

See

http://codex.wordpress.org/Function_Reference/register_post_type#Arguments

Magic methods summary

Properties summary

Related

If you find undocumented functionality, please report it here.

Admin Page Framework