| Server IP : 108.167.142.43 / Your IP : 216.73.217.58 Web Server : Apache System : Linux gator4174.hostgator.com 5.14.0-687.39.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Aug 18 06:09:16 EDT 2026 x86_64 User : delarice ( 2406) PHP Version : 8.3.36 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home2/delarice/www/wp-content/plugins/elementor/modules/atomic-widgets/utils/ |
Upload File : |
<?php
namespace Elementor\Modules\AtomicWidgets\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Element_Position {
const KIND_LAST = 'last';
const KIND_FIRST = 'first';
const KIND_INDEX = 'index';
const KIND_AFTER_TYPE = 'after_type';
const KIND_BEFORE_TYPE = 'before_type';
const KINDS = [
self::KIND_LAST,
self::KIND_FIRST,
self::KIND_INDEX,
self::KIND_AFTER_TYPE,
self::KIND_BEFORE_TYPE,
];
private string $kind;
/**
* @var int|string|null
*/
private $value;
private function __construct( string $kind, $value = null ) {
if ( ! in_array( $kind, self::KINDS, true ) ) {
throw new \InvalidArgumentException( esc_html( "Invalid element position kind: {$kind}" ) );
}
$this->kind = $kind;
$this->value = $value;
}
public static function last(): self {
return new self( self::KIND_LAST );
}
public static function first(): self {
return new self( self::KIND_FIRST );
}
public static function at_index( int $index ): self {
if ( $index < 0 ) {
throw new \InvalidArgumentException( 'Element_Position: index must be >= 0.' );
}
return new self( self::KIND_INDEX, $index );
}
public static function after_type( string $element_type ): self {
self::assert_non_empty_element_type( $element_type, 'after_type' );
return new self( self::KIND_AFTER_TYPE, $element_type );
}
public static function before_type( string $element_type ): self {
self::assert_non_empty_element_type( $element_type, 'before_type' );
return new self( self::KIND_BEFORE_TYPE, $element_type );
}
private static function assert_non_empty_element_type( string $element_type, string $method ): void {
if ( '' === trim( $element_type ) ) {
throw new \InvalidArgumentException(
esc_html( "Element_Position::{$method}: element_type must be a non-empty string." )
);
}
}
public function to_array(): array {
return [
'kind' => $this->kind,
'value' => $this->value,
];
}
}