PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.9
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.9
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Builder/ThemeBuilder.php +51 -1 3.0.43.1.9 View file →
@@ -56,9 +56,12 @@
56 56 add_action( 'wp_ajax_templately_create_template', [ $this, 'create_template' ] );
57 57
58 58 add_filter( 'elementor/document/config', [$this, 'elementor_document_config'], 10, 2 );
59 59 add_filter( 'elementor/documents/get/post_id', [$this, 'elementor_documents_get_post_id'] );
60 + add_action( 'elementor/widgets/register', [ $this, 'register_elements' ] );
60 61
62 + add_filter( 'the_content', [$this, 'filter_content'], 10 ,1);
63 +
61 64 self::$theme_compatibility = new ThemeCompatibility();
62 65 self::$location_manager = new LocationManager( $this );
63 66 self::$page_template_module = new PageTemplates();
64 67 }
@@ -83,13 +86,26 @@
83 86 public function source_register() {
84 87 self::$templates_manager = new TemplateManager( $this );
85 88 self::$conditions_manager = new ConditionManager( $this );
86 89 self::$source = new Source( $this );
90 + register_rest_field('templately_library','templately_type', [
91 + 'get_callback' => [ $this, 'get_rest_template_type' ],
92 + ]);
87 93 }
88 94
95 + public function get_rest_template_type() {
96 + return get_post_meta( get_the_ID(), '_templately_template_type', true );
97 + }
98 +
89 99 public function create_template() {
90 100 check_admin_referer( 'templately_create_template' );
91 101
102 + // Check user capability
103 + if (!current_user_can('delete_posts')) {
104 + wp_send_json_error(['message' => 'Insufficient permissions']);
105 + wp_die();
106 + }
107 +
92 108 $_type = sanitize_text_field( wp_unslash( $_POST['template_type'] ) );
93 109
94 110 $_meta = [];
95 111
@@ -183,13 +199,47 @@
183 199 return $post_id;
184 200 }
185 201
186 202 public function modify_template_type( $value, $object_id, $meta_key, $single ) {
187 - if ( Document::TYPE_META_KEY === $meta_key && Source::CPT === get_post_type( $object_id ) ) {
203 + $_value = $value;
204 + if ( empty($value) && Document::TYPE_META_KEY === $meta_key && Source::CPT === get_post_type( $object_id ) ) {
188 205 remove_filter( 'get_post_metadata', [ $this, 'modify_template_type' ] );
189 206 $value = get_post_meta( $object_id, Source::TYPE_META_KEY, $single );
207 + $arr = [
208 + 'post' => 'single-post',
209 + 'page' => 'single-page',
210 + 'error' => 'error-404',
211 + 'product_single' => 'product',
212 + 'product_archive' => 'product-archive',
213 + 'course_single' => 'single-post',
214 + 'course_archive' => 'archive',
215 + ];
216 + $key = $single ? $value : (isset($value[0]) ? $value[0] : '');
217 + $value = isset( $arr[ $key ] ) ? $arr[ $key ] : $value;
218 + if(in_array($value, ['header', 'footer'])){
219 + return $_value;
220 + }
190 221 }
191 222
192 223 return $value;
224 + }
225 +
226 + public function register_elements( $widgets_manager ) {
227 + $widgets_manager->register( new \Templately\Builder\Widgets\Post_Title() );
228 + $widgets_manager->register( new \Templately\Builder\Widgets\Post_Content() );
229 + $widgets_manager->register( new \Templately\Builder\Widgets\Featured_Image() );
230 + $widgets_manager->register( new \Templately\Builder\Widgets\Site_Logo() );
231 + }
232 +
233 + public function filter_content( $content ) {
234 + if(is_singular()){
235 + global $post;
236 + if(!empty($post) && $post->post_type === 'templately_library'){
237 + if(in_array(get_post_meta($post->ID, '_templately_template_type', true), ['header', 'footer'])){
238 + return '';
239 + }
240 + }
241 + }
242 + return $content;
193 243 }
194 244
195 245 }