| @@ -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; |
| @@ -24,10 +24,8 @@ | ||
| 24 | 24 | const OPTION_PREVIOUS = 'elementor_previous_kit'; |
| 25 | 25 | |
| 26 | 26 | const E_HASH_COMMAND_OPEN_SITE_SETTINGS = 'e:run:panel/global/open'; |
| 27 | 27 | |
| 28 | - private $should_skip_trash_kit_confirmation = false; | |
| 29 | - | |
| 30 | 28 | public function get_active_id() { |
| 31 | 29 | return get_option( self::OPTION_ACTIVE ); |
| 32 | 30 | } |
| 33 | 31 | |
| @@ -34,10 +32,10 @@ | ||
| 34 | 32 | public function get_previous_id() { |
| 35 | 33 | return get_option( self::OPTION_PREVIOUS ); |
| 36 | 34 | } |
| 37 | 35 | |
| 38 | - public function get_kit( $kit_id ) { | |
| 39 | - $kit = Plugin::$instance->documents->get( $kit_id ); | |
| 36 | + public function get_active_kit() { | |
| 37 | + $kit = Plugin::$instance->documents->get( $this->get_active_id() ); | |
| 40 | 38 | |
| 41 | 39 | if ( ! $this->is_valid_kit( $kit ) ) { |
| 42 | 40 | return $this->get_empty_kit_instance(); |
| 43 | 41 | } |
| @@ -44,12 +42,8 @@ | ||
| 44 | 42 | |
| 45 | 43 | return $kit; |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | - public function get_active_kit() { | |
| 49 | - return $this->get_kit( $this->get_active_id() ); | |
| 50 | - } | |
| 51 | - | |
| 52 | 46 | public function get_active_kit_for_frontend() { |
| 53 | 47 | $kit = Plugin::$instance->documents->get_doc_for_frontend( $this->get_active_id() ); |
| 54 | 48 | |
| 55 | 49 | if ( ! $this->is_valid_kit( $kit ) ) { |
| @@ -71,9 +65,9 @@ | ||
| 71 | 65 | /** |
| 72 | 66 | * Returns an empty kit for situation when there is no kit in the site. |
| 73 | 67 | * |
| 74 | 68 | * @return Kit |
| 75 | - * @throws \Exception If the kit instance cannot be created. | |
| 69 | + * @throws \Exception | |
| 76 | 70 | */ |
| 77 | 71 | private function get_empty_kit_instance() { |
| 78 | 72 | return new Kit( [ |
| 79 | 73 | 'settings' => [], |
| @@ -170,9 +164,9 @@ | ||
| 170 | 164 | return; |
| 171 | 165 | } |
| 172 | 166 | |
| 173 | 167 | $id = wp_insert_post( [ |
| 174 | - 'post_title' => esc_html__( 'Default Kit', 'elementor' ), | |
| 168 | + 'post_title' => __( 'Default Kit', 'elementor' ), | |
| 175 | 169 | 'post_type' => Source_Local::CPT, |
| 176 | 170 | 'post_status' => 'publish', |
| 177 | 171 | 'meta_input' => [ |
| 178 | 172 | '_elementor_edit_mode' => 'builder', |
| @@ -185,35 +179,8 @@ | ||
| 185 | 179 | return $id; |
| 186 | 180 | } |
| 187 | 181 | |
| 188 | 182 | /** |
| 189 | - * @param $imported_kit_id int The id of the imported kit that should be deleted. | |
| 190 | - * @param $active_kit_id int The id of the kit that should set as 'active_kit' after the deletion. | |
| 191 | - * @param $previous_kit_id int The id of the kit that should set as 'previous_kit' after the deletion. | |
| 192 | - * @return void | |
| 193 | - */ | |
| 194 | - public function revert( int $imported_kit_id, int $active_kit_id, int $previous_kit_id ) { | |
| 195 | - // If the kit that should set as active is not a valid kit then abort the revert. | |
| 196 | - if ( ! $this->is_kit( $active_kit_id ) ) { | |
| 197 | - return; | |
| 198 | - } | |
| 199 | - | |
| 200 | - // This a hacky solution to avoid from the revert process to be interrupted by the `trash_kit_confirmation`. | |
| 201 | - $this->should_skip_trash_kit_confirmation = true; | |
| 202 | - | |
| 203 | - $kit = $this->get_kit( $imported_kit_id ); | |
| 204 | - $kit->force_delete(); | |
| 205 | - | |
| 206 | - $this->should_skip_trash_kit_confirmation = false; | |
| 207 | - | |
| 208 | - update_option( self::OPTION_ACTIVE, $active_kit_id ); | |
| 209 | - | |
| 210 | - if ( $this->is_kit( $previous_kit_id ) ) { | |
| 211 | - update_option( self::OPTION_PREVIOUS, $previous_kit_id ); | |
| 212 | - } | |
| 213 | - } | |
| 214 | - | |
| 215 | - /** | |
| 216 | 183 | * @param Documents_Manager $documents_manager |
| 217 | 184 | */ |
| 218 | 185 | public function register_document( $documents_manager ) { |
| 219 | 186 | $documents_manager->register_document_type( 'kit', Kit::get_class_full_name() ); |
| @@ -276,9 +243,9 @@ | ||
| 276 | 243 | $is_kit_preview = is_preview() && isset( $_GET['preview_id'] ) && $active_kit->get_main_id() === (int) $_GET['preview_id']; |
| 277 | 244 | |
| 278 | 245 | if ( $is_kit_preview ) { |
| 279 | 246 | $kit = Plugin::$instance->documents->get_doc_or_auto_save( $active_kit->get_main_id(), get_current_user_id() ); |
| 280 | - } elseif ( null !== $active_kit->get_main_post() && 'publish' === $active_kit->get_main_post()->post_status ) { | |
| 247 | + } elseif ( 'publish' === $active_kit->get_main_post()->post_status ) { | |
| 281 | 248 | $kit = $active_kit; |
| 282 | 249 | } |
| 283 | 250 | |
| 284 | 251 | return $kit; |
| @@ -299,9 +266,9 @@ | ||
| 299 | 266 | * Map Scheme To Global |
| 300 | 267 | * |
| 301 | 268 | * Convert a given scheme value to its corresponding default global value |
| 302 | 269 | * |
| 303 | - * @param string $type 'color'/'typography'. | |
| 270 | + * @param string $type 'color'/'typography' | |
| 304 | 271 | * @param $value |
| 305 | 272 | * @return mixed |
| 306 | 273 | */ |
| 307 | 274 | private function map_scheme_to_global( $type, $value ) { |
| @@ -334,9 +301,9 @@ | ||
| 334 | 301 | * @access public |
| 335 | 302 | */ |
| 336 | 303 | public function convert_scheme_to_global( $scheme ) { |
| 337 | 304 | if ( isset( $scheme['type'] ) && isset( $scheme['value'] ) ) { |
| 338 | - // _deprecated_argument( $args['scheme'], '3.0.0', 'Schemes are now deprecated - use $args[\'global\'] instead.' ); | |
| 305 | + //_deprecated_argument( $args['scheme'], '3.0.0', 'Schemes are now deprecated - use $args[\'global\'] instead.' ); | |
| 339 | 306 | return $this->map_scheme_to_global( $scheme['type'], $scheme['value'] ); |
| 340 | 307 | } |
| 341 | 308 | |
| 342 | 309 | // Typography control 'scheme' properties usually only include the string with the typography value ('1'-'4'). |
| @@ -373,16 +340,12 @@ | ||
| 373 | 340 | |
| 374 | 341 | /** |
| 375 | 342 | * Send a confirm message before move a kit to trash, or if delete permanently not for trash. |
| 376 | 343 | * |
| 377 | - * @param $post_id | |
| 378 | - * @param bool $is_permanently_delete | |
| 344 | + * @param $post_id | |
| 345 | + * @param false $is_permanently_delete | |
| 379 | 346 | */ |
| 380 | 347 | private function before_delete_kit( $post_id, $is_permanently_delete = false ) { |
| 381 | - if ( $this->should_skip_trash_kit_confirmation ) { | |
| 382 | - return; | |
| 383 | - } | |
| 384 | - | |
| 385 | 348 | $document = Plugin::$instance->documents->get( $post_id ); |
| 386 | 349 | |
| 387 | 350 | if ( |
| 388 | 351 | ! $document || |
| @@ -423,20 +386,13 @@ | ||
| 423 | 386 | } |
| 424 | 387 | } |
| 425 | 388 | |
| 426 | 389 | if ( $document ) { |
| 427 | - $document_edit_url = add_query_arg( | |
| 428 | - [ | |
| 429 | - 'active-document' => $this->get_active_id(), | |
| 430 | - ], | |
| 431 | - $document->get_edit_url() | |
| 432 | - ); | |
| 433 | - | |
| 434 | 390 | $admin_bar_config['elementor_edit_page']['children'][] = [ |
| 435 | 391 | 'id' => 'elementor_site_settings', |
| 436 | 392 | 'title' => esc_html__( 'Site Settings', 'elementor' ), |
| 437 | 393 | 'sub_title' => esc_html__( 'Site', 'elementor' ), |
| 438 | - 'href' => $document_edit_url, | |
| 394 | + 'href' => $document->get_edit_url() . '#' . self::E_HASH_COMMAND_OPEN_SITE_SETTINGS, | |
| 439 | 395 | 'class' => 'elementor-site-settings', |
| 440 | 396 | 'parent_class' => 'elementor-second-section', |
| 441 | 397 | ]; |
| 442 | 398 | } |