| @@ -56,12 +56,9 @@ | ||
| 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' ] ); | |
| 61 | 60 | |
| 62 | - add_filter( 'the_content', [$this, 'filter_content'], 10 ,1); | |
| 63 | - | |
| 64 | 61 | self::$theme_compatibility = new ThemeCompatibility(); |
| 65 | 62 | self::$location_manager = new LocationManager( $this ); |
| 66 | 63 | self::$page_template_module = new PageTemplates(); |
| 67 | 64 | } |
| @@ -86,26 +83,13 @@ | ||
| 86 | 83 | public function source_register() { |
| 87 | 84 | self::$templates_manager = new TemplateManager( $this ); |
| 88 | 85 | self::$conditions_manager = new ConditionManager( $this ); |
| 89 | 86 | self::$source = new Source( $this ); |
| 90 | - register_rest_field('templately_library','templately_type', [ | |
| 91 | - 'get_callback' => [ $this, 'get_rest_template_type' ], | |
| 92 | - ]); | |
| 93 | 87 | } |
| 94 | 88 | |
| 95 | - public function get_rest_template_type() { | |
| 96 | - return get_post_meta( get_the_ID(), '_templately_template_type', true ); | |
| 97 | - } | |
| 98 | - | |
| 99 | 89 | public function create_template() { |
| 100 | 90 | check_admin_referer( 'templately_create_template' ); |
| 101 | 91 | |
| 102 | - // Check user capability | |
| 103 | - if (!current_user_can('delete_posts')) { | |
| 104 | - wp_send_json_error(['message' => 'Insufficient permissions']); | |
| 105 | - wp_die(); | |
| 106 | - } | |
| 107 | - | |
| 108 | 92 | $_type = sanitize_text_field( wp_unslash( $_POST['template_type'] ) ); |
| 109 | 93 | |
| 110 | 94 | $_meta = []; |
| 111 | 95 | |
| @@ -199,47 +183,13 @@ | ||
| 199 | 183 | return $post_id; |
| 200 | 184 | } |
| 201 | 185 | |
| 202 | 186 | public function modify_template_type( $value, $object_id, $meta_key, $single ) { |
| 203 | - $_value = $value; | |
| 204 | - if ( empty($value) && Document::TYPE_META_KEY === $meta_key && Source::CPT === get_post_type( $object_id ) ) { | |
| 187 | + if ( Document::TYPE_META_KEY === $meta_key && Source::CPT === get_post_type( $object_id ) ) { | |
| 205 | 188 | remove_filter( 'get_post_metadata', [ $this, 'modify_template_type' ] ); |
| 206 | 189 | $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 | - } | |
| 221 | 190 | } |
| 222 | 191 | |
| 223 | 192 | 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; | |
| 243 | 193 | } |
| 244 | 194 | |
| 245 | 195 | } |