Admin Page Framework Documentation
  • Package
  • Class
  • Tree

Packages

  • AdminPageFramework
    • FieldType
    • MetaBox
    • NetworkAdmin
      • Page
    • Page
    • PageMetaBox
    • PostType
    • TaxonomyField
  • None

Classes

  • AdminPageFramework_PostType
  • AdminPageFramework_PostType_Controller
  • AdminPageFramework_PostType_Model
  • AdminPageFramework_PostType_Router
  • AdminPageFramework_PostType_View
  1 <?php
  2 /**
  3  * Admin Page Framework
  4  * 
  5  * http://en.michaeluno.jp/admin-page-framework/
  6  * Copyright (c) 2013-2014 Michael Uno; Licensed MIT
  7  * 
  8  */
  9 if ( ! class_exists( 'AdminPageFramework_PostType' ) ) :
 10 /**
 11  * Provides methods for registering custom post types.
 12  * 
 13  * <h2>Hooks</h2>
 14  * <p>The class automatically creates WordPress action and filter hooks associated with the class methods.
 15  * 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.</p>
 16  * <h3>Methods and Action Hooks</h3>
 17  * <ul>
 18  *     <li><strong>start_{instantiated class name}</strong> – triggered at the end of the class constructor. This receives the class object in the first parameter.</li>
 19  *     <li><strong>set_up_{instantiated class name}</strong> – triggered after the setUp() method is called. This receives the class object in the first parameter.</li>
 20  * </ul>
 21  * <h3>Methods and Filter Hooks</h3>
 22  * <ul>
 23  *     <li><strong>cell_{post type slug}_{column key}</strong> – 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.</li>
 24  *     <li><strong>columns_{post type slug}</strong> – receives the array containing the header columns for the listing table of the custom post type's post. The first parameter: the header columns container array.</li>
 25  *     <li><strong>sortable_columns_{post type slug}</strong> – receives the array containing the sortable header column array for the listing table of the custom post type's post. The first parameter: the sortable header columns container array.</li>
 26  * </ul>
 27  * <h3>Remarks</h3>
 28  * <p>The slugs must not contain a dot(.) or a hyphen(-) since it is used in the callback method name.</p> 
 29  * 
 30  * @abstract
 31  * @since 2.0.0
 32  * @package AdminPageFramework
 33  * @subpackage PostType
 34  */
 35 abstract class AdminPageFramework_PostType extends AdminPageFramework_PostType_Controller {    
 36         
 37     /**
 38     * The constructor of the class object.
 39     * 
 40     * Registers necessary hooks and sets up internal properties.
 41     * 
 42     * <h4>Example</h4>
 43     * <code>new APF_PostType( 
 44     *     'apf_posts',     // post type slug
 45     *     array( // argument - for the array structure, refer to http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
 46     *         'labels' => array(
 47     *             'name' => 'Admin Page Framework',
 48     *             'singular_name' => 'Admin Page Framework',
 49     *             'add_new' => 'Add New',
 50     *             'add_new_item' => 'Add New APF Post',
 51     *             'edit' => 'Edit',
 52     *             'edit_item' => 'Edit APF Post',
 53     *             'new_item' => 'New APF Post',
 54     *             'view' => 'View',
 55     *             'view_item' => 'View APF Post',
 56     *             'search_items' => 'Search APF Post',
 57     *             'not_found' => 'No APF Post found',
 58     *             'not_found_in_trash' => 'No APF Post found in Trash',
 59     *             'parent' => 'Parent APF Post'
 60     *         ),
 61     *         'public' => true,
 62     *         'menu_position' => 110,
 63     *         'supports' => array( 'title' ),
 64     *         'taxonomies' => array( '' ),
 65     *         'menu_icon' => null,
 66     *         'has_archive' => true,
 67     *         'show_admin_column' => true, // for custom taxonomies
 68     *     )     
 69     * );</code>
 70     * @since 2.0.0
 71     * @since 2.1.6 Added the $sTextDomain parameter.
 72     * @see http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
 73     * @param string The post type slug.
 74     * @param array The <a href="http://codex.wordpress.org/Function_Reference/register_post_type#Arguments">argument array</a> passed to register_post_type().
 75     * @param 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.
 76     * @param string The text domain of the caller script.
 77     * @return void
 78     */
 79     public function __construct( $sPostType, $aArgs=array(), $sCallerPath=null, $sTextDomain='admin-page-framework' ) {
 80         
 81         if ( empty( $sPostType ) ) return;
 82 
 83         // Properties
 84         $this->oProp = new AdminPageFramework_Property_PostType( 
 85             $this, 
 86             $sCallerPath ? trim( $sCallerPath ) : ( 
 87                 ( is_admin() && isset( $GLOBALS['pagenow'] ) && in_array( $GLOBALS['pagenow'], array( 'edit.php', 'post.php', 'post-new.php', 'plugins.php', 'tags.php', 'edit-tags.php', ) ) )
 88                     ? AdminPageFramework_Utility::getCallerScriptPath( __FILE__ ) 
 89                     : null 
 90                 ),     // this is important to attempt to find the caller script path here when separating the library into multiple files.    
 91             get_class( $this ), // class name
 92             'post', // capability
 93             $sTextDomain, // text domain
 94             'post_type' // fields type
 95         );
 96         $this->oProp->sPostType = AdminPageFramework_WPUtility::sanitizeSlug( $sPostType );
 97         $this->oProp->aPostTypeArgs = $aArgs; // for the argument array structure, refer to http://codex.wordpress.org/Function_Reference/register_post_type#Arguments
 98 
 99         parent::__construct( $this->oProp );
100                 
101         $this->oUtil->addAndDoAction( $this, "start_{$this->oProp->sClassName}", $this );
102                             
103     }
104                 
105 }
106 endif;
Admin Page Framework Documentation API documentation generated by ApiGen 2.8.0