PluginProbe ʕ •ᴥ•ʔ
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More / 3.4.2
Superb Addons: Blocks, Patterns, Pre-built Pages, Sliders, Popups, Free Forms, Animations & More v3.4.2
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 1 year ago class-addons-template-util.php 1 year ago class-base-exception.php 1 year ago class-cache-constants.php 1 year ago class-cache-exception.php 1 year ago class-key-exception.php 1 year ago class-keytypes.php 1 year ago class-option-exception.php 1 year ago class-quiet-skin.php 1 year ago class-request-exception.php 1 year ago class-script-translations.php 1 year ago class-settings-exception.php 1 year ago class-theme-installer.php 1 year ago
class-addons-template-util.php
81 lines
1 <?php
2
3 namespace SuperbAddons\Data\Utils\Wizard;
4
5 use WP_Block_Template;
6
7 defined('ABSPATH') || exit();
8
9 class AddonsPageTemplateUtil
10 {
11 const TEMPLATE_ID = 'superbaddons-page-template';
12 const PLUGIN_SLUG = 'superb-blocks/plugin';
13
14 public static function GetAddonsPageBlockTemplateObject()
15 {
16 $template_content = false;
17 $template_source = "plugin";
18
19 $template = new WP_Block_Template();
20 $template->type = WizardItemTypes::WP_TEMPLATE;
21 $template->theme = self::PLUGIN_SLUG;
22 $template->slug = self::TEMPLATE_ID;
23 $template->id = self::PLUGIN_SLUG . '//' . self::TEMPLATE_ID;
24 $template->title = __("Superb Addons Template Page", "superb-blocks");
25 $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");
26 $template->origin = 'plugin';
27 $template->status = 'publish';
28 $template->has_theme_file = true;
29 $template->is_custom = true;
30 $template->post_types = ['page'];
31
32 // Get the saved custom template from the database if it exists.
33 $custom_template_query_args = array(
34 'post_type' => WizardItemTypes::WP_TEMPLATE,
35 'posts_per_page' => 1,
36 'name' => self::TEMPLATE_ID,
37 'no_found_rows' => true,
38 'tax_query' => array(
39 array(
40 'taxonomy' => 'wp_theme',
41 'field' => 'name',
42 'terms' => array(self::PLUGIN_SLUG, get_stylesheet()),
43 ),
44 ),
45 );
46
47 $custom_template_query = new \WP_Query($custom_template_query_args);
48 $custom_superb_templates = $custom_template_query->posts;
49
50 if ($custom_superb_templates && !empty($custom_superb_templates)) {
51 $template_content = $custom_superb_templates[0]->post_content;
52 $template_source = "custom";
53 } else {
54 $page_content = '<!-- wp:post-content {"align":"full","layout":{"type":"default"},"lock":{"move":true,"remove":true}} /-->';
55 $template_content = self::GetAddonsPageTemplateContent($page_content);
56 }
57
58 $template->source = $template_source;
59 $template->content = $template_content;
60
61 return $template;
62 }
63
64 public static function GetAddonsPageTemplateContent($page_content)
65 {
66 ob_start();
67 ?>
68 <!-- wp:template-part {"slug":"header","lock":{"move":true,"remove":true}} /-->
69
70 <!-- 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"}} -->
71 <main class="wp-block-group" style="margin-top:0rem;padding-top:0;padding-right:0;padding-bottom:0;padding-left:0">
72 <?= $page_content ?>
73 </main>
74 <!-- /wp:group -->
75
76 <!-- wp:template-part {"slug":"footer","lock":{"move":true,"remove":true}} /-->
77 <?php
78 return ob_get_clean();
79 }
80 }
81