| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | use Elementor\Core\Kits\Documents\Tabs\Global_Colors; |
| 7 | 7 | use Elementor\Core\Kits\Documents\Tabs\Global_Typography; |
| 8 | 8 | use Elementor\Plugin; |
| 9 | 9 | use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 10 | -use Elementor\Core\Files\CSS\Post_Preview; | |
| 10 | +use Elementor\Core\Files\CSS\Post_Preview as Post_Preview; | |
| 11 | 11 | use Elementor\Core\Documents_Manager; |
| 12 | 12 | use Elementor\Core\Kits\Documents\Kit; |
| 13 | 13 | use Elementor\TemplateLibrary\Source_Local; |
| 14 | 14 | use Elementor\Utils; |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | /** |
| 72 | 72 | * Returns an empty kit for situation when there is no kit in the site. |
| 73 | 73 | * |
| 74 | 74 | * @return Kit |
| 75 | - * @throws \Exception If the kit instance cannot be created. | |
| 75 | + * @throws \Exception | |
| 76 | 76 | */ |
| 77 | 77 | private function get_empty_kit_instance() { |
| 78 | 78 | return new Kit( [ |
| 79 | 79 | 'settings' => [], |
| @@ -137,16 +137,12 @@ | ||
| 137 | 137 | |
| 138 | 138 | public function create_new_kit( $kit_name = '', $settings = [], $active = true ) { |
| 139 | 139 | $kit_name = $kit_name ? $kit_name : esc_html__( 'Custom', 'elementor' ); |
| 140 | 140 | |
| 141 | - $current_kit = $this->get_active_kit(); | |
| 142 | - | |
| 143 | - $kit_meta_data = $this->get_meta_to_preserve( $current_kit ); | |
| 144 | - | |
| 145 | 141 | $id = $this->create( [ |
| 146 | 142 | 'post_title' => $kit_name, |
| 147 | 143 | 'settings' => $settings, |
| 148 | - ], $kit_meta_data ); | |
| 144 | + ] ); | |
| 149 | 145 | |
| 150 | 146 | if ( $active ) { |
| 151 | 147 | update_option( self::OPTION_PREVIOUS, $this->get_active_id() ); |
| 152 | 148 | update_option( self::OPTION_ACTIVE, $id ); |
| @@ -151,32 +147,11 @@ | ||
| 151 | 147 | update_option( self::OPTION_PREVIOUS, $this->get_active_id() ); |
| 152 | 148 | update_option( self::OPTION_ACTIVE, $id ); |
| 153 | 149 | } |
| 154 | 150 | |
| 155 | - do_action( 'elementor/kit/after_new_kit_created', [ | |
| 156 | - 'new_kit_id' => $id, | |
| 157 | - 'previous_kit_id' => $current_kit->get_post()->ID, | |
| 158 | - ] ); | |
| 159 | - | |
| 160 | 151 | return $id; |
| 161 | 152 | } |
| 162 | 153 | |
| 163 | - private function get_meta_to_preserve( Kit $current_kit ): array { | |
| 164 | - $meta_keys_to_preserve = apply_filters( 'elementor/kit/meta_to_preserve_on_kit_import', [] ); | |
| 165 | - | |
| 166 | - $kit_meta_data = []; | |
| 167 | - | |
| 168 | - foreach ( $meta_keys_to_preserve as $meta_key ) { | |
| 169 | - $value = $current_kit->get_meta( $meta_key ); | |
| 170 | - | |
| 171 | - if ( ! empty( $value ) ) { | |
| 172 | - $kit_meta_data[ $meta_key ] = $value; | |
| 173 | - } | |
| 174 | - } | |
| 175 | - | |
| 176 | - return $kit_meta_data; | |
| 177 | - } | |
| 178 | - | |
| 179 | 154 | public function create_default() { |
| 180 | 155 | return $this->create( [ |
| 181 | 156 | 'post_title' => esc_html__( 'Default Kit', 'elementor' ), |
| 182 | 157 | ] ); |
| @@ -301,9 +276,9 @@ | ||
| 301 | 276 | $is_kit_preview = is_preview() && isset( $_GET['preview_id'] ) && $active_kit->get_main_id() === (int) $_GET['preview_id']; |
| 302 | 277 | |
| 303 | 278 | if ( $is_kit_preview ) { |
| 304 | 279 | $kit = Plugin::$instance->documents->get_doc_or_auto_save( $active_kit->get_main_id(), get_current_user_id() ); |
| 305 | - } elseif ( null !== $active_kit->get_main_post() && 'publish' === $active_kit->get_main_post()->post_status ) { | |
| 280 | + } elseif ( 'publish' === $active_kit->get_main_post()->post_status ) { | |
| 306 | 281 | $kit = $active_kit; |
| 307 | 282 | } |
| 308 | 283 | |
| 309 | 284 | return $kit; |
| @@ -324,9 +299,9 @@ | ||
| 324 | 299 | * Map Scheme To Global |
| 325 | 300 | * |
| 326 | 301 | * Convert a given scheme value to its corresponding default global value |
| 327 | 302 | * |
| 328 | - * @param string $type 'color'/'typography'. | |
| 303 | + * @param string $type 'color'/'typography' | |
| 329 | 304 | * @param $value |
| 330 | 305 | * @return mixed |
| 331 | 306 | */ |
| 332 | 307 | private function map_scheme_to_global( $type, $value ) { |
| @@ -359,9 +334,9 @@ | ||
| 359 | 334 | * @access public |
| 360 | 335 | */ |
| 361 | 336 | public function convert_scheme_to_global( $scheme ) { |
| 362 | 337 | if ( isset( $scheme['type'] ) && isset( $scheme['value'] ) ) { |
| 363 | - // _deprecated_argument( $args['scheme'], '3.0.0', 'Schemes are now deprecated - use $args[\'global\'] instead.' ); | |
| 338 | + //_deprecated_argument( $args['scheme'], '3.0.0', 'Schemes are now deprecated - use $args[\'global\'] instead.' ); | |
| 364 | 339 | return $this->map_scheme_to_global( $scheme['type'], $scheme['value'] ); |
| 365 | 340 | } |
| 366 | 341 | |
| 367 | 342 | // Typography control 'scheme' properties usually only include the string with the typography value ('1'-'4'). |
| @@ -398,10 +373,10 @@ | ||
| 398 | 373 | |
| 399 | 374 | /** |
| 400 | 375 | * Send a confirm message before move a kit to trash, or if delete permanently not for trash. |
| 401 | 376 | * |
| 402 | - * @param $post_id | |
| 403 | - * @param bool $is_permanently_delete | |
| 377 | + * @param $post_id | |
| 378 | + * @param false $is_permanently_delete | |
| 404 | 379 | */ |
| 405 | 380 | private function before_delete_kit( $post_id, $is_permanently_delete = false ) { |
| 406 | 381 | if ( $this->should_skip_trash_kit_confirmation ) { |
| 407 | 382 | return; |
| @@ -448,20 +423,13 @@ | ||
| 448 | 423 | } |
| 449 | 424 | } |
| 450 | 425 | |
| 451 | 426 | if ( $document ) { |
| 452 | - $document_edit_url = add_query_arg( | |
| 453 | - [ | |
| 454 | - 'active-document' => $this->get_active_id(), | |
| 455 | - ], | |
| 456 | - $document->get_edit_url() | |
| 457 | - ); | |
| 458 | - | |
| 459 | 427 | $admin_bar_config['elementor_edit_page']['children'][] = [ |
| 460 | 428 | 'id' => 'elementor_site_settings', |
| 461 | 429 | 'title' => esc_html__( 'Site Settings', 'elementor' ), |
| 462 | 430 | 'sub_title' => esc_html__( 'Site', 'elementor' ), |
| 463 | - 'href' => $document_edit_url, | |
| 431 | + 'href' => $document->get_edit_url() . '#' . self::E_HASH_COMMAND_OPEN_SITE_SETTINGS, | |
| 464 | 432 | 'class' => 'elementor-site-settings', |
| 465 | 433 | 'parent_class' => 'elementor-second-section', |
| 466 | 434 | ]; |
| 467 | 435 | } |