register_subscription_post_type();
$this->register_subscription_item_post_type();
$this->register_post_status();
}
/**
* Register ``subscrpt_order`` post type
*/
public function register_subscription_post_type() {
$labels = array(
'name' => __( 'Subscriptions', 'subscription' ),
'singular_name' => __( 'Subscription', 'subscription' ),
'name_admin_bar' => __( 'Subscription\'s', 'subscription' ),
'archives' => __( 'Item Archives', 'subscription' ),
'attributes' => __( 'Item Attributes', 'subscription' ),
'parent_item_colon' => __( 'Parent :', 'subscription' ),
'all_items' => __( 'Subscriptions', 'subscription' ),
'add_new_item' => __( 'Add New Subscription', 'subscription' ),
'add_new' => __( 'Add Subscription', 'subscription' ),
'new_item' => __( 'New Subscription', 'subscription' ),
'edit_item' => __( 'Edit Subscription', 'subscription' ),
'update_item' => __( 'Update Subscription', 'subscription' ),
'view_item' => __( 'View Subscription', 'subscription' ),
'view_items' => __( 'View Subscription', 'subscription' ),
'search_items' => __( 'Search Subscription', 'subscription' ),
'not_found' => __( 'No subscriptions found.', 'subscription' ),
'item_updated' => __( 'Subscription updated.', 'subscription' ),
);
$args = array(
'label' => __( 'Subscriptions', 'subscription' ),
'labels' => $labels,
'description' => '',
'public' => false,
'publicly_queryable' => false,
'show_ui' => true,
'delete_with_user' => false,
'show_in_rest' => true,
'rest_base' => '',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'exclude_from_search' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'capabilities' => array(
'create_posts' => false,
),
'hierarchical' => false,
'rewrite' => array(
'slug' => 'subscrpt_order',
'with_front' => true,
),
'query_var' => true,
'supports' => false,
);
$args = apply_filters( 'subscrpt_order_post_args', $args );
register_post_type( 'subscrpt_order', $args );
}
/**
* Register ``subscrpt_order_item`` post type
*/
public function register_subscription_item_post_type() {
$args = array(
'label' => __( 'Subscription Items', 'subscription' ),
// 'labels' => ,
'description' => '',
'public' => false,
'publicly_queryable' => false,
'show_ui' => false,
'delete_with_user' => false,
'show_in_rest' => true,
'rest_base' => '',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'has_archive' => false,
'show_in_menu' => false,
'show_in_nav_menus' => false,
'exclude_from_search' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'capabilities' => array(
'create_posts' => false,
),
'hierarchical' => false,
'rewrite' => array(
'slug' => 'subscription_item',
'with_front' => false,
),
'query_var' => true,
'supports' => false,
);
$args = apply_filters( 'subscrpt_order_item_post_args', $args );
register_post_type( 'subscrpt_order_item', $args );
}
/**
* Register custom post status.
*
* @return void
*/
public function register_post_status() {
register_post_status(
'pending',
array(
'label' => _x( 'Pending', 'post status label', 'subscription' ),
'public' => true,
// translators: pending posts count.
'label_count' => _n_noop( 'Pending (%s)', 'Pending (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
register_post_status(
'active',
array(
'label' => _x( 'Active', 'post status label', 'subscription' ),
'public' => true,
// translators: active posts count.
'label_count' => _n_noop( 'Active (%s)', 'Active (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
register_post_status(
'on_hold',
array(
'label' => _x( 'On Hold', 'post status label', 'subscription' ),
'public' => true,
// translators: on-hold posts count.
'label_count' => _n_noop( 'On Hold (%s)', 'On Hold (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
register_post_status(
'cancelled',
array(
'label' => _x( 'Cancelled', 'post status label', 'subscription' ),
'public' => true,
// translators: cancelled posts count.
'label_count' => _n_noop( 'Cancelled (%s)', 'Cancelled (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
register_post_status(
'expired',
array(
'label' => _x( 'Expired', 'post status label', 'subscription' ),
'public' => true,
// translators: expired posts count.
'label_count' => _n_noop( 'Expired (%s)', 'Expired (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
register_post_status(
'pe_cancelled',
array(
'label' => _x( 'Pending Cancellation', 'post status label', 'subscription' ),
'public' => true,
// translators: pending cancellation posts count.
'label_count' => _n_noop( 'Pending Cancellation (%s)', 'Pending Cancellation (%s)', 'subscription' ),
'post_type' => array( 'subscrpt_order' ),
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'show_in_metabox_dropdown' => true,
'show_in_inline_dropdown' => true,
'dashicon' => '',
)
);
}
}