PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.6.1
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.6.1
4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 trunk 1.0.0 2.0.0 2.0.1 2.0.2 2.0.3 3.0 3.0.1 3.0.2 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 3.6.1 3.6.2 3.7.0 3.7.1
superb-blocks / src / data / utils / class-addons-template-util.php
superb-blocks / src / data / utils Last commit date
wizard 11 months ago class-addons-template-util.php 11 months ago class-allowed-template-html-util.php 11 months ago class-base-exception.php 11 months ago class-cache-constants.php 11 months ago class-cache-exception.php 11 months ago class-key-exception.php 11 months ago class-keytypes.php 11 months ago class-option-exception.php 11 months ago class-quiet-skin.php 11 months ago class-request-exception.php 11 months ago class-script-translations.php 11 months ago class-settings-exception.php 11 months ago class-theme-installer-exception.php 11 months ago class-theme-installer.php 11 months ago
class-addons-template-util.php
82 lines
1 <?php
2
3 namespace SuperbAddons\Data\Utils\Wizard;
4
5 use SuperbAddons\Data\Utils\AllowedTemplateHTMLUtil;
6 use WP_Block_Template;
7
8 defined('ABSPATH') || exit();
9
10 class AddonsPageTemplateUtil
11 {
12 const TEMPLATE_ID = 'superbaddons-page-template';
13 const PLUGIN_SLUG = 'superb-blocks/plugin';
14
15 public static function GetAddonsPageBlockTemplateObject()
16 {
17 $template_content = false;
18 $template_source = "plugin";
19
20 $template = new WP_Block_Template();
21 $template->type = WizardItemTypes::WP_TEMPLATE;
22 $template->theme = self::PLUGIN_SLUG;
23 $template->slug = self::TEMPLATE_ID;
24 $template->id = self::PLUGIN_SLUG . '//' . self::TEMPLATE_ID;
25 $template->title = __("Superb Addons Template Page", "superb-blocks");
26 $template->description = __("This is a basic full width page template that includes a header and footer. This template is used when creating template pages in Superb Addons.", "superb-blocks");
27 $template->origin = 'plugin';
28 $template->status = 'publish';
29 $template->has_theme_file = true;
30 $template->is_custom = true;
31 $template->post_types = ['page'];
32
33 // Get the saved custom template from the database if it exists.
34 $custom_template_query_args = array(
35 'post_type' => WizardItemTypes::WP_TEMPLATE,
36 'posts_per_page' => 1,
37 'name' => self::TEMPLATE_ID,
38 'no_found_rows' => true,
39 'tax_query' => array(
40 array(
41 'taxonomy' => 'wp_theme',
42 'field' => 'name',
43 'terms' => array(self::PLUGIN_SLUG, get_stylesheet()),
44 ),
45 ),
46 );
47
48 $custom_template_query = new \WP_Query($custom_template_query_args);
49 $custom_superb_templates = $custom_template_query->posts;
50
51 if ($custom_superb_templates && !empty($custom_superb_templates)) {
52 $template_content = $custom_superb_templates[0]->post_content;
53 $template_source = "custom";
54 } else {
55 $page_content = '<!-- wp:post-content {"align":"full","layout":{"type":"default"},"lock":{"move":true,"remove":true}} /-->';
56 $template_content = self::GetAddonsPageTemplateContent($page_content);
57 }
58
59 $template->source = $template_source;
60 $template->content = $template_content;
61
62 return $template;
63 }
64
65 public static function GetAddonsPageTemplateContent($page_content)
66 {
67 $template = '<!-- wp:template-part {"slug":"header","lock":{"move":true,"remove":true}} /-->' . "\n";
68 $template .= '<!-- wp:group {"tagName":"main","lock":{"move":true,"remove":true},"style":{"spacing":{"margin":{"top":"0rem"},"padding":{"top":"0","bottom":"0","left":"0","right":"0"},"blockGap":"var:preset|spacing|superbspacing-medium"}},"layout":{"type":"default"}} -->' . "\n";
69 $template .= '<main class="wp-block-group" style="margin-top:0rem;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0">' . "\n";
70
71 AllowedTemplateHTMLUtil::enable_safe_styles();
72 $template .= wp_kses($page_content, "post");
73 AllowedTemplateHTMLUtil::disable_safe_styles();
74
75 $template .= '</main>' . "\n";
76 $template .= '<!-- /wp:group -->' . "\n";
77 $template .= '<!-- wp:template-part {"slug":"footer","lock":{"move":true,"remove":true}} /-->';
78
79 return $template;
80 }
81 }
82