| @@ -37,9 +37,9 @@ | ||
| 37 | 37 | public function hooks() { |
| 38 | 38 | if ( class_exists( '\Elementor\Plugin' ) ) { |
| 39 | 39 | add_action( 'elementor/preview/enqueue_styles', [ $this, 'styles' ] ); |
| 40 | 40 | add_action( 'elementor/editor/before_enqueue_styles', [ $this, 'styles' ] ); |
| 41 | - add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'scripts' ] ); | |
| 41 | + add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'scripts' ] ); | |
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | * @return void |
| 56 | 56 | */ |
| 57 | 57 | public function scripts() { |
| 58 | 58 | templately()->assets->enqueue( 'templately-elementor', 'css/elementor.css' ); |
| 59 | - templately()->assets->enqueue( 'templately-elementor', 'js/elementor.js', [ 'jquery' ], true ); | |
| 59 | + templately()->assets->enqueue( 'templately-elementor', 'js/elementor.js', [ 'jquery' ] ); | |
| 60 | 60 | templately()->admin->scripts( 'elementor' ); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| @@ -77,18 +77,13 @@ | ||
| 77 | 77 | */ |
| 78 | 78 | protected function is_eligible( $template, $types = [ 'page', 'section' ] ) { |
| 79 | 79 | if ( ! Helper::is_plugin_active( 'elementor-pro/elementor-pro.php' ) && |
| 80 | 80 | isset( $template['type'] ) && |
| 81 | - ! in_array( $template['type'], $types, true ) | |
| 82 | - ) { | |
| 81 | + ! in_array( $template['type'], $types, true ) ) { | |
| 83 | 82 | $message = sprintf( |
| 84 | - __( 'You have to install/activate %s to import %s Template.', 'templately' ), | |
| 85 | - sprintf( | |
| 86 | - '<a target="_blank" href="%s">%s</a>', | |
| 87 | - 'https://wpdeveloper.com/go/elementor', | |
| 88 | - 'Elementor PRO' | |
| 89 | - ), | |
| 90 | - $template['type'] | |
| 83 | + __( /** @lang text */ 'You have to install/activate <a target="_blank" href="%s">Elementor PRO</a> to import %s Template.', 'templately' ), | |
| 84 | + 'https://wpdeveloper.com/go/elementor', | |
| 85 | + ucwords( $template['type'] ) | |
| 91 | 86 | ); |
| 92 | 87 | |
| 93 | 88 | return Helper::error( 'required_elementor_pro', $message, 'import/page', 404 ); |
| 94 | 89 | } |
| @@ -250,13 +245,9 @@ | ||
| 250 | 245 | } |
| 251 | 246 | /** |
| 252 | 247 | * Checking the template eligibility for import. |
| 253 | 248 | */ |
| 254 | - $eligible = $this->is_eligible( $template_data ); | |
| 255 | - if( is_wp_error( $eligible ) ) { | |
| 256 | - return $eligible; | |
| 257 | - } | |
| 258 | - | |
| 249 | + $this->is_eligible( $template_data ); | |
| 259 | 250 | $inserted_ID = $importer->create_page( $template_data ); |
| 260 | 251 | |
| 261 | 252 | if ( is_wp_error( $inserted_ID ) ) { |
| 262 | 253 | return Helper::error( |
| @@ -284,12 +275,8 @@ | ||
| 284 | 275 | } |
| 285 | 276 | |
| 286 | 277 | $importer = new ElementorImporter; |
| 287 | 278 | $imported_template = $importer->import_in_library( $template_data ); |
| 288 | - | |
| 289 | - if( is_wp_error( $imported_template ) ) { | |
| 290 | - return $imported_template; | |
| 291 | - } | |
| 292 | 279 | |
| 293 | 280 | return [ |
| 294 | 281 | 'post_id' => $imported_template['template_id'], |
| 295 | 282 | 'edit_link' => get_edit_post_link( $imported_template['template_id'], 'internal' ), |