| @@ -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 ); |
| @@ -218,28 +186,20 @@ | ||
| 218 | 186 | throw new \Exception( 'Couldn’t replace your address because both of the URLs provided are identical. Try again by entering different URLs.' ); |
| 219 | 187 | } |
| 220 | 188 | |
| 221 | 189 | $is_valid_urls = ( filter_var( $from, FILTER_VALIDATE_URL ) && filter_var( $to, FILTER_VALIDATE_URL ) ); |
| 222 | - | |
| 223 | 190 | if ( ! $is_valid_urls ) { |
| 224 | 191 | throw new \Exception( 'Couldn’t replace your address because at least one of the URLs provided are invalid. Try again by entering valid URLs.' ); |
| 225 | 192 | } |
| 226 | 193 | |
| 227 | 194 | global $wpdb; |
| 228 | - $escaped_from = str_replace( '/', '\\/', $from ); | |
| 229 | - $escaped_to = str_replace( '/', '\\/', $to ); | |
| 230 | - $meta_value_like = '[%'; // meta_value LIKE '[%' are json formatted | |
| 231 | 195 | |
| 196 | + // @codingStandardsIgnoreStart cannot use `$wpdb->prepare` because it remove's the backslashes | |
| 232 | 197 | $rows_affected = $wpdb->query( |
| 233 | - $wpdb->prepare( | |
| 234 | - "UPDATE {$wpdb->postmeta} " . | |
| 235 | - 'SET `meta_value` = REPLACE(`meta_value`, %s, %s) ' . | |
| 236 | - "WHERE `meta_key` = '_elementor_data' AND `meta_value` LIKE %s;", | |
| 237 | - $escaped_from, | |
| 238 | - $escaped_to, | |
| 239 | - $meta_value_like | |
| 240 | - ) | |
| 241 | - ); | |
| 198 | + "UPDATE {$wpdb->postmeta} " . | |
| 199 | + "SET `meta_value` = REPLACE(`meta_value`, '" . str_replace( '/', '\\\/', $from ) . "', '" . str_replace( '/', '\\\/', $to ) . "') " . | |
| 200 | + "WHERE `meta_key` = '_elementor_data' AND `meta_value` LIKE '[%' ;" ); // meta_value LIKE '[%' are json formatted | |
| 201 | + // @codingStandardsIgnoreEnd | |
| 242 | 202 | |
| 243 | 203 | if ( false === $rows_affected ) { |
| 244 | 204 | throw new \Exception( 'An error occurred while replacing URL\'s.' ); |
| 245 | 205 | } |
| @@ -247,9 +207,8 @@ | ||
| 247 | 207 | // Allow externals to replace-urls, when they have to. |
| 248 | 208 | $rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $from, $to ); |
| 249 | 209 | |
| 250 | 210 | Plugin::$instance->files_manager->clear_cache(); |
| 251 | - Google_Font::clear_cache(); | |
| 252 | 211 | |
| 253 | 212 | return sprintf( |
| 254 | 213 | /* translators: %d: Number of rows. */ |
| 255 | 214 | _n( '%d database row affected.', '%d database rows affected.', $rows_affected, 'elementor' ), |
| @@ -280,9 +239,9 @@ | ||
| 280 | 239 | * |
| 281 | 240 | * Filters whether the post type supports editing with Elementor. |
| 282 | 241 | * |
| 283 | 242 | * @since 1.0.0 |
| 284 | - * @deprecated 2.2.0 Use `elementor/utils/is_post_support` hook Instead. | |
| 243 | + * @deprecated 2.2.0 Use `elementor/utils/is_post_support` Instead | |
| 285 | 244 | * |
| 286 | 245 | * @param bool $is_supported Whether the post type supports editing with Elementor. |
| 287 | 246 | * @param int $post_id Post ID. |
| 288 | 247 | * @param string $post_type Post type. |
| @@ -399,10 +358,10 @@ | ||
| 399 | 358 | if ( ! defined( 'DONOTCDN' ) ) { |
| 400 | 359 | define( 'DONOTCDN', true ); |
| 401 | 360 | } |
| 402 | 361 | |
| 403 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { | |
| 404 | - define( 'DONOTCACHEOBJECT', true ); | |
| 362 | + if ( ! defined( 'DONOTCACHCEOBJECT' ) ) { | |
| 363 | + define( 'DONOTCACHCEOBJECT', true ); | |
| 405 | 364 | } |
| 406 | 365 | |
| 407 | 366 | // Set the headers to prevent caching for the different browsers. |
| 408 | 367 | nocache_headers(); |
| @@ -441,12 +400,12 @@ | ||
| 441 | 400 | * Retrieve a custom URL for creating a new post/page using Elementor. |
| 442 | 401 | * |
| 443 | 402 | * @since 1.9.0 |
| 444 | 403 | * @access public |
| 445 | - * @deprecated 3.3.0 Use `Plugin::$instance->documents->get_create_new_post_url()` instead. | |
| 404 | + * @deprecated 3.3.0 | |
| 446 | 405 | * @static |
| 447 | 406 | * |
| 448 | - * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 407 | + * @param string $post_type Optional. Post type slug. Default is 'page'. | |
| 449 | 408 | * @param string|null $template_type Optional. Query arg 'template_type'. Default is null. |
| 450 | 409 | * |
| 451 | 410 | * @return string A URL for creating new post using Elementor. |
| 452 | 411 | */ |
| @@ -513,14 +472,14 @@ | ||
| 513 | 472 | * @since 2.1.2 |
| 514 | 473 | * @access public |
| 515 | 474 | * @static |
| 516 | 475 | */ |
| 517 | - public static function array_inject( $base_array, $key, $insert ) { | |
| 518 | - $length = array_search( $key, array_keys( $base_array ), true ) + 1; | |
| 476 | + public static function array_inject( $array, $key, $insert ) { | |
| 477 | + $length = array_search( $key, array_keys( $array ), true ) + 1; | |
| 519 | 478 | |
| 520 | - return array_slice( $base_array, 0, $length, true ) + | |
| 479 | + return array_slice( $array, 0, $length, true ) + | |
| 521 | 480 | $insert + |
| 522 | - array_slice( $base_array, $length, null, true ); | |
| 481 | + array_slice( $array, $length, null, true ); | |
| 523 | 482 | } |
| 524 | 483 | |
| 525 | 484 | /** |
| 526 | 485 | * Render html attributes |
| @@ -564,9 +523,9 @@ | ||
| 564 | 523 | * Viewport meta tag. |
| 565 | 524 | * |
| 566 | 525 | * Filters the meta tag containing the viewport information. |
| 567 | 526 | * |
| 568 | - * This hook can be used to change the initial viewport meta tag set by Elementor | |
| 527 | + * This hook can be used to change the intial viewport meta tag set by Elementor | |
| 569 | 528 | * and replace it with a different viewport tag. |
| 570 | 529 | * |
| 571 | 530 | * @since 2.5.0 |
| 572 | 531 | * |
| @@ -581,12 +540,11 @@ | ||
| 581 | 540 | /** |
| 582 | 541 | * Add Elementor Config js vars to the relevant script handle, |
| 583 | 542 | * WP will wrap it with <script> tag. |
| 584 | 543 | * To make sure this script runs thru the `script_loader_tag` hook, use a known handle value. |
| 585 | - * | |
| 586 | 544 | * @param string $handle |
| 587 | 545 | * @param string $js_var |
| 588 | - * @param mixed $config | |
| 546 | + * @param mixed $config | |
| 589 | 547 | */ |
| 590 | 548 | public static function print_js_config( $handle, $js_var, $config ) { |
| 591 | 549 | $config = wp_json_encode( $config ); |
| 592 | 550 | |
| @@ -616,9 +574,9 @@ | ||
| 616 | 574 | |
| 617 | 575 | /** |
| 618 | 576 | * Checks a control value for being empty, including a string of '0' not covered by PHP's empty(). |
| 619 | 577 | * |
| 620 | - * @param mixed $source | |
| 578 | + * @param mixed $source | |
| 621 | 579 | * @param bool|string $key |
| 622 | 580 | * |
| 623 | 581 | * @return bool |
| 624 | 582 | */ |
| @@ -637,30 +595,15 @@ | ||
| 637 | 595 | public static function has_pro() { |
| 638 | 596 | return defined( 'ELEMENTOR_PRO_VERSION' ); |
| 639 | 597 | } |
| 640 | 598 | |
| 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 | 599 | /** |
| 657 | 600 | * Convert HTMLEntities to UTF-8 characters |
| 658 | 601 | * |
| 659 | - * @param string $html_string | |
| 602 | + * @param $string | |
| 660 | 603 | * @return string |
| 661 | 604 | */ |
| 662 | - public static function urlencode_html_entities( $html_string ) { | |
| 605 | + public static function urlencode_html_entities( $string ) { | |
| 663 | 606 | $entities_dictionary = [ |
| 664 | 607 | '‘' => "'", // Opening single quote |
| 665 | 608 | '’' => "'", // Closing single quote |
| 666 | 609 | '“' => '"', // Closing double quote |
| @@ -673,11 +616,11 @@ | ||
| 673 | 616 | '„' => '"', // Double low quote |
| 674 | 617 | ]; |
| 675 | 618 | |
| 676 | 619 | // Decode decimal entities |
| 677 | - $html_string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $html_string ); | |
| 620 | + $string = str_replace( array_keys( $entities_dictionary ), array_values( $entities_dictionary ), $string ); | |
| 678 | 621 | |
| 679 | - return rawurlencode( html_entity_decode( $html_string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); | |
| 622 | + return rawurlencode( html_entity_decode( $string, ENT_QUOTES | ENT_HTML5, 'UTF-8' ) ); | |
| 680 | 623 | } |
| 681 | 624 | |
| 682 | 625 | /** |
| 683 | 626 | * Parse attributes that come as a string of comma-delimited key|value pairs. |
| @@ -750,10 +693,10 @@ | ||
| 750 | 693 | * Fired by `admin_menu` action. |
| 751 | 694 | * |
| 752 | 695 | * @since 3.1.0 |
| 753 | 696 | * |
| 754 | - * @param string $menu_slug | |
| 755 | - * @param string $new_label | |
| 697 | + * @param $menu_slug | |
| 698 | + * @param $new_label | |
| 756 | 699 | * @access public |
| 757 | 700 | */ |
| 758 | 701 | public static function change_submenu_first_item_label( $menu_slug, $new_label ) { |
| 759 | 702 | global $submenu; |
| @@ -772,9 +715,9 @@ | ||
| 772 | 715 | * |
| 773 | 716 | * @return string |
| 774 | 717 | */ |
| 775 | 718 | public static function validate_html_tag( $tag ) { |
| 776 | - return $tag && in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS ) ? $tag : 'div'; | |
| 719 | + return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS ) ? $tag : 'div'; | |
| 777 | 720 | } |
| 778 | 721 | |
| 779 | 722 | /** |
| 780 | 723 | * Safe print a validated HTML tag. |
| @@ -788,10 +731,10 @@ | ||
| 788 | 731 | |
| 789 | 732 | /** |
| 790 | 733 | * Print internal content (not user input) without escaping. |
| 791 | 734 | */ |
| 792 | - public static function print_unescaped_internal_string( $internal_string ) { | |
| 793 | - echo $internal_string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 735 | + public static function print_unescaped_internal_string( $string ) { | |
| 736 | + echo $string; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 794 | 737 | } |
| 795 | 738 | |
| 796 | 739 | /** |
| 797 | 740 | * Get recently edited posts query. |
| @@ -816,9 +759,9 @@ | ||
| 816 | 759 | |
| 817 | 760 | return new \WP_Query( $args ); |
| 818 | 761 | } |
| 819 | 762 | |
| 820 | - public static function print_wp_kses_extended( $text, array $tags ) { | |
| 763 | + public static function print_wp_kses_extended( $string, array $tags ) { | |
| 821 | 764 | $allowed_html = wp_kses_allowed_html( 'post' ); |
| 822 | 765 | |
| 823 | 766 | foreach ( $tags as $tag ) { |
| 824 | 767 | if ( isset( self::EXTENDED_ALLOWED_HTML_TAGS[ $tag ] ) ) { |
| @@ -826,9 +769,9 @@ | ||
| 826 | 769 | $allowed_html = array_replace_recursive( $allowed_html, $extended_tags ); |
| 827 | 770 | } |
| 828 | 771 | } |
| 829 | 772 | |
| 830 | - echo wp_kses( $text, $allowed_html ); | |
| 773 | + echo wp_kses( $string, $allowed_html ); | |
| 831 | 774 | } |
| 832 | 775 | |
| 833 | 776 | public static function is_elementor_path( $path ) { |
| 834 | 777 | $path = wp_normalize_path( $path ); |
| @@ -852,10 +795,10 @@ | ||
| 852 | 795 | } ); |
| 853 | 796 | } |
| 854 | 797 | |
| 855 | 798 | /** |
| 856 | - * @param string $file | |
| 857 | - * @param mixed ...$args | |
| 799 | + * @param $file | |
| 800 | + * @param mixed ...$args | |
| 858 | 801 | * @return false|string |
| 859 | 802 | */ |
| 860 | 803 | public static function file_get_contents( $file, ...$args ) { |
| 861 | 804 | if ( ! is_file( $file ) || ! is_readable( $file ) ) { |
| @@ -860,8 +803,9 @@ | ||
| 860 | 803 | public static function file_get_contents( $file, ...$args ) { |
| 861 | 804 | if ( ! is_file( $file ) || ! is_readable( $file ) ) { |
| 862 | 805 | return false; |
| 863 | 806 | } |
| 807 | + | |
| 864 | 808 | return file_get_contents( $file, ...$args ); |
| 865 | 809 | } |
| 866 | 810 | |
| 867 | 811 | public static function get_super_global_value( $super_global, $key ) { |
| @@ -868,109 +812,31 @@ | ||
| 868 | 812 | if ( ! isset( $super_global[ $key ] ) ) { |
| 869 | 813 | return null; |
| 870 | 814 | } |
| 871 | 815 | |
| 872 | - if ( $_FILES === $super_global ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 873 | - return isset( $super_global[ $key ]['name'] ) ? | |
| 874 | - self::sanitize_file_name( $super_global[ $key ] ) : | |
| 875 | - self::sanitize_multi_upload( $super_global[ $key ] ); | |
| 816 | + if ( $_FILES === $super_global ) { | |
| 817 | + $super_global[ $key ]['name'] = sanitize_file_name( $super_global[ $key ]['name'] ); | |
| 818 | + | |
| 819 | + return $super_global[ $key ]; | |
| 876 | 820 | } |
| 877 | 821 | |
| 878 | 822 | return wp_kses_post_deep( wp_unslash( $super_global[ $key ] ) ); |
| 879 | 823 | } |
| 880 | 824 | |
| 881 | - private static function sanitize_multi_upload( $fields ) { | |
| 882 | - return array_map( function( $field ) { | |
| 883 | - return array_map( 'self::sanitize_file_name', $field ); | |
| 884 | - }, $fields ); | |
| 885 | - } | |
| 886 | - | |
| 887 | - private static function sanitize_file_name( $file ) { | |
| 888 | - $file['name'] = sanitize_file_name( $file['name'] ); | |
| 889 | - | |
| 890 | - return $file; | |
| 891 | - } | |
| 892 | - | |
| 893 | 825 | /** |
| 894 | 826 | * Return specific object property value if exist from array of keys. |
| 895 | 827 | * |
| 896 | - * @param array $base_array | |
| 897 | - * @param array $keys | |
| 898 | - * @return mixed|null | |
| 828 | + * @param $array | |
| 829 | + * @param $keys | |
| 830 | + * @return key|false | |
| 899 | 831 | */ |
| 900 | - public static function get_array_value_by_keys( $base_array, $keys ) { | |
| 832 | + public static function get_array_value_by_keys( $array, $keys ) { | |
| 901 | 833 | $keys = (array) $keys; |
| 902 | 834 | foreach ( $keys as $key ) { |
| 903 | - if ( ! isset( $base_array[ $key ] ) ) { | |
| 835 | + if ( ! isset( $array[ $key ] ) ) { | |
| 904 | 836 | return null; |
| 905 | 837 | } |
| 906 | - $base_array = $base_array[ $key ]; | |
| 838 | + $array = $array[ $key ]; | |
| 907 | 839 | } |
| 908 | - return $base_array; | |
| 909 | - } | |
| 910 | - | |
| 911 | - public static function get_cached_callback( $callback, $cache_key, $cache_time = 24 * HOUR_IN_SECONDS ) { | |
| 912 | - $cache = get_site_transient( $cache_key ); | |
| 913 | - | |
| 914 | - if ( ! $cache ) { | |
| 915 | - $cache = call_user_func( $callback ); | |
| 916 | - | |
| 917 | - if ( ! is_wp_error( $cache ) ) { | |
| 918 | - set_site_transient( $cache_key, $cache, $cache_time ); | |
| 919 | - } | |
| 920 | - } | |
| 921 | - | |
| 922 | - return $cache; | |
| 923 | - } | |
| 924 | - | |
| 925 | - 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 ); | |
| 928 | - | |
| 929 | - $now_time = gmdate( 'U' ); | |
| 930 | - | |
| 931 | - return $now_time >= $sale_start_time && $now_time <= $sale_end_time; | |
| 932 | - } | |
| 933 | - | |
| 934 | - public static function safe_throw( string $message ) { | |
| 935 | - if ( ! static::is_elementor_debug() ) { | |
| 936 | - return; | |
| 937 | - } | |
| 938 | - | |
| 939 | - throw new \Exception( esc_html( $message ) ); | |
| 940 | - } | |
| 941 | - | |
| 942 | - public static function has_invalid_post_permissions( $post ): bool { | |
| 943 | - $is_image_attachment = 'attachment' === $post->post_type && strpos( $post->post_mime_type, 'image/' ) === 0; | |
| 944 | - | |
| 945 | - if ( $is_image_attachment ) { | |
| 946 | - return false; | |
| 947 | - } | |
| 948 | - | |
| 949 | - $is_private = 'private' === $post->post_status | |
| 950 | - && ! current_user_can( 'read_private_posts', $post->ID ); | |
| 951 | - | |
| 952 | - $not_allowed = 'publish' !== $post->post_status | |
| 953 | - && ! current_user_can( 'edit_post', $post->ID ); | |
| 954 | - | |
| 955 | - $password_required = post_password_required( $post->ID ) | |
| 956 | - && ! current_user_can( 'edit_post', $post->ID ); | |
| 957 | - | |
| 958 | - 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 ); | |
| 840 | + return $array; | |
| 975 | 841 | } |
| 976 | 842 | } |