PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.2.5
Post Grid Gutenberg Blocks – PostX v2.2.5
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 5.0.17 2.1.1 All 238 releases
ultimate-post / addons / templates / Saved_Templates.php

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

82 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP;
3
4 defined('ABSPATH') || exit;
5
6 class Saved_Templates {
7 public function __construct(){
8 $this->templates_post_type_callback();
9 add_action('admin_head', array($this, 'custom_head_templates'));
10 add_action('load-post-new.php', array($this, 'disable_new_post_templates'));
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 custom_head_templates() {
16 if( 'ultp_templates' == get_current_screen()->post_type && (!defined('ULTP_PRO_VER')) ) {
17 $post_count = wp_count_posts('ultp_templates');
18 $post_count = $post_count->publish + $post_count->draft;
19 if( $post_count > 0 ) { ?>
20 <span class="ultp-saved-templates-action" data-link="<?php echo ultimate_post()->get_premium_link(); ?>" data-text="Go Pro for Unlimited Templates" data-count="<?php echo $post_count; ?>" style="display:none;"></span>
21 <?php }
22 }
23 }
24
25 public function disable_new_post_templates() {
26 if ( get_current_screen()->post_type == 'ultp_templates' && (!defined('ULTP_PRO_VER')) ){
27 $post_count = wp_count_posts('ultp_templates');
28 $post_count = $post_count->publish + $post_count->draft;
29 if ($post_count > 0) {
30 wp_die( 'You are not allowed to do that! Please <a target="_blank" href="'.ultimate_post()->get_premium_link().'">Upgrade Pro.</a>' );
31 }
32 }
33 }
34
35 // Template Heading Add
36 public function templates_table_head( $defaults ) {
37 $type_array = array('type' => __('Shortcode', 'ultimate-post'));
38 array_splice( $defaults, 2, 0, $type_array );
39 return $defaults;
40 }
41
42 // Column Content
43 public function templates_table_content( $column_name, $post_id ) {
44 if ($column_name == 'shortcode') {
45 echo '<code>[gutenberg_post_blocks id="'.$post_id.'"]</code>';
46 }
47 }
48
49
50 // Templates Post Type Register
51 public function templates_post_type_callback() {
52 $labels = array(
53 'name' => _x( 'Saved Templates', 'Templates', 'ultimate-post' ),
54 'singular_name' => _x( 'Saved Template', 'Templates', 'ultimate-post' ),
55 'menu_name' => __( 'Saved Templates', 'ultimate-post' ),
56 'parent_item_colon' => __( 'Parent Template', 'ultimate-post' ),
57 'all_items' => __( 'Saved Templates', 'ultimate-post' ),
58 'view_item' => __( 'View Template', 'ultimate-post' ),
59 'add_new_item' => __( 'Add New Template', 'ultimate-post' ),
60 'add_new' => __( 'Add New Template', 'ultimate-post' ),
61 'edit_item' => __( 'Edit Template', 'ultimate-post' ),
62 'update_item' => __( 'Update Template', 'ultimate-post' ),
63 'search_items' => __( 'Search Template', 'ultimate-post' ),
64 'not_found' => __( 'No Template Found', 'ultimate-post' ),
65 'not_found_in_trash' => __( 'Not Template found in Trash', 'ultimate-post' ),
66 );
67 $args = array(
68 'labels' => $labels,
69 'show_in_rest' => true,
70 'supports' => array( 'title', 'editor' ),
71 'hierarchical' => false,
72 'public' => false,
73 'rewrite' => false,
74 'show_ui' => true,
75 'show_in_menu' => 'ultp-settings',
76 'show_in_nav_menus' => false,
77 'exclude_from_search' => true,
78 'capability_type' => 'page',
79 );
80 register_post_type( 'ultp_templates', $args );
81 }
82 }