PluginProbe
Elementor Website Builder – more than just a page builder / 3.26.3
Elementor Website Builder – more than just a page builder v3.26.3
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 +39 -98 4.1.0-dev13.26.3 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.
@@ -750,10 +719,10 @@
750 719 * Fired by `admin_menu` action.
751 720 *
752 721 * @since 3.1.0
753 722 *
754 - * @param string $menu_slug
755 - * @param string $new_label
723 + * @param $menu_slug
724 + * @param $new_label
756 725 * @access public
757 726 */
758 727 public static function change_submenu_first_item_label( $menu_slug, $new_label ) {
759 728 global $submenu;
@@ -788,10 +757,10 @@
788 757
789 758 /**
790 759 * Print internal content (not user input) without escaping.
791 760 */
792 - public static function print_unescaped_internal_string( $internal_string ) {
793 - 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
794 763 }
795 764
796 765 /**
797 766 * Get recently edited posts query.
@@ -816,9 +785,9 @@
816 785
817 786 return new \WP_Query( $args );
818 787 }
819 788
820 - public static function print_wp_kses_extended( $text, array $tags ) {
789 + public static function print_wp_kses_extended( $string, array $tags ) {
821 790 $allowed_html = wp_kses_allowed_html( 'post' );
822 791
823 792 foreach ( $tags as $tag ) {
824 793 if ( isset( self::EXTENDED_ALLOWED_HTML_TAGS[ $tag ] ) ) {
@@ -826,9 +795,9 @@
826 795 $allowed_html = array_replace_recursive( $allowed_html, $extended_tags );
827 796 }
828 797 }
829 798
830 - echo wp_kses( $text, $allowed_html );
799 + echo wp_kses( $string, $allowed_html );
831 800 }
832 801
833 802 public static function is_elementor_path( $path ) {
834 803 $path = wp_normalize_path( $path );
@@ -852,10 +821,10 @@
852 821 } );
853 822 }
854 823
855 824 /**
856 - * @param string $file
857 - * @param mixed ...$args
825 + * @param $file
826 + * @param mixed ...$args
858 827 * @return false|string
859 828 */
860 829 public static function file_get_contents( $file, ...$args ) {
861 830 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
@@ -860,8 +829,9 @@
860 829 public static function file_get_contents( $file, ...$args ) {
861 830 if ( ! is_file( $file ) || ! is_readable( $file ) ) {
862 831 return false;
863 832 }
833 +
864 834 return file_get_contents( $file, ...$args );
865 835 }
866 836
867 837 public static function get_super_global_value( $super_global, $key ) {
@@ -868,9 +838,9 @@
868 838 if ( ! isset( $super_global[ $key ] ) ) {
869 839 return null;
870 840 }
871 841
872 - if ( $_FILES === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
842 + if ( $_FILES === $super_global ) {
873 843 return isset( $super_global[ $key ]['name'] ) ?
874 844 self::sanitize_file_name( $super_global[ $key ] ) :
875 845 self::sanitize_multi_upload( $super_global[ $key ] );
876 846 }
@@ -892,21 +862,21 @@
892 862
893 863 /**
894 864 * Return specific object property value if exist from array of keys.
895 865 *
896 - * @param array $base_array
897 - * @param array $keys
898 - * @return mixed|null
866 + * @param $array
867 + * @param $keys
868 + * @return key|false
899 869 */
900 - public static function get_array_value_by_keys( $base_array, $keys ) {
870 + public static function get_array_value_by_keys( $array, $keys ) {
901 871 $keys = (array) $keys;
902 872 foreach ( $keys as $key ) {
903 - if ( ! isset( $base_array[ $key ] ) ) {
873 + if ( ! isset( $array[ $key ] ) ) {
904 874 return null;
905 875 }
906 - $base_array = $base_array[ $key ];
876 + $array = $array[ $key ];
907 877 }
908 - return $base_array;
878 + return $array;
909 879 }
910 880
911 881 public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) {
912 882 $cache = get_site_transient( $cache_key );
@@ -922,10 +892,10 @@
922 892 return $cache;
923 893 }
924 894
925 895 public static function is_sale_time(): bool {
926 - $sale_start_time = gmmktime( 12, 0, 0, 11, 25, 2025 );
927 - $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 );
928 898
929 899 $now_time = gmdate( 'U' );
930 900
931 901 return $now_time >= $sale_start_time && $now_time <= $sale_end_time;
@@ -935,9 +905,9 @@
935 905 if ( ! static::is_elementor_debug() ) {
936 906 return;
937 907 }
938 908
939 - throw new \Exception( esc_html( $message ) );
909 + throw new \Exception( $message );
940 910 }
941 911
942 912 public static function has_invalid_post_permissions( $post ): bool {
943 913 $is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0;
@@ -955,35 +925,6 @@
955 925 $password_required = post_password_required( $post->ID )
956 926 && ! current_user_can( 'edit_post', $post->ID );
957 927
958 928 return $is_private || $not_allowed || $password_required;
959 - }
960 -
961 - public static function is_custom_kit_applied() {
962 - return (bool) Plugin::$instance->kits_manager->get_previous_id();
963 - }
964 -
965 - public static function decode_string( string $encoded_string, ?string $fallback = '' ) {
966 - try {
967 - return base64_decode( $encoded_string, true ) ?? $fallback;
968 - } catch ( \Exception $e ) {
969 - return $fallback;
970 - }
971 - }
972 -
973 - public static function encode_string( string $decoded_string ): string {
974 - return base64_encode( $decoded_string );
975 - }
976 -
977 - public static function html_to_plain_text( string $html ): string {
978 - if ( empty( $html ) ) {
979 - return '';
980 - }
981 -
982 - $text = preg_replace( '#<br\s*/?\s*>#i', ' ', $html );
983 - $text = preg_replace( '#</?[a-z][^>]*>#i', ' ', $text );
984 - $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
985 - $text = str_replace( "\xE2\x80\x8B", '', $text );
986 -
987 - return trim( preg_replace( '/\s+/', ' ', $text ) );
988 929 }
989 930 }