| 1 |
<?php |
| 2 |
namespace Ens\Flow; |
| 3 |
|
| 4 |
use Ens\Config; |
| 5 |
use Ens\Utils\Helpers; |
| 6 |
|
| 7 |
/** |
| 8 |
* Class FlowCPT |
| 9 |
* |
| 10 |
* @package Ens\Flow |
| 11 |
* |
| 12 |
* @since 1.0.0 |
| 13 |
*/ |
| 14 |
class FlowCPT { |
| 15 |
|
| 16 |
protected $identifier; |
| 17 |
|
| 18 |
/** |
| 19 |
* Register post type. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
* |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
public function register($identifier) { |
| 26 |
$this->identifier = $identifier; |
| 27 |
add_action( 'init', [$this, 'register_post_type'] ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Register post type. |
| 32 |
* |
| 33 |
* @since 1.0.0 |
| 34 |
* |
| 35 |
* @return void |
| 36 |
*/ |
| 37 |
public function register_post_type() { |
| 38 |
$plugin_name = Helpers::get_config_data( $this->identifier,'plugin_name' ); |
| 39 |
$prefix_for_cpt = Helpers::get_config_data( $this->identifier,'general_prefix' ); |
| 40 |
$text_domain = Helpers::get_config_data( $this->identifier,'text_domain' ); |
| 41 |
|
| 42 |
$labels = array( |
| 43 |
'name' => __( $plugin_name . ' Notification Flow', $text_domain ), |
| 44 |
'singular_name' => __( $plugin_name . ' Notification Flow', $text_domain ), |
| 45 |
'menu_name' => __( $plugin_name . ' Notification Flow', $text_domain ), |
| 46 |
'add_new' => __( 'Add New', $text_domain ), |
| 47 |
'add_new_item' => __( 'Add New ' . $plugin_name . ' Notification Flow', $text_domain ), |
| 48 |
'edit' => __( 'Edit', $text_domain ), |
| 49 |
'edit_item' => __( 'Edit ' . $plugin_name . ' Notification Flow', $text_domain ), |
| 50 |
'new_item' => __( 'New ' . $plugin_name . ' Notification Flow', $text_domain ), |
| 51 |
'view' => __( 'View', $text_domain ), |
| 52 |
'view_item' => __( 'View ' . $plugin_name . ' Notification Flow', $text_domain ), |
| 53 |
'search_items' => __( 'Search ' . $plugin_name . ' Notification Flow', $text_domain ), |
| 54 |
'not_found' => __( 'No ' . $plugin_name . ' notification flow found', $text_domain ), |
| 55 |
'not_found' => __( 'No ' . $plugin_name . ' notification flow found', $text_domain ), |
| 56 |
'not_found_in_trash' => __( 'No ' . $plugin_name . ' notification flow found in trash', $text_domain ), |
| 57 |
'parent' => __( 'Parent ' . $plugin_name . ' notification flow', $text_domain ), |
| 58 |
); |
| 59 |
|
| 60 |
$args = array( |
| 61 |
'labels' => $labels, |
| 62 |
'public' => true, |
| 63 |
'publicly_queryable' => true, |
| 64 |
'show_ui' => true, |
| 65 |
'show_in_menu' => false, |
| 66 |
'query_var' => true, |
| 67 |
'rewrite' => array( 'slug' => $prefix_for_cpt . '-flow' ), |
| 68 |
'capability_type' => 'post', |
| 69 |
'has_archive' => true, |
| 70 |
'hierarchical' => false, |
| 71 |
'menu_position' => null, |
| 72 |
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ), |
| 73 |
); |
| 74 |
|
| 75 |
register_post_type( |
| 76 |
$prefix_for_cpt . '-flow', |
| 77 |
$args |
| 78 |
); |
| 79 |
} |
| 80 |
} |
| 81 |
|