| Server IP : 3.93.235.159 / Your IP : 216.73.216.140 Web Server : Apache System : Linux ip-172-26-0-169 5.10.0-46-cloud-amd64 #1 SMP Debian 5.10.262-1 (2026-07-31) x86_64 User : bitnami ( 1000) PHP Version : 8.2.9 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/elementor/modules/components/ |
Upload File : |
<?php
namespace Elementor\Modules\Components;
use Elementor\Core\Utils\Api\Parse_Result;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Components_Parser {
const MIN_NAME_LENGTH = 2;
const MAX_NAME_LENGTH = 50;
public static function make() {
return new static();
}
public function parse_name( $name, $existing_components_names ): Parse_Result {
$result = Parse_Result::make();
$sanitized = trim( sanitize_text_field( $name ) );
if ( strlen( $sanitized ) < self::MIN_NAME_LENGTH ) {
$result->errors()->add( 'name', 'component_name_too_short_min_' . self::MIN_NAME_LENGTH );
}
if ( strlen( $sanitized ) > self::MAX_NAME_LENGTH ) {
$result->errors()->add( 'name', 'component_name_too_long_max_' . self::MAX_NAME_LENGTH );
}
if ( in_array( $sanitized, $existing_components_names, true ) ) {
$result->errors()->add( 'name', 'duplicated_component_name' );
}
return $result->wrap( $sanitized );
}
}