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