| @@ -18,11 +18,18 @@ | ||
| 18 | 18 | |
| 19 | 19 | // Add a filter to the save post to inject out template into the page cache. |
| 20 | 20 | // add_filter( 'wp_insert_post_data', [ $this, 'register_templates' ] ); |
| 21 | 21 | |
| 22 | + } | |
| 23 | + | |
| 24 | + public function get_template() { | |
| 25 | + if(!empty($this->templates)){ | |
| 26 | + return $this->templates; | |
| 27 | + } | |
| 22 | 28 | $this->templates = [ |
| 23 | 29 | self::TEMPLATE_HEADER_FOOTER => __( 'Templately Gutenberg Template', 'templately' ), |
| 24 | 30 | ]; |
| 31 | + return $this->templates; | |
| 25 | 32 | } |
| 26 | 33 | |
| 27 | 34 | public function set_platform( $platform ): PageTemplates { |
| 28 | 35 | $this->platform = $platform; |
| @@ -84,8 +91,11 @@ | ||
| 84 | 91 | |
| 85 | 92 | |
| 86 | 93 | switch ( $page_template ) { |
| 87 | 94 | case self::TEMPLATE_HEADER_FOOTER: |
| 95 | + // removes: Renders a 'viewport' meta tag. | |
| 96 | + remove_action( 'wp_head', '_block_template_viewport_meta_tag', 0 ); | |
| 97 | + | |
| 88 | 98 | if ( $this->platform === 'gutenberg' ) { |
| 89 | 99 | $template_path = $file . 'templates/templately-gutenberg-template.php'; |
| 90 | 100 | } else { |
| 91 | 101 | $template_path = $file . 'templates/header-footer.php'; |
| @@ -106,9 +116,9 @@ | ||
| 106 | 116 | return self::TEMPLATE_HEADER_FOOTER; |
| 107 | 117 | } |
| 108 | 118 | |
| 109 | 119 | public function add_new_template( $posts_templates ) { |
| 110 | - return array_merge( $posts_templates, $this->templates ); | |
| 120 | + return array_merge( $posts_templates, $this->get_template() ); | |
| 111 | 121 | } |
| 112 | 122 | |
| 113 | 123 | public function register_templates( $atts ) { |
| 114 | 124 | |
| @@ -127,9 +137,9 @@ | ||
| 127 | 137 | wp_cache_delete( $cache_key, 'themes' ); |
| 128 | 138 | |
| 129 | 139 | // Now add our template to the list of templates by merging our templates. |
| 130 | 140 | // with the existing templates array from the cache. |
| 131 | - $templates = array_merge( $templates, $this->templates ); | |
| 141 | + $templates = array_merge( $templates, $this->get_template() ); | |
| 132 | 142 | |
| 133 | 143 | // Add the modified cache to allow WordPress to pick it up for listing. |
| 134 | 144 | // available templates. |
| 135 | 145 | wp_cache_add( $cache_key, $templates, 'themes', 1800 ); |