setArguments(
// argument - for the array structure, see http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
array(
'labels' => $this->_getLabels(),
'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', AdminPageFrameworkLoader_Registry::$sFilePath )
)
: 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' => AdminPageFrameworkLoader_Registry::$sDirPath . '/asset/image/wp-logo_32x32.png',
// (framework specific) [3.5.10+] default: true
'show_submenu_add_new' => true,
// (framework specific) [3.7.4+]
'submenu_order_manage' => 5, // default 5
'submenu_order_addnew' => 9, // default 10
)
);
$this->addTaxonomy(
'apf_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' => 'Sample 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)
'show_in_sidebar_menus' => true, // (framework specific)
'submenu_order' => 10, // (framework specific) Default :15
)
);
$this->addTaxonomy(
'apf_second_taxonomy',
array(
'labels' => array(
'name' => 'Non Hierarchical',
'add_new_item' => 'Add New Taxonomy',
'new_item_name' => "New Sample Taxonomy"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => false,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'show_table_filter' => true, // (framework specific)
'show_in_sidebar_menus' => false, // (framework specific)
// 'submenu_order' => 15, // (framework specific)
)
);
}
/**
* @return array
*/
private function _getLabels() {
return $this->oProp->bIsAdmin
? array(
'name' => __( 'APF Demo', 'admin-page-framework-loader' ),
'menu_name' => __( 'APF Demo', 'admin-page-framework-loader' ),
'all_items' => __( 'Manage Sample Posts', 'admin-page-framework-loader' ),
'singular_name' => __( 'APF Demo', 'admin-page-framework-loader' ),
'add_new' => __( 'Add New', 'admin-page-framework-loader' ),
'add_new_item' => __( 'Add New APF Post', 'admin-page-framework-loader' ),
'edit' => __( 'Edit', 'admin-page-framework-loader' ),
'edit_item' => __( 'Edit APF Post', 'admin-page-framework-loader' ),
'new_item' => __( 'New APF Post', 'admin-page-framework-loader' ),
'view' => __( 'View', 'admin-page-framework-loader' ),
'view_item' => __( 'View APF Post', 'admin-page-framework-loader' ),
'search_items' => __( 'Search APF Post', 'admin-page-framework-loader' ),
'not_found' => __( 'No APF Post found', 'admin-page-framework-loader' ),
'not_found_in_trash' => __( 'No APF Post found in Trash', 'admin-page-framework-loader' ),
'parent' => __( 'Parent APF Post', 'admin-page-framework-loader' ),
// (framework specific)
'plugin_action_link' => __( 'APF Posts', 'admin-page-framework-loader' ), // framework specific key. [3.7.3+]
)
: array();
}
/**
* Called when the edit.php page starts loading.
*
* Alternatively you can use the `load_{post type slug}` method and action hook.
*/
public function load() {
$this->setAutoSave( false );
$this->setAuthorTableFilter( true );
add_filter( 'request', array( $this, 'replyToSortCustomColumn' ) );
}
/**
* Inserts a custom string into the left footer.
*
* @callback filter footer_left_{class name}
*/
public function footer_left_APF_PostType( $sHTML ) {
return __( 'Custom left footer text.', 'admin-page-framework-loader' ) . '
'
. $sHTML;
}
/**
* Inserts a custom string into the left footer.
*
* @callback filter footer_left_{class name}
*/
public function footer_right_APF_PostType( $sHTML ) {
return __( 'Custom right footer text.', 'admin-page-framework-loader' ) . '
'
. $sHTML;
}
/*
* Built-in callback methods
*
* @callback filter action_links_{post type slug}
* @return array
*/
public function action_links_apf_posts( $aActionLinks, $oPost ) {
$_sMessage = esc_attr(
__( 'You can embed a custom link with the `action_links_{post type slug}` filter hook.', 'admin-page-framework-loader' )
);
$aActionLinks[] = ""
. __( 'Sample Link', 'admin-page-framework-loader' )
. "";
return $aActionLinks;
}
/*
* Built-in callback methods
*
* @callback filter columns_{post type slug}
*/
public function columns_apf_posts( $aHeaderColumns ) {
return array_merge(
$aHeaderColumns,
array(
'cb' => '', // Checkbox for bulk actions.
'title' => __( 'Title', 'admin-page-framework' ), // Post title. Includes "edit", "quick edit", "trash" and "view" links. If $mode (set from $_REQUEST['mode']) is 'excerpt', a post excerpt is included between the title and links.
'author' => __( 'Author', 'admin-page-framework' ), // Post author.
// 'categories' => __( 'Categories', 'admin-page-framework' ), // Categories the post belongs to.
// 'tags' => __( 'Tags', 'admin-page-framework' ), // Tags for the post.
'comments' => '