| @@ -9,8 +9,10 @@ | ||
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | class Save_Components_Validator { |
| 13 | + const MAX_COMPONENTS = 50; | |
| 14 | + | |
| 13 | 15 | private Collection $components; |
| 14 | 16 | |
| 15 | 17 | public function __construct( Collection $components ) { |
| 16 | 18 | $this->components = $components; |
| @@ -39,12 +41,11 @@ | ||
| 39 | 41 | ]; |
| 40 | 42 | } |
| 41 | 43 | |
| 42 | 44 | private function validate_count( Collection $data ): array { |
| 43 | - $non_archived_components = $this->components->filter( fn ( $component ) => ! $component['is_archived'] ); | |
| 44 | - $count = $non_archived_components->count() + $data->count(); | |
| 45 | + $count = $this->components->count() + $data->count(); | |
| 45 | 46 | |
| 46 | - if ( $count > Components_REST_API::MAX_COMPONENTS ) { | |
| 47 | + if ( $count > self::MAX_COMPONENTS ) { | |
| 47 | 48 | return [ esc_html__( 'Maximum number of components exceeded.', 'elementor' ) ]; |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | 51 | return []; |
| @@ -58,11 +59,11 @@ | ||
| 58 | 59 | $title = $component['title']; |
| 59 | 60 | $uid = $component['uid']; |
| 60 | 61 | |
| 61 | 62 | $is_title_exists = $this->components->some( |
| 62 | - fn ( $component ) => ! $component['is_archived'] && $component['title'] === $title | |
| 63 | + fn ( $component ) => $component['title'] === $title | |
| 63 | 64 | ) || $data->filter( |
| 64 | - fn ( $component ) => ! $component['title'] === $title | |
| 65 | + fn ( $component ) => $component['title'] === $title | |
| 65 | 66 | )->count() > 1; |
| 66 | 67 | |
| 67 | 68 | if ( $is_title_exists ) { |
| 68 | 69 | $errors[] = [ |