| 1 |
<?php |
| 2 |
|
| 3 |
namespace ULTP; |
| 4 |
|
| 5 |
|
| 6 |
defined( 'ABSPATH' ) || exit; |
| 7 |
|
| 8 |
class Saved_Templates { |
| 9 |
public function __construct() { |
| 10 |
$this->templates_post_type_callback(); |
| 11 |
add_filter( 'manage_ultp_templates_posts_columns', array( $this, 'templates_table_head' ) ); |
| 12 |
add_action( 'manage_ultp_templates_posts_custom_column', array( $this, 'templates_table_content' ), 10, 2 ); |
| 13 |
} |
| 14 |
|
| 15 |
public function templates_table_head( $defaults ) { |
| 16 |
$type_array = array( 'type' => __( 'Shortcode', 'ultimate-post' ) ); |
| 17 |
array_splice( $defaults, 2, 0, $type_array ); |
| 18 |
return $defaults; |
| 19 |
} |
| 20 |
|
| 21 |
// Column Content |
| 22 |
public function templates_table_content( $column_name, $post_id ) { |
| 23 |
echo '<code class="ultp-shortcode-copy">[postx_template id="' . esc_attr( $post_id ) . '"]</code>'; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
// Templates Post Type Register |
| 28 |
public function templates_post_type_callback() { |
| 29 |
$labels = array( |
| 30 |
'name' => _x( 'Saved Templates', 'Templates', 'ultimate-post' ), |
| 31 |
'singular_name' => _x( 'Saved Template', 'Templates', 'ultimate-post' ), |
| 32 |
'menu_name' => __( 'Saved Templates', 'ultimate-post' ), |
| 33 |
'parent_item_colon' => __( 'Parent Template', 'ultimate-post' ), |
| 34 |
'all_items' => __( 'Saved Templates', 'ultimate-post' ), |
| 35 |
'view_item' => __( 'View Template', 'ultimate-post' ), |
| 36 |
'add_new_item' => __( 'Add New Template', 'ultimate-post' ), |
| 37 |
'add_new' => __( 'Add New Template', 'ultimate-post' ), |
| 38 |
'edit_item' => __( 'Edit Template', 'ultimate-post' ), |
| 39 |
'update_item' => __( 'Update Template', 'ultimate-post' ), |
| 40 |
'search_items' => __( 'Search Template', 'ultimate-post' ), |
| 41 |
'not_found' => __( 'No Template Found', 'ultimate-post' ), |
| 42 |
'not_found_in_trash' => __( 'Not Template found in Trash', 'ultimate-post' ), |
| 43 |
); |
| 44 |
$args = array( |
| 45 |
'labels' => $labels, |
| 46 |
'show_in_rest' => true, |
| 47 |
'supports' => array( 'title', 'editor' ), |
| 48 |
'hierarchical' => false, |
| 49 |
'public' => false, |
| 50 |
'rewrite' => false, |
| 51 |
'show_ui' => true, |
| 52 |
'show_in_menu' => false, |
| 53 |
'show_in_nav_menus' => false, |
| 54 |
'exclude_from_search' => true, |
| 55 |
'capability_type' => 'page', |
| 56 |
); |
| 57 |
register_post_type( 'ultp_templates', $args ); |
| 58 |
} |
| 59 |
} |
| 60 |
|