Created
June 26, 2015 16:02
-
-
Save davisshaver/57d9f35e1ecae0b34c3f to your computer and use it in GitHub Desktop.
Gist for adding a basic Publishing Checklists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Publishing_Checklist { | |
private static $instance; | |
public static function get_instance() { | |
if ( ! isset( self::$instance ) ) { | |
self::$instance = new Publishing_Checklist; | |
self::$instance->setup_actions(); | |
} | |
return self::$instance; | |
} | |
private function setup_actions() { | |
add_action( 'publishing_checklist_init', array( $this, 'action_publishing_checklist_init' ) ); | |
} | |
/** | |
* Initialize our Publishing Checklist rules | |
*/ | |
public function action_publishing_checklist_init() { | |
$post_types = array( 'post' ); | |
$args = array( | |
'label' => esc_html__( 'Featured Image', 'demo_publishing_checklist' ), | |
'callback' => array( $this, 'validate_demo_checklist_task' ), | |
'explanation' => esc_html__( 'A featured image is required.', 'demo_publishing_checklist' ), | |
'post_type' => $post_types, | |
); | |
Publishing_Checklist()->register_task( 'demo-featured-image', $args ); | |
} | |
/** | |
* Validate a given checklist task | |
*/ | |
public function validate_demo_checklist_task( $post_id, $id ) { | |
switch ( $id ) { | |
case 'demo-featured-image': | |
return has_post_thumbnail( $post_id ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname( __FILE__ ) . '/class-publishing-checklist.php'; | |
Publishing_Checklist::get_instance(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment