PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.8.0
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.8.0
3.8.0 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 All 112 releases
← All changes | includes/Core/Migrator.php +51 -1 3.6.13.8.0 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2
3 3 namespace Templately\Core;
4 4
5 -use Templately\API\Profile;
5 +use Templately\Modules\Auth\REST\Profile;
6 6 use Templately\Utils\Base;
7 7 use Templately\Utils\Options;
8 8
9 9 class Migrator extends Base {
@@ -67,8 +67,58 @@
67 67 if( TEMPLATELY_VERSION !== $_old_version && \version_compare($_old_version, '2.2.10', '<=') ) {
68 68 Profile::get_instance()->sync();
69 69 }
70 70
71 + $this->cleanup_gutenberg_elementor_meta();
72 +
71 73 $this->options->update_option( '_templately_migrate', TEMPLATELY_VERSION );
74 + }
75 +
76 + /**
77 + * One-time cleanup: a bug mapped EVERY `templately_library` template to an Elementor
78 + * document type regardless of platform (the mapping gated on the CPT, not the
79 + * template's platform). Elementor therefore adopted GUTENBERG templates as Elementor
80 + * documents and persisted Elementor meta onto them (`_elementor_edit_mode=builder`,
81 + * `_elementor_template_type`, ...), so they reported `is_built_with_elementor() === true`
82 + * and surfaced Elementor's "Edit with Elementor" UI for a Gutenberg post. The mapping is
83 + * now platform-gated (ThemeBuilder::modify_template_type); strip the already-persisted
84 + * Elementor meta from Gutenberg-platform templates so they are no longer treated as
85 + * Elementor documents. Runs once (own flag), independent of the version gates above.
86 + */
87 + private function cleanup_gutenberg_elementor_meta(){
88 + $flag = '_templately_cleaned_gutenberg_elementor_meta';
89 +
90 + if ( $this->options->get_option( $flag ) ) {
91 + return;
92 + }
93 +
94 + global $wpdb;
95 +
96 + $post_ids = $wpdb->get_col( $wpdb->prepare(
97 + "SELECT p.ID FROM {$wpdb->posts} p
98 + INNER JOIN {$wpdb->postmeta} pm ON pm.post_id = p.ID
99 + WHERE p.post_type = %s AND pm.meta_key = %s AND pm.meta_value = %s",
100 + 'templately_library',
101 + '_templately_template_platform',
102 + 'gutenberg'
103 + ) );
104 +
105 + // Pure-Elementor document meta that must not live on a Gutenberg template.
106 + $meta_keys = [
107 + '_elementor_edit_mode',
108 + '_elementor_template_type',
109 + '_elementor_data',
110 + '_elementor_version',
111 + '_elementor_page_settings',
112 + '_elementor_css',
113 + ];
114 +
115 + foreach ( (array) $post_ids as $post_id ) {
116 + foreach ( $meta_keys as $meta_key ) {
117 + delete_post_meta( (int) $post_id, $meta_key );
118 + }
119 + }
120 +
121 + $this->options->update_option( $flag, time() );
72 122 }
73 123
74 124 }