| @@ -328,9 +328,9 @@ | ||
| 328 | 328 | * @param string $file Path to the file. |
| 329 | 329 | * @param string $referrer Referrer of the file 'local' or 'kit-library'. |
| 330 | 330 | * @param string $kit_id |
| 331 | 331 | * @return array |
| 332 | - * @throws \Exception If export validation fails or processing errors occur. | |
| 332 | + * @throws \Exception | |
| 333 | 333 | */ |
| 334 | 334 | public function upload_kit( $file, $referrer, $kit_id = null ) { |
| 335 | 335 | $this->ensure_writing_permissions(); |
| 336 | 336 | |
| @@ -356,13 +356,13 @@ | ||
| 356 | 356 | * Assigning the Import process to the 'import' property, |
| 357 | 357 | * so it will be available to use in different places such as: WP_Cli, Pro, etc. |
| 358 | 358 | * |
| 359 | 359 | * @param string $path Path to the file or session_id. |
| 360 | - * @param array $settings Settings the import use to determine which content to import. | |
| 361 | - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.) | |
| 362 | - * @param bool $split_to_chunks Determine if the import process should be split into chunks. | |
| 360 | + * @param array $settings Settings the import use to determine which content to import. | |
| 361 | + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.) | |
| 362 | + * @param bool $split_to_chunks Determine if the import process should be split into chunks. | |
| 363 | 363 | * @return array |
| 364 | - * @throws \Exception If export configuration is invalid or processing fails. | |
| 364 | + * @throws \Exception | |
| 365 | 365 | */ |
| 366 | 366 | public function import_kit( string $path, array $settings, bool $split_to_chunks = false ): array { |
| 367 | 367 | $this->ensure_writing_permissions(); |
| 368 | 368 | $this->ensure_DOMDocument_exists(); |
| @@ -393,9 +393,9 @@ | ||
| 393 | 393 | * |
| 394 | 394 | * @return array Two types of response. |
| 395 | 395 | * 1. The status and the runner name. |
| 396 | 396 | * 2. The imported data. (Only if the runner is the last one in the import process) |
| 397 | - * @throws \Exception If import configuration is invalid or processing fails. | |
| 397 | + * @throws \Exception | |
| 398 | 398 | */ |
| 399 | 399 | public function import_kit_by_runner( string $session_id, string $runner_name ): array { |
| 400 | 400 | // Check session_id |
| 401 | 401 | $this->import = Import::from_session( $session_id ); |
| @@ -418,9 +418,9 @@ | ||
| 418 | 418 | * |
| 419 | 419 | * @param array $settings Settings the export use to determine which content to export. |
| 420 | 420 | * (e.g: include, kit_info, selected_plugins, selected_cpt, etc.) |
| 421 | 421 | * @return array |
| 422 | - * @throws \Exception If import/export process fails or validation errors occur. | |
| 422 | + * @throws \Exception | |
| 423 | 423 | */ |
| 424 | 424 | public function export_kit( array $settings ) { |
| 425 | 425 | $this->ensure_writing_permissions(); |
| 426 | 426 | |
| @@ -616,10 +616,8 @@ | ||
| 616 | 616 | } |
| 617 | 617 | |
| 618 | 618 | /** |
| 619 | 619 | * Handle upload kit ajax request. |
| 620 | - * | |
| 621 | - * @throws \Error If operation validation fails or processing errors occur. | |
| 622 | 620 | */ |
| 623 | 621 | private function handle_upload_kit() { |
| 624 | 622 | // PHPCS - A URL that should contain special chars (auth headers information). |
| 625 | 623 | $file_url = isset( $_POST['e_import_file'] ) |
| @@ -644,9 +642,9 @@ | ||
| 644 | 642 | throw new \Error( static::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped |
| 645 | 643 | } |
| 646 | 644 | |
| 647 | 645 | $import_result = apply_filters( 'elementor/import/kit/result', [ 'file_url' => $file_url ] ); |
| 648 | - } elseif ( ! empty( $source ) ) { | |
| 646 | + } else if ( ! empty( $source ) ) { | |
| 649 | 647 | $import_result = apply_filters( 'elementor/import/kit/result/' . $source, [ |
| 650 | 648 | 'kit_id' => $kit_id, |
| 651 | 649 | 'source' => $source, |
| 652 | 650 | ] ); |
| @@ -770,10 +768,8 @@ | ||
| 770 | 768 | } |
| 771 | 769 | |
| 772 | 770 | /** |
| 773 | 771 | * Handle export kit ajax request. |
| 774 | - * | |
| 775 | - * @throws \Error If cleanup process fails or file system errors occur. | |
| 776 | 772 | */ |
| 777 | 773 | private function handle_export_kit() { |
| 778 | 774 | // PHPCS - Already validated in caller function |
| 779 | 775 | $settings = json_decode( ElementorUtils::get_super_global_value( $_POST, 'data' ), true ); // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| @@ -781,9 +777,8 @@ | ||
| 781 | 777 | |
| 782 | 778 | $export = $this->export_kit( $settings ); |
| 783 | 779 | |
| 784 | 780 | $file_name = $export['file_name']; |
| 785 | - $file_size = filesize( $file_name ); | |
| 786 | 781 | $file = ElementorUtils::file_get_contents( $file_name ); |
| 787 | 782 | |
| 788 | 783 | if ( ! $file ) { |
| 789 | 784 | throw new \Error( 'Could not read the exported file.' ); |
| @@ -800,9 +795,8 @@ | ||
| 800 | 795 | $source, |
| 801 | 796 | $export, |
| 802 | 797 | $settings, |
| 803 | 798 | $file, |
| 804 | - $file_size, | |
| 805 | 799 | ); |
| 806 | 800 | |
| 807 | 801 | if ( is_wp_error( $result ) ) { |
| 808 | 802 | wp_send_json_error( $result ); |
| @@ -975,13 +969,13 @@ | ||
| 975 | 969 | return $document ? $document->get_edit_url() : ''; |
| 976 | 970 | } |
| 977 | 971 | |
| 978 | 972 | /** |
| 979 | - * @param string $class_name | |
| 973 | + * @param string $class | |
| 980 | 974 | * |
| 981 | 975 | * @return bool |
| 982 | 976 | */ |
| 983 | - public function is_third_party_class( $class_name ) { | |
| 977 | + public function is_third_party_class( $class ) { | |
| 984 | 978 | $allowed_classes = [ |
| 985 | 979 | 'Elementor\\', |
| 986 | 980 | 'ElementorPro\\', |
| 987 | 981 | 'WP_', |
| @@ -988,9 +982,9 @@ | ||
| 988 | 982 | 'wp_', |
| 989 | 983 | ]; |
| 990 | 984 | |
| 991 | 985 | foreach ( $allowed_classes as $allowed_class ) { |
| 992 | - if ( str_starts_with( $class_name, $allowed_class ) ) { | |
| 986 | + if ( str_starts_with( $class, $allowed_class ) ) { | |
| 993 | 987 | return false; |
| 994 | 988 | } |
| 995 | 989 | } |
| 996 | 990 | |