Importers
2 months ago
Admin.php
1 week ago
Editor.php
1 year ago
Elementor.php
1 year ago
License.php
1 year ago
Logger.php
2 years ago
Main.php
1 week ago
Rest_Server.php
2 weeks ago
Sites_Listing.php
2 weeks ago
Starter_Ranking.php
1 week ago
TI_Beaver.php
1 year ago
WP_Cli.php
3 months ago
White_Label_Config.php
3 years ago
Elementor.php
156 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Handles code for Elementor. |
| 4 | * |
| 5 | * @package templates-patterns-collection |
| 6 | */ |
| 7 | |
| 8 | namespace TIOB; |
| 9 | |
| 10 | use TIOB\Main; |
| 11 | |
| 12 | /** |
| 13 | * Class Editor |
| 14 | * |
| 15 | * @package templates-patterns-collection |
| 16 | */ |
| 17 | class Elementor { |
| 18 | use White_Label_Config; |
| 19 | |
| 20 | /** |
| 21 | * Initialize the Admin. |
| 22 | */ |
| 23 | public function init() { |
| 24 | $this->setup_white_label(); |
| 25 | |
| 26 | if ( $this->is_library_disabled() ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'register_script' ), 999 ); |
| 31 | add_action( 'elementor/editor/before_enqueue_styles', array( $this, 'register_style' ) ); |
| 32 | add_action( 'elementor/preview/enqueue_styles', array( $this, 'register_style' ) ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Register editor blocks. |
| 37 | */ |
| 38 | public function register_script() { |
| 39 | $deps = require( TIOB_PATH . 'elementor/build/index.asset.php' ); |
| 40 | |
| 41 | wp_enqueue_script( |
| 42 | 'ti-tpc-elementor', |
| 43 | TIOB_URL . 'elementor/build/index.js', |
| 44 | array_merge( $deps['dependencies'], array( 'elementor-editor', 'lodash', 'wp-api' ) ), |
| 45 | $deps['version'], |
| 46 | true |
| 47 | ); |
| 48 | |
| 49 | wp_localize_script( |
| 50 | 'ti-tpc-elementor', |
| 51 | 'tiTpc', |
| 52 | apply_filters( |
| 53 | 'ti_tpc_editor_data', |
| 54 | array( |
| 55 | 'endpoint' => ( defined( 'TPC_TEMPLATES_CLOUD_ENDPOINT' ) ) ? TPC_TEMPLATES_CLOUD_ENDPOINT : Admin::get_templates_cloud_endpoint(), |
| 56 | 'params' => array( |
| 57 | 'site_url' => get_site_url(), |
| 58 | 'license_id' => apply_filters( 'tiob_license_key', 'free' ), |
| 59 | 'type' => 'elementor', |
| 60 | 'meta' => Main::get_meta_fields( $post_id = get_the_ID(), $type = 'elementor' ), |
| 61 | ), |
| 62 | 'canPredefine' => apply_filters( 'ti_tpc_can_predefine', false ), |
| 63 | 'postType' => get_post_type(), |
| 64 | 'placeholderIndex' => '-1', |
| 65 | 'exporter' => array( |
| 66 | 'exportLabel' => sprintf( |
| 67 | // translators: %s: templates location. |
| 68 | __( 'Save to %s', 'templates-patterns-collection' ), |
| 69 | 'Templates Cloud' |
| 70 | ), |
| 71 | 'modalLabel' => __( 'Save Templates', 'templates-patterns-collection' ), |
| 72 | 'textLabel' => __( 'Template Name', 'templates-patterns-collection' ), |
| 73 | 'textPlaceholder' => __( 'Template', 'templates-patterns-collection' ), |
| 74 | 'buttonLabel' => __( 'Save', 'templates-patterns-collection' ), |
| 75 | 'toggleLabel' => __( 'Automatically sync to the cloud', 'templates-patterns-collection' ), |
| 76 | 'templateSaved' => __( 'Template Saved.', 'templates-patterns-collection' ), |
| 77 | 'templatePublished' => __( 'Template Published.', 'templates-patterns-collection' ), |
| 78 | 'templateUnpublished' => __( 'Template Unpublished.', 'templates-patterns-collection' ), |
| 79 | ), |
| 80 | 'library' => array( |
| 81 | 'libraryButton' => sprintf( |
| 82 | // translators: %s: Templates Cloud |
| 83 | __( 'Import from %s', 'templates-patterns-collection' ), |
| 84 | 'Templates Cloud' |
| 85 | ), |
| 86 | 'templatesCloud' => 'Templates Cloud', |
| 87 | 'historyMessage' => sprintf( |
| 88 | // translators: %s: Templates Cloud |
| 89 | __( 'Add Template from %s:', 'templates-patterns-collection' ), |
| 90 | 'Templates Cloud' |
| 91 | ), |
| 92 | 'tabs' => array( |
| 93 | 'templates' => __( 'Page Templates', 'templates-patterns-collection' ), |
| 94 | 'library' => __( 'My Library', 'templates-patterns-collection' ), |
| 95 | ), |
| 96 | 'actions' => array( |
| 97 | 'sync' => __( 'Sync Library', 'templates-patterns-collection' ), |
| 98 | 'save' => sprintf( |
| 99 | // translators: %s: templates location. |
| 100 | __( 'Save to %s', 'templates-patterns-collection' ), |
| 101 | 'Templates Cloud' |
| 102 | ), |
| 103 | 'close' => __( 'Close', 'templates-patterns-collection' ), |
| 104 | 'cancel' => __( 'Cancel', 'templates-patterns-collection' ), |
| 105 | 'edit' => __( 'Edit', 'templates-patterns-collection' ), |
| 106 | 'duplicate' => __( 'Duplicate', 'templates-patterns-collection' ), |
| 107 | 'delete' => __( 'Delete', 'templates-patterns-collection' ), |
| 108 | 'insert' => __( 'Insert', 'templates-patterns-collection' ), |
| 109 | 'back' => __( 'Back to Library', 'templates-patterns-collection' ), |
| 110 | ), |
| 111 | 'filters' => array( |
| 112 | 'sortLabel' => __( 'Sort by', 'templates-patterns-collection' ), |
| 113 | 'sortLabels' => array( |
| 114 | 'name' => __( 'Name', 'templates-patterns-collection' ), |
| 115 | 'date' => __( 'Date', 'templates-patterns-collection' ), |
| 116 | 'modified' => __( 'Last Modified', 'templates-patterns-collection' ), |
| 117 | 'actions' => __( 'Actions', 'templates-patterns-collection' ), |
| 118 | ), |
| 119 | 'search' => __( 'Search', 'templates-patterns-collection' ), |
| 120 | 'searchLabel' => __( 'Search Templates', 'templates-patterns-collection' ), |
| 121 | ), |
| 122 | 'export' => array( |
| 123 | 'save' => __( 'Save', 'templates-patterns-collection' ), |
| 124 | 'title' => sprintf( |
| 125 | // translators: %s: Templates Cloud |
| 126 | __( 'Save your page to %s', 'templates-patterns-collection' ), |
| 127 | 'Templates Cloud' |
| 128 | ), |
| 129 | 'placeholder' => __( 'Enter Template Name', 'templates-patterns-collection' ), |
| 130 | 'labelScreenshot' => __( 'Screenshot URL', 'templates-patterns-collection' ), |
| 131 | 'labelSlug' => __( 'Site Slug', 'templates-patterns-collection' ), |
| 132 | 'publish' => __( 'Publish', 'templates-patterns-collection' ), |
| 133 | 'unpublish' => __( 'Unpublish', 'templates-patterns-collection' ), |
| 134 | 'defaultTitle' => __( 'Template', 'templates-patterns-collection' ), |
| 135 | ), |
| 136 | ), |
| 137 | ) |
| 138 | ) |
| 139 | ); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Register editor styles. |
| 144 | */ |
| 145 | public function register_style() { |
| 146 | $deps = require( TIOB_PATH . 'elementor/build/index.asset.php' ); |
| 147 | |
| 148 | wp_enqueue_style( |
| 149 | 'ti-tpc-elementor-styles', |
| 150 | TIOB_URL . 'elementor/build/index.css', |
| 151 | array( 'wp-components' ), |
| 152 | $deps['version'] |
| 153 | ); |
| 154 | } |
| 155 | } |
| 156 |