PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.0-dev5
Elementor Website Builder – more than just a page builder v3.26.0-dev5
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/utils.php +43 -108 4.1.0-dev33.26.0-dev5 View file →
@@ -1,8 +1,7 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Core\Files\Fonts\Google_Font;
5 4 use Elementor\Core\Utils\Collection;
6 5
7 6 if ( ! defined( 'ABSPATH' ) ) {
8 7 exit; // Exit if accessed directly.
@@ -29,9 +28,8 @@
29 28 'a',
30 29 'article',
31 30 'aside',
32 31 'button',
33 - 'form',
34 32 'div',
35 33 'footer',
36 34 'h1',
37 35 'h2',
@@ -106,13 +104,10 @@
106 104
107 105 const IMAGE_CAROUSEL = 'image_carousel';
108 106
109 107 /**
110 - * Whether WordPress CLI mode is enabled or not.
108 + * Is WP CLI.
111 109 *
112 - * @access public
113 - * @static
114 - *
115 110 * @return bool
116 111 */
117 112 public static function is_wp_cli() {
118 113 return defined( 'WP_CLI' ) && WP_CLI;
@@ -118,8 +113,10 @@
118 113 return defined( 'WP_CLI' ) && WP_CLI;
119 114 }
120 115
121 116 /**
117 + * Is script debug.
118 + *
122 119 * Whether script debug is enabled or not.
123 120 *
124 121 * @since 1.0.0
125 122 * @access public
@@ -124,32 +121,21 @@
124 121 * @since 1.0.0
125 122 * @access public
126 123 * @static
127 124 *
128 - * @return bool
125 + * @return bool True if it's a script debug is active, false otherwise.
129 126 */
130 127 public static function is_script_debug() {
131 128 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
132 129 }
133 130
134 - /**
135 - * Whether Elementor debug is enabled or not.
136 - *
137 - * @access public
138 - * @static
139 - *
140 - * @return bool
141 - */
142 131 public static function is_elementor_debug() {
143 132 return defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG;
144 133 }
145 134
146 135 /**
147 - * Whether Elementor test mode is enabled or not.
136 + * Whether elementor test mode is enabled or not.
148 137 *
149 - * @access public
150 - * @static
151 - *
152 138 * @return bool
153 139 */
154 140 public static function is_elementor_tests() {
155 141 return defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS;
@@ -195,13 +181,13 @@
195 181 * @since 2.1.0
196 182 * @static
197 183 * @access public
198 184 *
199 - * @param string $from
200 - * @param string $to
185 + * @param $from
186 + * @param $to
201 187 *
202 188 * @return string
203 - * @throws \Exception If URLs are missing or invalid URLs provided.
189 + * @throws \Exception
204 190 */
205 191 public static function replace_urls( $from, $to ) {
206 192 $from = trim( $from );
207 193 $to = trim( $to );
@@ -247,9 +233,8 @@
247 233 // Allow externals to replace-urls, when they have to.
248 234 $rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $from, $to );
249 235
250 236 Plugin::$instance->files_manager->clear_cache();
251 - Google_Font::clear_cache();
252 237
253 238 return sprintf(
254 239 /* translators: %d: Number of rows. */
255 240 _n( '%d database row affected.', '%d database rows affected.', $rows_affected, 'elementor' ),
@@ -444,9 +429,9 @@
444 429 * @access public
445 430 * @deprecated 3.3.0 Use `Plugin::$instance->documents->get_create_new_post_url()` instead.
446 431 * @static
447 432 *
448 - * @param string $post_type Optional. Post type slug. Default is 'page'.
433 + * @param string $post_type Optional. Post type slug. Default is 'page'.
449 434 * @param string|null $template_type Optional. Query arg 'template_type'. Default is null.
450 435 *
451 436 * @return string A URL for creating new post using Elementor.
452 437 */
@@ -513,14 +498,14 @@
513 498 * @since 2.1.2
514 499 * @access public
515 500 * @static
516 501 */
517 - public static function array_inject( $base_array, $key, $insert ) {
518 - $length = array_search( $key, array_keys( $base_array ), true ) + 1;
502 + public static function array_inject( $array, $key, $insert ) {
503 + $length = array_search( $key, array_keys( $array ), true ) + 1;
519 504
520 - return array_slice( $base_array, 0, $length, true ) +
505 + return array_slice( $array, 0, $length, true ) +
521 506 $insert +
522 - array_slice( $base_array, $length, null, true );
507 + array_slice( $array, $length, null, true );
523 508 }
524 509
525 510 /**
526 511 * Render html attributes
@@ -581,12 +566,11 @@
581 566 /**
582 567 * Add Elementor Config js vars to the relevant script handle,
583 568 * WP will wrap it with <script> tag.
584 569 * To make sure this script runs thru the `script_loader_tag` hook, use a known handle value.
585 - *
586 570 * @param string $handle
587 571 * @param string $js_var
588 - * @param mixed $config
572 + * @param mixed $config
589 573 */
590 574 public static function print_js_config( $handle, $js_var, $config ) {
591 575 $config = wp_json_encode( $config );
592 576
@@ -616,9 +600,9 @@
616 600
617 601 /**
618 602 * Checks a control value for being empty, including a string of '0' not covered by PHP's empty().
619 603 *
620 - * @param mixed $source
604 + * @param mixed $source
621 605 * @param bool|string $key
622 606 *
623 607 * @return bool
624 608 */
@@ -637,30 +621,15 @@
637 621 public static function has_pro() {
638 622 return defined( 'ELEMENTOR_PRO_VERSION' );
639 623 }
640 624
641 - public static function is_pro_installed_and_not_active(): bool {
642 - if ( ! function_exists( 'get_plugins' ) ) {
643 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
644 - }
645 -
646 - $file_path = self::get_elementor_pro_file_path();
647 - $installed_plugins = get_plugins();
648 -
649 - return isset( $installed_plugins[ $file_path ] );
650 - }
651 -
652 - private static function get_elementor_pro_file_path(): string {
653 - return 'elementor-pro/elementor-pro.php';
654 - }
655 -
656 625 /**
657 626 * Convert HTMLEntities to UTF-8 characters
658 627 *
659 - * @param string $html_string
628 + * @param $string
660 629 * @return string
661 630 */
662 - public static function urlencode_html_entities( $html_string ) {
631 + public static function urlencode_html_entities( $string ) {
663 632 $entities_dictionary = [
664 633 '&#145;' => "'", // Opening single quote
665 634 '&#146;' => "'", // Closing single quote
666 635 '&#147;' => '"', // Closing double quote
@@ -673,11 +642,11 @@
673 642 '&#8222;' => '"', // Double low quote
674 643 ];
675 644
676 645 // Decode decimal entities
677 - $html_string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $html_string );
646 + $string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $string );
678 647
679 - return rawurlencode( html_entity_decode( $html_string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) );
648 + return rawurlencode( html_entity_decode( $string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) );
680 649 }
681 650
682 651 /**
683 652 * Parse attributes that come as a string of comma-delimited key|value pairs.
@@ -729,19 +698,13 @@
729 698 if ( $id === $element['id'] ) {
730 699 return $element;
731 700 }
732 701
733 - $inner_elements = apply_filters(
734 - 'elementor/utils/find_element_recursive/inner_elements',
735 - $element['elements'] ?? [],
736 - $element
737 - );
702 + if ( ! empty( $element['elements'] ) ) {
703 + $element = self::find_element_recursive( $element['elements'], $id );
738 704
739 - if ( ! empty( $inner_elements ) ) {
740 - $found = self::find_element_recursive( $inner_elements, $id );
741 -
742 - if ( $found ) {
743 - return $found;
705 + if ( $element ) {
706 + return $element;
744 707 }
745 708 }
746 709 }
747 710
@@ -756,10 +719,10 @@
756 719 * Fired by `admin_menu` action.
757 720 *
758 721 * @since 3.1.0
759 722 *
760 - * @param string $menu_slug
761 - * @param string $new_label
723 + * @param $menu_slug
724 + * @param $new_label
762 725 * @access public
763 726 */
764 727 public static function change_submenu_first_item_label( $menu_slug, $new_label ) {
765 728 global $submenu;
@@ -794,10 +757,10 @@
794 757
795 758 /**
796 759 * Print internal content (not user input) without escaping.
797 760 */
798 - public static function print_unescaped_internal_string( $internal_string ) {
799 - echo $internal_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
761 + public static function print_unescaped_internal_string( $string ) {
762 + echo $string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
800 763 }
801 764
802 765 /**
803 766 * Get recently edited posts query.
@@ -822,9 +785,9 @@
822 785
823 786 return new \WP_Query( $args );
824 787 }
825 788
826 - public static function print_wp_kses_extended( $text, array $tags ) {
789 + public static function print_wp_kses_extended( $string, array $tags ) {
827 790 $allowed_html = wp_kses_allowed_html( 'post' );
828 791
829 792 foreach ( $tags as $tag ) {
830 793 if ( isset( self::EXTENDED_ALLOWED_HTML_TAGS[ $tag ] ) ) {
@@ -832,9 +795,9 @@
832 795 $allowed_html = array_replace_recursive( $allowed_html, $extended_tags );
833 796 }
834 797 }
835 798
836 - echo wp_kses( $text, $allowed_html );
799 + echo wp_kses( $string, $allowed_html );
837 800 }
838 801
839 802 public static function is_elementor_path( $path ) {
840 803 $path = wp_normalize_path( $path );
@@ -858,10 +821,10 @@
858 821 } );
859 822 }
860 823
861 824 /**
862 - * @param string $file
863 - * @param mixed ...$args
825 + * @param $file
826 + * @param mixed ...$args
864 827 * @return false|string
865 828 */
866 829 public static function file_get_contents( $file, ...$args ) {
867 830 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
@@ -866,8 +829,9 @@
866 829 public static function file_get_contents( $file, ...$args ) {
867 830 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
868 831 return false;
869 832 }
833 +
870 834 return file_get_contents( $file, ...$args );
871 835 }
872 836
873 837 public static function get_super_global_value( $super_global, $key ) {
@@ -874,9 +838,9 @@
874 838 if ( ! isset( $super_global[ $key ] ) ) {
875 839 return null;
876 840 }
877 841
878 - if ( $_FILES === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
842 + if ( $_FILES === $super_global ) {
879 843 return isset( $super_global[ $key ]['name'] ) ?
880 844 self::sanitize_file_name( $super_global[ $key ] ) :
881 845 self::sanitize_multi_upload( $super_global[ $key ] );
882 846 }
@@ -898,21 +862,21 @@
898 862
899 863 /**
900 864 * Return specific object property value if exist from array of keys.
901 865 *
902 - * @param array $base_array
903 - * @param array $keys
904 - * @return mixed|null
866 + * @param $array
867 + * @param $keys
868 + * @return key|false
905 869 */
906 - public static function get_array_value_by_keys( $base_array, $keys ) {
870 + public static function get_array_value_by_keys( $array, $keys ) {
907 871 $keys = (array) $keys;
908 872 foreach ( $keys as $key ) {
909 - if ( ! isset( $base_array[ $key ] ) ) {
873 + if ( ! isset( $array[ $key ] ) ) {
910 874 return null;
911 875 }
912 - $base_array = $base_array[ $key ];
876 + $array = $array[ $key ];
913 877 }
914 - return $base_array;
878 + return $array;
915 879 }
916 880
917 881 public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) {
918 882 $cache = get_site_transient( $cache_key );
@@ -928,10 +892,10 @@
928 892 return $cache;
929 893 }
930 894
931 895 public static function is_sale_time(): bool {
932 - $sale_start_time = gmmktime( 12, 0, 0, 11, 25, 2025 );
933 - $sale_end_time = gmmktime( 3, 59, 0, 12, 3, 2025 );
896 + $sale_start_time = gmmktime( 13, 0, 0, 11, 26, 2024 );
897 + $sale_end_time = gmmktime( 9, 59, 0, 12, 4, 2024 );
934 898
935 899 $now_time = gmdate( 'U' );
936 900
937 901 return $now_time >= $sale_start_time && $now_time <= $sale_end_time;
@@ -941,9 +905,9 @@
941 905 if ( ! static::is_elementor_debug() ) {
942 906 return;
943 907 }
944 908
945 - throw new \Exception( esc_html( $message ) );
909 + throw new \Exception( $message );
946 910 }
947 911
948 912 public static function has_invalid_post_permissions( $post ): bool {
949 913 $is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0;
@@ -961,35 +925,6 @@
961 925 $password_required = post_password_required( $post->ID )
962 926 && ! current_user_can( 'edit_post', $post->ID );
963 927
964 928 return $is_private || $not_allowed || $password_required;
965 - }
966 -
967 - public static function is_custom_kit_applied() {
968 - return (bool) Plugin::$instance->kits_manager->get_previous_id();
969 - }
970 -
971 - public static function decode_string( string $encoded_string, ?string $fallback = '' ) {
972 - try {
973 - return base64_decode( $encoded_string, true ) ?? $fallback;
974 - } catch ( \Exception $e ) {
975 - return $fallback;
976 - }
977 - }
978 -
979 - public static function encode_string( string $decoded_string ): string {
980 - return base64_encode( $decoded_string );
981 - }
982 -
983 - public static function html_to_plain_text( string $html ): string {
984 - if ( empty( $html ) ) {
985 - return '';
986 - }
987 -
988 - $text = preg_replace( '#<br\s*/?\s*>#i', ' ', $html );
989 - $text = preg_replace( '#</?[a-z][^>]*>#i', ' ', $text );
990 - $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
991 - $text = str_replace( "\xE2\x80\x8B", '', $text );
992 -
993 - return trim( preg_replace( '/\s+/', ' ', $text ) );
994 929 }
995 930 }