PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.8
Elementor Website Builder – more than just a page builder v3.25.8
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 -126 4.2.03.25.8 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',
@@ -92,27 +90,10 @@
92 90 ],
93 91 ];
94 92
95 93 /**
96 - * Variables for free to pro upsale modal promotions
97 - */
98 -
99 - const ANIMATED_HEADLINE = 'animated_headline';
100 -
101 - const CTA = 'cta';
102 -
103 - const VIDEO_PLAYLIST = 'video_playlist';
104 -
105 - const TESTIMONIAL_WIDGET = 'testimonial_widget';
106 -
107 - const IMAGE_CAROUSEL = 'image_carousel';
108 -
109 - /**
110 - * Whether WordPress CLI mode is enabled or not.
94 + * Is WP CLI.
111 95 *
112 - * @access public
113 - * @static
114 - *
115 96 * @return bool
116 97 */
117 98 public static function is_wp_cli() {
118 99 return defined( 'WP_CLI' ) && WP_CLI;
@@ -118,8 +99,10 @@
118 99 return defined( 'WP_CLI' ) && WP_CLI;
119 100 }
120 101
121 102 /**
103 + * Is script debug.
104 + *
122 105 * Whether script debug is enabled or not.
123 106 *
124 107 * @since 1.0.0
125 108 * @access public
@@ -124,32 +107,21 @@
124 107 * @since 1.0.0
125 108 * @access public
126 109 * @static
127 110 *
128 - * @return bool
111 + * @return bool True if it's a script debug is active, false otherwise.
129 112 */
130 113 public static function is_script_debug() {
131 114 return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;
132 115 }
133 116
134 - /**
135 - * Whether Elementor debug is enabled or not.
136 - *
137 - * @access public
138 - * @static
139 - *
140 - * @return bool
141 - */
142 117 public static function is_elementor_debug() {
143 118 return defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG;
144 119 }
145 120
146 121 /**
147 - * Whether Elementor test mode is enabled or not.
122 + * Whether elementor test mode is enabled or not.
148 123 *
149 - * @access public
150 - * @static
151 - *
152 124 * @return bool
153 125 */
154 126 public static function is_elementor_tests() {
155 127 return defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS;
@@ -195,13 +167,13 @@
195 167 * @since 2.1.0
196 168 * @static
197 169 * @access public
198 170 *
199 - * @param string $from
200 - * @param string $to
171 + * @param $from
172 + * @param $to
201 173 *
202 174 * @return string
203 - * @throws \Exception If URLs are missing or invalid URLs provided.
175 + * @throws \Exception
204 176 */
205 177 public static function replace_urls( $from, $to ) {
206 178 $from = trim( $from );
207 179 $to = trim( $to );
@@ -247,9 +219,8 @@
247 219 // Allow externals to replace-urls, when they have to.
248 220 $rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $from, $to );
249 221
250 222 Plugin::$instance->files_manager->clear_cache();
251 - Google_Font::clear_cache();
252 223
253 224 return sprintf(
254 225 /* translators: %d: Number of rows. */
255 226 _n( '%d database row affected.', '%d database rows affected.', $rows_affected, 'elementor' ),
@@ -444,9 +415,9 @@
444 415 * @access public
445 416 * @deprecated 3.3.0 Use `Plugin::$instance->documents->get_create_new_post_url()` instead.
446 417 * @static
447 418 *
448 - * @param string $post_type Optional. Post type slug. Default is 'page'.
419 + * @param string $post_type Optional. Post type slug. Default is 'page'.
449 420 * @param string|null $template_type Optional. Query arg 'template_type'. Default is null.
450 421 *
451 422 * @return string A URL for creating new post using Elementor.
452 423 */
@@ -513,14 +484,14 @@
513 484 * @since 2.1.2
514 485 * @access public
515 486 * @static
516 487 */
517 - public static function array_inject( $base_array, $key, $insert ) {
518 - $length = array_search( $key, array_keys( $base_array ), true ) + 1;
488 + public static function array_inject( $array, $key, $insert ) {
489 + $length = array_search( $key, array_keys( $array ), true ) + 1;
519 490
520 - return array_slice( $base_array, 0, $length, true ) +
491 + return array_slice( $array, 0, $length, true ) +
521 492 $insert +
522 - array_slice( $base_array, $length, null, true );
493 + array_slice( $array, $length, null, true );
523 494 }
524 495
525 496 /**
526 497 * Render html attributes
@@ -581,12 +552,11 @@
581 552 /**
582 553 * Add Elementor Config js vars to the relevant script handle,
583 554 * WP will wrap it with <script> tag.
584 555 * To make sure this script runs thru the `script_loader_tag` hook, use a known handle value.
585 - *
586 556 * @param string $handle
587 557 * @param string $js_var
588 - * @param mixed $config
558 + * @param mixed $config
589 559 */
590 560 public static function print_js_config( $handle, $js_var, $config ) {
591 561 $config = wp_json_encode( $config );
592 562
@@ -616,9 +586,9 @@
616 586
617 587 /**
618 588 * Checks a control value for being empty, including a string of '0' not covered by PHP's empty().
619 589 *
620 - * @param mixed $source
590 + * @param mixed $source
621 591 * @param bool|string $key
622 592 *
623 593 * @return bool
624 594 */
@@ -637,34 +607,15 @@
637 607 public static function has_pro() {
638 608 return defined( 'ELEMENTOR_PRO_VERSION' );
639 609 }
640 610
641 - public static function is_license_active(): bool {
642 - return class_exists( '\ElementorPro\License\API' ) && \ElementorPro\License\API::is_license_active();
643 - }
644 -
645 - public static function is_pro_installed_and_not_active(): bool {
646 - if ( ! function_exists( 'get_plugins' ) ) {
647 - require_once ABSPATH . 'wp-admin/includes/plugin.php';
648 - }
649 -
650 - $file_path = self::get_elementor_pro_file_path();
651 - $installed_plugins = get_plugins();
652 -
653 - return isset( $installed_plugins[ $file_path ] );
654 - }
655 -
656 - private static function get_elementor_pro_file_path(): string {
657 - return 'elementor-pro/elementor-pro.php';
658 - }
659 -
660 611 /**
661 612 * Convert HTMLEntities to UTF-8 characters
662 613 *
663 - * @param string $html_string
614 + * @param $string
664 615 * @return string
665 616 */
666 - public static function urlencode_html_entities( $html_string ) {
617 + public static function urlencode_html_entities( $string ) {
667 618 $entities_dictionary = [
668 619 '&#145;' => "'", // Opening single quote
669 620 '&#146;' => "'", // Closing single quote
670 621 '&#147;' => '"', // Closing double quote
@@ -677,11 +628,11 @@
677 628 '&#8222;' => '"', // Double low quote
678 629 ];
679 630
680 631 // Decode decimal entities
681 - $html_string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $html_string );
632 + $string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $string );
682 633
683 - return rawurlencode( html_entity_decode( $html_string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) );
634 + return rawurlencode( html_entity_decode( $string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) );
684 635 }
685 636
686 637 /**
687 638 * Parse attributes that come as a string of comma-delimited key|value pairs.
@@ -733,19 +684,13 @@
733 684 if ( $id === $element['id'] ) {
734 685 return $element;
735 686 }
736 687
737 - $inner_elements = apply_filters(
738 - 'elementor/utils/find_element_recursive/inner_elements',
739 - $element['elements'] ?? [],
740 - $element
741 - );
688 + if ( ! empty( $element['elements'] ) ) {
689 + $element = self::find_element_recursive( $element['elements'], $id );
742 690
743 - if ( ! empty( $inner_elements ) ) {
744 - $found = self::find_element_recursive( $inner_elements, $id );
745 -
746 - if ( $found ) {
747 - return $found;
691 + if ( $element ) {
692 + return $element;
748 693 }
749 694 }
750 695 }
751 696
@@ -760,10 +705,10 @@
760 705 * Fired by `admin_menu` action.
761 706 *
762 707 * @since 3.1.0
763 708 *
764 - * @param string $menu_slug
765 - * @param string $new_label
709 + * @param $menu_slug
710 + * @param $new_label
766 711 * @access public
767 712 */
768 713 public static function change_submenu_first_item_label( $menu_slug, $new_label ) {
769 714 global $submenu;
@@ -798,10 +743,10 @@
798 743
799 744 /**
800 745 * Print internal content (not user input) without escaping.
801 746 */
802 - public static function print_unescaped_internal_string( $internal_string ) {
803 - echo $internal_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
747 + public static function print_unescaped_internal_string( $string ) {
748 + echo $string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
804 749 }
805 750
806 751 /**
807 752 * Get recently edited posts query.
@@ -826,9 +771,9 @@
826 771
827 772 return new \WP_Query( $args );
828 773 }
829 774
830 - public static function print_wp_kses_extended( $text, array $tags ) {
775 + public static function print_wp_kses_extended( $string, array $tags ) {
831 776 $allowed_html = wp_kses_allowed_html( 'post' );
832 777
833 778 foreach ( $tags as $tag ) {
834 779 if ( isset( self::EXTENDED_ALLOWED_HTML_TAGS[ $tag ] ) ) {
@@ -836,9 +781,9 @@
836 781 $allowed_html = array_replace_recursive( $allowed_html, $extended_tags );
837 782 }
838 783 }
839 784
840 - echo wp_kses( $text, $allowed_html );
785 + echo wp_kses( $string, $allowed_html );
841 786 }
842 787
843 788 public static function is_elementor_path( $path ) {
844 789 $path = wp_normalize_path( $path );
@@ -862,10 +807,10 @@
862 807 } );
863 808 }
864 809
865 810 /**
866 - * @param string $file
867 - * @param mixed ...$args
811 + * @param $file
812 + * @param mixed ...$args
868 813 * @return false|string
869 814 */
870 815 public static function file_get_contents( $file, ...$args ) {
871 816 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
@@ -870,8 +815,9 @@
870 815 public static function file_get_contents( $file, ...$args ) {
871 816 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
872 817 return false;
873 818 }
819 +
874 820 return file_get_contents( $file, ...$args );
875 821 }
876 822
877 823 public static function get_super_global_value( $super_global, $key ) {
@@ -878,9 +824,9 @@
878 824 if ( ! isset( $super_global[ $key ] ) ) {
879 825 return null;
880 826 }
881 827
882 - if ( $_FILES === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
828 + if ( $_FILES === $super_global ) {
883 829 return isset( $super_global[ $key ]['name'] ) ?
884 830 self::sanitize_file_name( $super_global[ $key ] ) :
885 831 self::sanitize_multi_upload( $super_global[ $key ] );
886 832 }
@@ -902,21 +848,21 @@
902 848
903 849 /**
904 850 * Return specific object property value if exist from array of keys.
905 851 *
906 - * @param array $base_array
907 - * @param array $keys
908 - * @return mixed|null
852 + * @param $array
853 + * @param $keys
854 + * @return key|false
909 855 */
910 - public static function get_array_value_by_keys( $base_array, $keys ) {
856 + public static function get_array_value_by_keys( $array, $keys ) {
911 857 $keys = (array) $keys;
912 858 foreach ( $keys as $key ) {
913 - if ( ! isset( $base_array[ $key ] ) ) {
859 + if ( ! isset( $array[ $key ] ) ) {
914 860 return null;
915 861 }
916 - $base_array = $base_array[ $key ];
862 + $array = $array[ $key ];
917 863 }
918 - return $base_array;
864 + return $array;
919 865 }
920 866
921 867 public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) {
922 868 $cache = get_site_transient( $cache_key );
@@ -932,10 +878,10 @@
932 878 return $cache;
933 879 }
934 880
935 881 public static function is_sale_time(): bool {
936 - $sale_start_time = gmmktime( 10, 0, 0, 6, 15, 2026 );
937 - $sale_end_time = gmmktime( 3, 59, 0, 6, 17, 2026 );
882 + $sale_start_time = gmmktime( 13, 0, 0, 11, 26, 2024 );
883 + $sale_end_time = gmmktime( 9, 59, 0, 12, 4, 2024 );
938 884
939 885 $now_time = gmdate( 'U' );
940 886
941 887 return $now_time >= $sale_start_time && $now_time <= $sale_end_time;
@@ -945,9 +891,9 @@
945 891 if ( ! static::is_elementor_debug() ) {
946 892 return;
947 893 }
948 894
949 - throw new \Exception( esc_html( $message ) );
895 + throw new \Exception( $message );
950 896 }
951 897
952 898 public static function has_invalid_post_permissions( $post ): bool {
953 899 $is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0;
@@ -965,35 +911,6 @@
965 911 $password_required = post_password_required( $post->ID )
966 912 && ! current_user_can( 'edit_post', $post->ID );
967 913
968 914 return $is_private || $not_allowed || $password_required;
969 - }
970 -
971 - public static function is_custom_kit_applied() {
972 - return (bool) Plugin::$instance->kits_manager->get_previous_id();
973 - }
974 -
975 - public static function decode_string( string $encoded_string, ?string $fallback = '' ) {
976 - try {
977 - return base64_decode( $encoded_string, true ) ?? $fallback;
978 - } catch ( \Exception $e ) {
979 - return $fallback;
980 - }
981 - }
982 -
983 - public static function encode_string( string $decoded_string ): string {
984 - return base64_encode( $decoded_string );
985 - }
986 -
987 - public static function html_to_plain_text( string $html ): string {
988 - if ( empty( $html ) ) {
989 - return '';
990 - }
991 -
992 - $text = preg_replace( '#<br\s*/?\s*>#i', ' ', $html );
993 - $text = preg_replace( '#</?[a-z][^>]*>#i', ' ', $text );
994 - $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
995 - $text = str_replace( "\xE2\x80\x8B", '', $text );
996 -
997 - return trim( preg_replace( '/\s+/', ' ', $text ) );
998 915 }
999 916 }