S === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return isset( $super_global[ $key ]['name'] ) ?
self::sanitize_file_name( $super_global[ $key ] ) :
self::sanitize_multi_upload( $super_global[ $key ] );
}
return wp_kses_post_deep( wp_unslash( $super_global[ $key ] ) );
}
private static function sanitize_multi_upload( $fields ) {
return array_map( function( $field ) {
return array_map( 'self::sanitize_file_name', $field );
}, $fields );
}
private static function sanitize_file_name( $file ) {
$file['name'] = sanitize_file_name( $file['name'] );
return $file;
}
/**
* Return specific object property value if exist from array of keys.
*
* @param array $base_array
* @param array $keys
* @return mixed|null
*/
public static function get_array_value_by_keys( $base_array, $keys ) {
$keys = (array) $keys;
foreach ( $keys as $key ) {
if ( ! isset( $base_array[ $key ] ) ) {
return null;
}
$base_array = $base_array[ $key ];
}
return $base_array;
}
public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) {
$cache = get_site_transient( $cache_key );
if ( ! $cache ) {
$cache = call_user_func( $callback );
if ( ! is_wp_error( $cache ) ) {
set_site_transient( $cache_key, $cache, $cache_time );
}
}
return $cache;
}
public static function is_sale_time(): bool {
$sale_start_time = gmmktime( 10, 0, 0, 6, 15, 2026 );
$sale_end_time = gmmktime( 3, 59, 0, 6, 17, 2026 );
$now_time = gmdate( 'U' );
return $now_time >= $sale_start_time && $now_time <= $sale_end_time;
}
public static function safe_throw( string $message ) {
if ( ! static::is_elementor_debug() ) {
return;
}
throw new \Exception( esc_html( $message ) );
}
public static function has_invalid_post_permissions( $post ): bool {
$is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0;
if ( $is_image_attachment ) {
return false;
}
$is_private = 'private' === $post->post_status
&& ! current_user_can( 'read_private_posts', $post->ID );
$not_allowed = 'publish' !== $post->post_status
&& ! current_user_can( 'edit_post', $post->ID );
$password_required = post_password_required( $post->ID )
&& ! current_user_can( 'edit_post', $post->ID );
return $is_private || $not_allowed || $password_required;
}
public static function is_custom_kit_applied() {
return (bool) Plugin::$instance->kits_manager->get_previous_id();
}
public static function decode_string( string $encoded_string, ?string $fallback = '' ) {
try {
return base64_decode( $encoded_string, true ) ?? $fallback;
} catch ( \Exception $e ) {
return $fallback;
}
}
public static function encode_string( string $decoded_string ): string {
return base64_encode( $decoded_string );
}
public static function html_to_plain_text( string $html ): string {
if ( empty( $html ) ) {
return '';
}
$text = preg_replace( '#
#i', ' ', $html );
$text = preg_replace( '#?[a-z][^>]*>#i', ' ', $text );
$text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
$text = str_replace( "\xE2\x80\x8B", '', $text );
return trim( preg_replace( '/\s+/', ' ', $text ) );
}
}
S === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
return isset( $super_global[ $key ]['name'] ) ?
self::sanitize_file_name( $super_global[ $key ] ) :
self::sanitize_multi_upload( $super_global[ $key ] );
}
return wp_kses_post_deep( wp_unslash( $super_global[ $key ] ) );
}
private static function sanitize_multi_upload( $fields ) {
return array_map( function( $field ) {
return array_map( 'self::sanitize_file_name', $field );
}, $fields );
}
private static function sanitize_file_name( $file ) {
$file['name'] = sanitize_file_name( $file['name'] );
return $file;
}
/**
* Return specific object property value if exist from array of keys.
*
* @param array $base_array
* @param array $keys
* @return mixed|null
*/
public static function get_array_value_by_keys( $base_array, $keys ) {
$keys = (array) $keys;
foreach ( $keys as $key ) {
if ( ! isset( $base_array[ $key ] ) ) {
return null;
}
$base_array = $base_array[ $key ];
}
return $base_array;
}
public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) {
$cache = get_site_transient( $cache_key );
if ( ! $cache ) {
$cache = call_user_func( $callback );
if ( ! is_wp_error( $cache ) ) {
set_site_transient( $cache_key, $cache, $cache_time );
}
}
return $cache;
}
public static function is_sale_time(): bool {
$sale_start_time = gmmktime( 10, 0, 0, 6, 15, 2026 );
$sale_end_time = gmmktime( 3, 59, 0, 6, 17, 2026 );
$now_time = gmdate( 'U' );
return $now_time >= $sale_start_time && $now_time <= $sale_end_time;
}
public static function safe_throw( string $message ) {
if ( ! static::is_elementor_debug() ) {
return;
}
throw new \Exception( esc_html( $message ) );
}
public static function has_invalid_post_permissions( $post ): bool {
$is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0;
if ( $is_image_attachment ) {
return false;
}
$is_private = 'private' === $post->post_status
&& ! current_user_can( 'read_private_posts', $post->ID );
$not_allowed = 'publish' !== $post->post_status
&& ! current_user_can( 'edit_post', $post->ID );
$password_required = post_password_required( $post->ID )
&& ! current_user_can( 'edit_post', $post->ID );
return $is_private || $not_allowed || $password_required;
}
public static function is_custom_kit_applied() {
return (bool) Plugin::$instance->kits_manager->get_previous_id();
}
public static function decode_string( string $encoded_string, ?string $fallback = '' ) {
try {
return base64_decode( $encoded_string, true ) ?? $fallback;
} catch ( \Exception $e ) {
return $fallback;
}
}
public static function encode_string( string $decoded_string ): string {
return base64_encode( $decoded_string );
}
public static function html_to_plain_text( string $html ): string {
if ( empty( $html ) ) {
return '';
}
$text = preg_replace( '#
#i', ' ', $html );
$text = preg_replace( '#?[a-z][^>]*>#i', ' ', $text );
$text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
$text = str_replace( "\xE2\x80\x8B", '', $text );
return trim( preg_replace( '/\s+/', ' ', $text ) );
}
}