| @@ -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. |
| @@ -22,9 +21,9 @@ | ||
| 22 | 21 | |
| 23 | 22 | const EDITOR_BREAK_LINES_OPTION_KEY = 'elementor_editor_break_lines'; |
| 24 | 23 | |
| 25 | 24 | /** |
| 26 | - * A list of safe tags for `validate_html_tag` method. | |
| 25 | + * A list of safe tage for `validate_html_tag` method. | |
| 27 | 26 | */ |
| 28 | 27 | const ALLOWED_HTML_WRAPPER_TAGS = [ |
| 29 | 28 | 'a', |
| 30 | 29 | 'article', |
| @@ -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,9 +107,9 @@ | ||
| 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 | } |
| @@ -131,27 +114,12 @@ | ||
| 131 | 114 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG; |
| 132 | 115 | } |
| 133 | 116 | |
| 134 | 117 | /** |
| 135 | - * Whether Elementor debug is enabled or not. | |
| 118 | + * Whether elementor test mode is enabled or not. | |
| 136 | 119 | * |
| 137 | - * @access public | |
| 138 | - * @static | |
| 139 | - * | |
| 140 | 120 | * @return bool |
| 141 | 121 | */ |
| 142 | - public static function is_elementor_debug() { | |
| 143 | - return defined( 'ELEMENTOR_DEBUG' ) && ELEMENTOR_DEBUG; | |
| 144 | - } | |
| 145 | - | |
| 146 | - /** | |
| 147 | - * Whether Elementor test mode is enabled or not. | |
| 148 | - * | |
| 149 | - * @access public | |
| 150 | - * @static | |
| 151 | - * | |
| 152 | - * @return bool | |
| 153 | - */ | |
| 154 | 122 | public static function is_elementor_tests() { |
| 155 | 123 | return defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS; |
| 156 | 124 | } |
| 157 | 125 | |
| @@ -195,13 +163,13 @@ | ||
| 195 | 163 | * @since 2.1.0 |
| 196 | 164 | * @static |
| 197 | 165 | * @access public |
| 198 | 166 | * |
| 199 | - * @param string $from | |
| 200 | - * @param string $to | |
| 167 | + * @param $from | |
| 168 | + * @param $to | |
| 201 | 169 | * |
| 202 | 170 | * @return string |
| 203 | - * @throws \Exception If URLs are missing or invalid URLs provided. | |
| 171 | + * @throws \Exception | |
| 204 | 172 | */ |
| 205 | 173 | public static function replace_urls( $from, $to ) { |
| 206 | 174 | $from = trim( $from ); |
| 207 | 175 | $to = trim( $to ); |
| @@ -247,9 +215,8 @@ | ||
| 247 | 215 | // Allow externals to replace-urls, when they have to. |
| 248 | 216 | $rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $from, $to ); |
| 249 | 217 | |
| 250 | 218 | Plugin::$instance->files_manager->clear_cache(); |
| 251 | - Google_Font::clear_cache(); | |
| 252 | 219 | |
| 253 | 220 | return sprintf( |
| 254 | 221 | /* translators: %d: Number of rows. */ |
| 255 | 222 | _n( '%d database row affected.', '%d database rows affected.', $rows_affected, 'elementor' ), |
| @@ -444,9 +411,9 @@ | ||
| 444 | 411 | * @access public |
| 445 | 412 | * @deprecated 3.3.0 Use `Plugin::$instance->documents->get_create_new_post_url()` instead. |
| 446 | 413 | * @static |
| 447 | 414 | * |
| 448 | - * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 415 | + * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 449 | 416 | * @param string|null $template_type Optional. Query arg 'template_type'. Default is null. |
| 450 | 417 | * |
| 451 | 418 | * @return string A URL for creating new post using Elementor. |
| 452 | 419 | */ |
| @@ -513,14 +480,14 @@ | ||
| 513 | 480 | * @since 2.1.2 |
| 514 | 481 | * @access public |
| 515 | 482 | * @static |
| 516 | 483 | */ |
| 517 | - public static function array_inject( $base_array, $key, $insert ) { | |
| 518 | - $length = array_search( $key, array_keys( $base_array ), true ) + 1; | |
| 484 | + public static function array_inject( $array, $key, $insert ) { | |
| 485 | + $length = array_search( $key, array_keys( $array ), true ) + 1; | |
| 519 | 486 | |
| 520 | - return array_slice( $base_array, 0, $length, true ) + | |
| 487 | + return array_slice( $array, 0, $length, true ) + | |
| 521 | 488 | $insert + |
| 522 | - array_slice( $base_array, $length, null, true ); | |
| 489 | + array_slice( $array, $length, null, true ); | |
| 523 | 490 | } |
| 524 | 491 | |
| 525 | 492 | /** |
| 526 | 493 | * Render html attributes |
| @@ -564,9 +531,9 @@ | ||
| 564 | 531 | * Viewport meta tag. |
| 565 | 532 | * |
| 566 | 533 | * Filters the meta tag containing the viewport information. |
| 567 | 534 | * |
| 568 | - * This hook can be used to change the initial viewport meta tag set by Elementor | |
| 535 | + * This hook can be used to change the intial viewport meta tag set by Elementor | |
| 569 | 536 | * and replace it with a different viewport tag. |
| 570 | 537 | * |
| 571 | 538 | * @since 2.5.0 |
| 572 | 539 | * |
| @@ -581,12 +548,11 @@ | ||
| 581 | 548 | /** |
| 582 | 549 | * Add Elementor Config js vars to the relevant script handle, |
| 583 | 550 | * WP will wrap it with <script> tag. |
| 584 | 551 | * To make sure this script runs thru the `script_loader_tag` hook, use a known handle value. |
| 585 | - * | |
| 586 | 552 | * @param string $handle |
| 587 | 553 | * @param string $js_var |
| 588 | - * @param mixed $config | |
| 554 | + * @param mixed $config | |
| 589 | 555 | */ |
| 590 | 556 | public static function print_js_config( $handle, $js_var, $config ) { |
| 591 | 557 | $config = wp_json_encode( $config ); |
| 592 | 558 | |
| @@ -616,9 +582,9 @@ | ||
| 616 | 582 | |
| 617 | 583 | /** |
| 618 | 584 | * Checks a control value for being empty, including a string of '0' not covered by PHP's empty(). |
| 619 | 585 | * |
| 620 | - * @param mixed $source | |
| 586 | + * @param mixed $source | |
| 621 | 587 | * @param bool|string $key |
| 622 | 588 | * |
| 623 | 589 | * @return bool |
| 624 | 590 | */ |
| @@ -637,34 +603,15 @@ | ||
| 637 | 603 | public static function has_pro() { |
| 638 | 604 | return defined( 'ELEMENTOR_PRO_VERSION' ); |
| 639 | 605 | } |
| 640 | 606 | |
| 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 | 607 | /** |
| 661 | 608 | * Convert HTMLEntities to UTF-8 characters |
| 662 | 609 | * |
| 663 | - * @param string $html_string | |
| 610 | + * @param $string | |
| 664 | 611 | * @return string |
| 665 | 612 | */ |
| 666 | - public static function urlencode_html_entities( $html_string ) { | |
| 613 | + public static function urlencode_html_entities( $string ) { | |
| 667 | 614 | $entities_dictionary = [ |
| 668 | 615 | '‘' => "'", // Opening single quote |
| 669 | 616 | '’' => "'", // Closing single quote |
| 670 | 617 | '“' => '"', // Closing double quote |
| @@ -677,11 +624,11 @@ | ||
| 677 | 624 | '„' => '"', // Double low quote |
| 678 | 625 | ]; |
| 679 | 626 | |
| 680 | 627 | // Decode decimal entities |
| 681 | - $html_string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $html_string ); | |
| 628 | + $string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $string ); | |
| 682 | 629 | |
| 683 | - return rawurlencode( html_entity_decode( $html_string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); | |
| 630 | + return rawurlencode( html_entity_decode( $string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); | |
| 684 | 631 | } |
| 685 | 632 | |
| 686 | 633 | /** |
| 687 | 634 | * Parse attributes that come as a string of comma-delimited key|value pairs. |
| @@ -733,19 +680,13 @@ | ||
| 733 | 680 | if ( $id === $element['id'] ) { |
| 734 | 681 | return $element; |
| 735 | 682 | } |
| 736 | 683 | |
| 737 | - $inner_elements = apply_filters( | |
| 738 | - 'elementor/utils/find_element_recursive/inner_elements', | |
| 739 | - $element['elements'] ?? [], | |
| 740 | - $element | |
| 741 | - ); | |
| 684 | + if ( ! empty( $element['elements'] ) ) { | |
| 685 | + $element = self::find_element_recursive( $element['elements'], $id ); | |
| 742 | 686 | |
| 743 | - if ( ! empty( $inner_elements ) ) { | |
| 744 | - $found = self::find_element_recursive( $inner_elements, $id ); | |
| 745 | - | |
| 746 | - if ( $found ) { | |
| 747 | - return $found; | |
| 687 | + if ( $element ) { | |
| 688 | + return $element; | |
| 748 | 689 | } |
| 749 | 690 | } |
| 750 | 691 | } |
| 751 | 692 | |
| @@ -760,10 +701,10 @@ | ||
| 760 | 701 | * Fired by `admin_menu` action. |
| 761 | 702 | * |
| 762 | 703 | * @since 3.1.0 |
| 763 | 704 | * |
| 764 | - * @param string $menu_slug | |
| 765 | - * @param string $new_label | |
| 705 | + * @param $menu_slug | |
| 706 | + * @param $new_label | |
| 766 | 707 | * @access public |
| 767 | 708 | */ |
| 768 | 709 | public static function change_submenu_first_item_label( $menu_slug, $new_label ) { |
| 769 | 710 | global $submenu; |
| @@ -798,10 +739,10 @@ | ||
| 798 | 739 | |
| 799 | 740 | /** |
| 800 | 741 | * Print internal content (not user input) without escaping. |
| 801 | 742 | */ |
| 802 | - public static function print_unescaped_internal_string( $internal_string ) { | |
| 803 | - echo $internal_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 743 | + public static function print_unescaped_internal_string( $string ) { | |
| 744 | + echo $string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 804 | 745 | } |
| 805 | 746 | |
| 806 | 747 | /** |
| 807 | 748 | * Get recently edited posts query. |
| @@ -826,9 +767,9 @@ | ||
| 826 | 767 | |
| 827 | 768 | return new \WP_Query( $args ); |
| 828 | 769 | } |
| 829 | 770 | |
| 830 | - public static function print_wp_kses_extended( $text, array $tags ) { | |
| 771 | + public static function print_wp_kses_extended( $string, array $tags ) { | |
| 831 | 772 | $allowed_html = wp_kses_allowed_html( 'post' ); |
| 832 | 773 | |
| 833 | 774 | foreach ( $tags as $tag ) { |
| 834 | 775 | if ( isset( self::EXTENDED_ALLOWED_HTML_TAGS[ $tag ] ) ) { |
| @@ -836,17 +777,11 @@ | ||
| 836 | 777 | $allowed_html = array_replace_recursive( $allowed_html, $extended_tags ); |
| 837 | 778 | } |
| 838 | 779 | } |
| 839 | 780 | |
| 840 | - echo wp_kses( $text, $allowed_html ); | |
| 781 | + echo wp_kses( $string, $allowed_html ); | |
| 841 | 782 | } |
| 842 | 783 | |
| 843 | - public static function kses_post_deep( $data ) { | |
| 844 | - return map_deep( $data, function ( $value ) { | |
| 845 | - return is_string( $value ) ? wp_kses_post( $value ) : $value; | |
| 846 | - } ); | |
| 847 | - } | |
| 848 | - | |
| 849 | 784 | public static function is_elementor_path( $path ) { |
| 850 | 785 | $path = wp_normalize_path( $path ); |
| 851 | 786 | |
| 852 | 787 | /** |
| @@ -868,10 +803,10 @@ | ||
| 868 | 803 | } ); |
| 869 | 804 | } |
| 870 | 805 | |
| 871 | 806 | /** |
| 872 | - * @param string $file | |
| 873 | - * @param mixed ...$args | |
| 807 | + * @param $file | |
| 808 | + * @param mixed ...$args | |
| 874 | 809 | * @return false|string |
| 875 | 810 | */ |
| 876 | 811 | public static function file_get_contents( $file, ...$args ) { |
| 877 | 812 | if ( ! is_file( $file ) || ! is_readable( $file ) ) { |
| @@ -876,8 +811,9 @@ | ||
| 876 | 811 | public static function file_get_contents( $file, ...$args ) { |
| 877 | 812 | if ( ! is_file( $file ) || ! is_readable( $file ) ) { |
| 878 | 813 | return false; |
| 879 | 814 | } |
| 815 | + | |
| 880 | 816 | return file_get_contents( $file, ...$args ); |
| 881 | 817 | } |
| 882 | 818 | |
| 883 | 819 | public static function get_super_global_value( $super_global, $key ) { |
| @@ -884,9 +820,9 @@ | ||
| 884 | 820 | if ( ! isset( $super_global[ $key ] ) ) { |
| 885 | 821 | return null; |
| 886 | 822 | } |
| 887 | 823 | |
| 888 | - if ( $_FILES === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 824 | + if ( $_FILES === $super_global ) { | |
| 889 | 825 | return isset( $super_global[ $key ]['name'] ) ? |
| 890 | 826 | self::sanitize_file_name( $super_global[ $key ] ) : |
| 891 | 827 | self::sanitize_multi_upload( $super_global[ $key ] ); |
| 892 | 828 | } |
| @@ -908,21 +844,21 @@ | ||
| 908 | 844 | |
| 909 | 845 | /** |
| 910 | 846 | * Return specific object property value if exist from array of keys. |
| 911 | 847 | * |
| 912 | - * @param array $base_array | |
| 913 | - * @param array $keys | |
| 914 | - * @return mixed|null | |
| 848 | + * @param $array | |
| 849 | + * @param $keys | |
| 850 | + * @return key|false | |
| 915 | 851 | */ |
| 916 | - public static function get_array_value_by_keys( $base_array, $keys ) { | |
| 852 | + public static function get_array_value_by_keys( $array, $keys ) { | |
| 917 | 853 | $keys = (array) $keys; |
| 918 | 854 | foreach ( $keys as $key ) { |
| 919 | - if ( ! isset( $base_array[ $key ] ) ) { | |
| 855 | + if ( ! isset( $array[ $key ] ) ) { | |
| 920 | 856 | return null; |
| 921 | 857 | } |
| 922 | - $base_array = $base_array[ $key ]; | |
| 858 | + $array = $array[ $key ]; | |
| 923 | 859 | } |
| 924 | - return $base_array; | |
| 860 | + return $array; | |
| 925 | 861 | } |
| 926 | 862 | |
| 927 | 863 | public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) { |
| 928 | 864 | $cache = get_site_transient( $cache_key ); |
| @@ -938,68 +874,12 @@ | ||
| 938 | 874 | return $cache; |
| 939 | 875 | } |
| 940 | 876 | |
| 941 | 877 | public static function is_sale_time(): bool { |
| 942 | - $sale_start_time = gmmktime( 10, 0, 0, 6, 15, 2026 ); | |
| 943 | - $sale_end_time = gmmktime( 3, 59, 0, 6, 17, 2026 ); | |
| 878 | + $sale_start_time = gmmktime( 12, 0, 0, 5, 28, 2024 ); | |
| 879 | + $sale_end_time = gmmktime( 4, 59, 0, 6, 4, 2024 ); | |
| 944 | 880 | |
| 945 | 881 | $now_time = gmdate( 'U' ); |
| 946 | 882 | |
| 947 | 883 | return $now_time >= $sale_start_time && $now_time <= $sale_end_time; |
| 948 | - } | |
| 949 | - | |
| 950 | - public static function safe_throw( string $message ) { | |
| 951 | - if ( ! static::is_elementor_debug() ) { | |
| 952 | - return; | |
| 953 | - } | |
| 954 | - | |
| 955 | - throw new \Exception( esc_html( $message ) ); | |
| 956 | - } | |
| 957 | - | |
| 958 | - public static function has_invalid_post_permissions( $post ): bool { | |
| 959 | - $is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0; | |
| 960 | - | |
| 961 | - if ( $is_image_attachment ) { | |
| 962 | - return false; | |
| 963 | - } | |
| 964 | - | |
| 965 | - $is_private = 'private' === $post->post_status | |
| 966 | - && ! current_user_can( 'read_private_posts', $post->ID ); | |
| 967 | - | |
| 968 | - $not_allowed = 'publish' !== $post->post_status | |
| 969 | - && ! current_user_can( 'edit_post', $post->ID ); | |
| 970 | - | |
| 971 | - $password_required = post_password_required( $post->ID ) | |
| 972 | - && ! current_user_can( 'edit_post', $post->ID ); | |
| 973 | - | |
| 974 | - return $is_private || $not_allowed || $password_required; | |
| 975 | - } | |
| 976 | - | |
| 977 | - public static function is_custom_kit_applied() { | |
| 978 | - return (bool) Plugin::$instance->kits_manager->get_previous_id(); | |
| 979 | - } | |
| 980 | - | |
| 981 | - public static function decode_string( string $encoded_string, ?string $fallback = '' ) { | |
| 982 | - try { | |
| 983 | - return base64_decode( $encoded_string, true ) ?? $fallback; | |
| 984 | - } catch ( \Exception $e ) { | |
| 985 | - return $fallback; | |
| 986 | - } | |
| 987 | - } | |
| 988 | - | |
| 989 | - public static function encode_string( string $decoded_string ): string { | |
| 990 | - return base64_encode( $decoded_string ); | |
| 991 | - } | |
| 992 | - | |
| 993 | - public static function html_to_plain_text( string $html ): string { | |
| 994 | - if ( empty( $html ) ) { | |
| 995 | - return ''; | |
| 996 | - } | |
| 997 | - | |
| 998 | - $text = preg_replace( '#<br\s*/?\s*>#i', ' ', $html ); | |
| 999 | - $text = preg_replace( '#</?[a-z][^>]*>#i', ' ', $text ); | |
| 1000 | - $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' ); | |
| 1001 | - $text = str_replace( "\xE2\x80\x8B", '', $text ); | |
| 1002 | - | |
| 1003 | - return trim( preg_replace( '/\s+/', ' ', $text ) ); | |
| 1004 | 884 | } |
| 1005 | 885 | } |