PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.5.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.5.3
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/Core/Platform/Elementor.php +47 -5 3.1.13.5.3 View file →
@@ -94,8 +94,12 @@
94 94 }
95 95 }
96 96
97 97 public function get_saved_templates( $params = [] ) {
98 + if ( ! function_exists( 'is_plugin_active' ) ){
99 + require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
100 + }
101 +
98 102 $_page_number = isset( $params['page'] ) ? intval( $params['page'] ) : 1;
99 103
100 104 $args = [
101 105 'post_type' => 'elementor_library',
@@ -128,11 +132,13 @@
128 132 wp_reset_postdata();
129 133 wp_reset_query();
130 134
131 135 return array(
132 - 'current_page' => $templates->query_vars['paged'],
133 - 'total_page' => $templates->max_num_pages,
134 - 'items' => $templateList,
136 + 'current_page' => $templates->query_vars['paged'],
137 + 'total_page' => $templates->max_num_pages,
138 + 'items' => $templateList,
139 + 'has_elementor' => rest_sanitize_boolean( \is_plugin_active( 'elementor/elementor.php' ) ),
140 + 'has_elementor_pro' => rest_sanitize_boolean( \is_plugin_active( 'elementor-pro/elementor-pro.php' ) ),
135 141 );
136 142 }
137 143
138 144 private function get_export_link( $template_id ) {
@@ -234,9 +240,9 @@
234 240 * @since 2.0.0
235 241 *
236 242 * @return array|WP_Error array on success, WP_Error on failure.
237 243 */
238 - public function create_page( $id, $title, $importer = null ) {
244 + public function create_page( $id, $title, $importer = null, $settings = [] ) {
239 245 $template_data = $importer->get_content( $id );
240 246
241 247 if ( is_wp_error( $template_data ) ) {
242 248 return $template_data;
@@ -241,8 +247,12 @@
241 247 if ( is_wp_error( $template_data ) ) {
242 248 return $template_data;
243 249 }
244 250
251 + if ( ! empty( $settings ) && ! empty( $template_data['content'] ) && is_array( $template_data['content'] ) ) {
252 + $template_data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $template_data['content'], $settings );
253 + }
254 +
245 255 $importer = new ElementorImporter;
246 256 $template_data = $importer->get_data( $template_data );
247 257
248 258 if ( ! empty( $title ) ) {
@@ -275,9 +285,9 @@
275 285 'visit' => get_permalink( $inserted_ID )
276 286 ];
277 287 }
278 288
279 - public function import_in_library( $id, $importer = null ) {
289 + public function import_in_library( $id, $importer = null, $settings = [] ) {
280 290 $template_data = $importer->get_content( $id, 'elementor', 'remote' );
281 291
282 292 if ( is_wp_error( $template_data ) ) {
283 293 return $template_data;
@@ -282,8 +292,12 @@
282 292 if ( is_wp_error( $template_data ) ) {
283 293 return $template_data;
284 294 }
285 295
296 + if ( ! empty( $settings ) && ! empty( $template_data['content'] ) && is_array( $template_data['content'] ) ) {
297 + $template_data['content'] = \Templately\Core\Importer\Utils\ElementorSettingsMerger::merge( $template_data['content'], $settings );
298 + }
299 +
286 300 $importer = new ElementorImporter;
287 301 $imported_template = $importer->import_in_library( $template_data );
288 302
289 303 if( is_wp_error( $imported_template ) ) {
@@ -322,6 +336,34 @@
322 336 public function insert( $data ) {
323 337 $importer = new ElementorImporter();
324 338
325 339 return $importer->get_data( $data );
340 + }
341 +
342 + /**
343 + * Filter Child Type
344 + *
345 + * @param $child_type
346 + * @param $element_data
347 + * @param $element
348 + *
349 + * @return mixed
350 + */
351 + public static function filter_child_type( $child_type, $element_data, $element ) {
352 + // Fix for Elementor Pro Promotion Widget
353 + if ( is_a( $element, 'Elementor\Modules\Promotions\Widgets\Pro_Widget_Promotion' ) || ( is_object( $element ) && 'pro-promotion' === $element->get_name() ) ) {
354 + $el_types = array_keys( Plugin::$instance->elements_manager->get_element_types() );
355 +
356 + if ( isset( $element_data['elType'] ) && in_array( $element_data['elType'], $el_types, true ) ) {
357 + return Plugin::$instance->elements_manager->get_element_types( $element_data['elType'] );
358 + }
359 +
360 + if ( ! isset( $element_data['widgetType'] ) ) {
361 + return null;
362 + }
363 +
364 + return Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
365 + }
366 +
367 + return $child_type;
326 368 }
327 369 }