PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.7.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.7.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.php +41 -0 3.6.23.7.3 View file →
@@ -12,5 +12,46 @@
12 12
13 13 // abstract public function get_saved_templates( $params = [] );
14 14 // abstract public function delete( $params = [] );
15 15 abstract public function create_page( $id, $title, $importer = null, $settings = [] );
16 +
17 + /**
18 + * Resolve remote template_type to the correct Builder template type.
19 + * Maps API template types to internal Builder keys with fallback to page_single.
20 + *
21 + * @param array $template_data Template data from API containing 'template_type' key
22 + *
23 + * @return string Builder template type key
24 + */
25 + protected static function resolve_library_type( array $template_data ): string {
26 + $template_type = (string) ( $template_data['template_type'] ?? '' );
27 +
28 + if ( $template_type === '' ) {
29 + throw new \InvalidArgumentException( "template_type is required for library import." );
30 + }
31 +
32 + // Direct match: if the slug is already a registered Builder type key, use it as-is
33 + // (e.g. 'header', 'footer', 'archive', 'search', 'docs_single', 'docs_archive', etc.)
34 + $registered_types = templately()->theme_builder::$templates_manager->get_template_types();
35 + if ( isset( $registered_types[ $template_type ] ) ) {
36 + return $template_type;
37 + }
38 +
39 + // Translation map for API slugs that differ from their Builder type key
40 + $map = [
41 + 'single-post' => 'single',
42 + 'single-doc' => 'docs_single',
43 + 'single-product' => 'product_single',
44 + 'fluent-product-single' => 'fluent_product_single',
45 + 'docs-archive' => 'docs_archive',
46 + 'course-archive' => 'course_archive',
47 + 'product-archive' => 'product_archive',
48 + '404' => 'error',
49 + ];
50 +
51 + if ( isset( $map[ $template_type ] ) ) {
52 + return $map[ $template_type ];
53 + }
54 +
55 + throw new \InvalidArgumentException( "Unknown template_type '{$template_type}' — no matching Builder type." );
56 + }
16 57 }