PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
5.1.1 5.1.0 5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 All 240 releases
ultimate-post / addons / templates / Saved_Templates.php

Saved_Templates.php in Post Grid Gutenberg Blocks – PostX 5.1.1, at addons/templates/Saved_Templates.php

60 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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