Skip to content

Instantly share code, notes, and snippets.

@zanematthew
Created October 6, 2011 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zanematthew/1268641 to your computer and use it in GitHub Desktop.
Save zanematthew/1268641 to your computer and use it in GitHub Desktop.
Sample class
class CustomPostType extends CustomPostTypeBase {
/**
* Every thing that is "custom" to our CPT goes here.
*/
public function __construct() {
$this->dependencies['script'] = array(
'jquery',
'jquery-ui-core',
'jquery-ui-dialog'
);
$this->dependencies['style'] = array(
'tt-base-style'
);
add_action( 'init', array( &$this, 'registerPostType' ) );
add_action( 'init', array( &$this, 'registerTaxonomy' ) );
add_action( 'template_redirect', array( &$this, 'templateRedirect' ) );
/** @todo consider, moving the following to the abstract */
add_action( 'wp_head', array( &$this, 'baseAjaxUrl' ) );
// @todo move to abstract
add_action( 'wp_ajax_loadTemplate', array( &$this, 'loadTemplate' ) );
// @todo move to abstract
add_action( 'wp_ajax_nopriv_loadTemplate', array( &$this, 'loadTemplate' ) ); // for public use
// @todo move to abstract
add_filter( 'post_class', array( &$this, 'addPostClass' ) );
// Only our container divs are loaded, the contents is injected via ajax :)
// @todo createDiv( $element_id=null )
add_action( 'wp_footer', array( &$this, 'createPostTypeDiv' ) );
add_action( 'wp_footer', array( &$this, 'createDeleteDiv' ) );
// @todo see if we can move this to the abstract
add_action( 'wp_ajax_postTypeSubmit', array( &$this, 'postTypeSubmit' ) );
add_action( 'wp_ajax_postTypeUpdate', array( &$this, 'postTypeUpdate' ) );
add_action( 'wp_ajax_postTypeDelete', array( &$this, 'postTypeDelete' ) );
add_action( 'wp_ajax_defaultUtilityUpdate', array( &$this, 'defaultUtilityUpdate' ) );
add_action( 'wp_ajax_addComment', array( &$this, 'addComment' ) );
register_activation_hook( __FILE__, array( &$this, 'regsiterActivation') );
// and so on..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment