| 1 |
<?php |
| 2 |
|
| 3 |
namespace YayMail\PostTypes; |
| 4 |
|
| 5 |
use YayMail\Utils\SingletonTrait; |
| 6 |
|
| 7 |
/** |
| 8 |
* Custom Post Type |
| 9 |
* |
| 10 |
* @method static TemplatePostType get_instance() |
| 11 |
*/ |
| 12 |
class TemplatePostType { |
| 13 |
use SingletonTrait; |
| 14 |
|
| 15 |
public const POST_TYPE = 'yaymail_template'; |
| 16 |
|
| 17 |
/** |
| 18 |
* Constructor |
| 19 |
*/ |
| 20 |
protected function __construct() { |
| 21 |
$this->init_hooks(); |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Initialize hooks when class init |
| 26 |
*/ |
| 27 |
protected function init_hooks() { |
| 28 |
// Register Custom Post Type for YayMail Template |
| 29 |
add_action( 'init', [ $this, 'register_template_post_type' ], 20 ); |
| 30 |
} |
| 31 |
|
| 32 |
public function register_template_post_type() { |
| 33 |
$labels = [ |
| 34 |
'name' => __( 'Email Template', 'yaymail' ), |
| 35 |
'singular_name' => __( 'Email Template', 'yaymail' ), |
| 36 |
'add_new' => __( 'Add New Email Template', 'yaymail' ), |
| 37 |
'add_new_item' => __( 'Add a new Email Template', 'yaymail' ), |
| 38 |
'edit_item' => __( 'Edit Email Template', 'yaymail' ), |
| 39 |
'new_item' => __( 'New Email Template', 'yaymail' ), |
| 40 |
'view_item' => __( 'View Email Template', 'yaymail' ), |
| 41 |
'search_items' => __( 'Search Email Template', 'yaymail' ), |
| 42 |
'not_found' => __( 'No Email Template found', 'yaymail' ), |
| 43 |
'not_found_in_trash' => __( 'No Email Template currently trashed', 'yaymail' ), |
| 44 |
'parent_item_colon' => '', |
| 45 |
]; |
| 46 |
$args = [ |
| 47 |
'labels' => $labels, |
| 48 |
'public' => false, |
| 49 |
'publicly_queryable' => false, |
| 50 |
'show_ui' => false, |
| 51 |
'query_var' => true, |
| 52 |
'rewrite' => true, |
| 53 |
'capability_type' => self::POST_TYPE, |
| 54 |
'capabilities' => [], |
| 55 |
'hierarchical' => false, |
| 56 |
'menu_position' => null, |
| 57 |
'exclude_from_search' => true, |
| 58 |
'supports' => [ 'title', 'author', 'thumbnail', 'revisions' ], |
| 59 |
]; |
| 60 |
register_post_type( self::POST_TYPE, $args ); |
| 61 |
} |
| 62 |
} |
| 63 |
|