| @@ -42,9 +42,9 @@ | ||
| 42 | 42 | /** |
| 43 | 43 | * Filter: 'wpseo_allow_system_file_edit' - Allow developers to change whether the editing of |
| 44 | 44 | * .htaccess and robots.txt is allowed. |
| 45 | 45 | * |
| 46 | - * @api bool $allowed Whether file editing is allowed. | |
| 46 | + * @param bool $allowed Whether file editing is allowed. | |
| 47 | 47 | */ |
| 48 | 48 | return apply_filters( 'wpseo_allow_system_file_edit', $allowed ); |
| 49 | 49 | } |
| 50 | 50 | |
| @@ -109,9 +109,9 @@ | ||
| 109 | 109 | if ( is_string( $value ) ) { |
| 110 | 110 | $value = trim( $value ); |
| 111 | 111 | } |
| 112 | 112 | elseif ( is_array( $value ) ) { |
| 113 | - $value = array_map( [ __CLASS__, 'trim_recursive' ], $value ); | |
| 113 | + $value = array_map( [ self::class, 'trim_recursive' ], $value ); | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | return $value; |
| 117 | 117 | } |
| @@ -116,28 +116,8 @@ | ||
| 116 | 116 | return $value; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | - * Translates a decimal analysis score into a textual one. | |
| 121 | - * | |
| 122 | - * @since 1.8.0 | |
| 123 | - * | |
| 124 | - * @param int $val The decimal score to translate. | |
| 125 | - * @param bool $css_value Whether to return the i18n translated score or the CSS class value. | |
| 126 | - * | |
| 127 | - * @return string | |
| 128 | - */ | |
| 129 | - public static function translate_score( $val, $css_value = true ) { | |
| 130 | - $seo_rank = WPSEO_Rank::from_numeric_score( $val ); | |
| 131 | - | |
| 132 | - if ( $css_value ) { | |
| 133 | - return $seo_rank->get_css_class(); | |
| 134 | - } | |
| 135 | - | |
| 136 | - return $seo_rank->get_label(); | |
| 137 | - } | |
| 138 | - | |
| 139 | - /** | |
| 140 | 120 | * Emulate the WP native sanitize_text_field function in a %%variable%% safe way. |
| 141 | 121 | * |
| 142 | 122 | * Sanitize a string from user input or from the db. |
| 143 | 123 | * |
| @@ -202,8 +182,22 @@ | ||
| 202 | 182 | * @return string |
| 203 | 183 | */ |
| 204 | 184 | public static function sanitize_url( $value, $allowed_protocols = [ 'http', 'https' ] ) { |
| 205 | 185 | |
| 186 | + // Percent-encode non-ASCII bytes in the path/query/fragment before parsing, so wp_parse_url() | |
| 187 | + // does not corrupt multibyte UTF-8 characters. The authority (userinfo + host) is left untouched | |
| 188 | + // to avoid double-encoding it during the sanitization below. | |
| 189 | + if ( preg_match( '/[\x80-\xff]/', $value ) === 1 ) { | |
| 190 | + preg_match( '`^((?:[a-z][a-z0-9+.\-]*:)?//[^/?#]*)?(.*)$`is', $value, $split ); | |
| 191 | + $value = $split[1] . preg_replace_callback( | |
| 192 | + '/[\x80-\xff]/', | |
| 193 | + static function ( $bytes ) { | |
| 194 | + return rawurlencode( $bytes[0] ); | |
| 195 | + }, | |
| 196 | + $split[2], | |
| 197 | + ); | |
| 198 | + } | |
| 199 | + | |
| 206 | 200 | $url = ''; |
| 207 | 201 | $parts = wp_parse_url( $value ); |
| 208 | 202 | |
| 209 | 203 | if ( isset( $parts['scheme'], $parts['host'] ) ) { |
| @@ -217,18 +211,18 @@ | ||
| 217 | 211 | |
| 218 | 212 | $parts['host'] = preg_replace( |
| 219 | 213 | '`[^a-z0-9-.:\[\]\\x80-\\xff]`', |
| 220 | 214 | '', |
| 221 | - strtolower( $parts['host'] ) | |
| 215 | + strtolower( $parts['host'] ), | |
| 222 | 216 | ); |
| 223 | 217 | |
| 224 | - $url .= $parts['host'] . ( isset( $parts['port'] ) ? ':' . intval( $parts['port'] ) : '' ); | |
| 218 | + $url .= $parts['host'] . ( isset( $parts['port'] ) ? ':' . (int) $parts['port'] : '' ); | |
| 225 | 219 | } |
| 226 | 220 | |
| 227 | 221 | if ( isset( $parts['path'] ) && strpos( $parts['path'], '/' ) === 0 ) { |
| 228 | 222 | $path = explode( '/', wp_strip_all_tags( $parts['path'] ) ); |
| 229 | 223 | $path = self::sanitize_encoded_text_field( $path ); |
| 230 | - $url .= implode( '/', $path ); | |
| 224 | + $url .= str_replace( '%40', '@', implode( '/', $path ) ); | |
| 231 | 225 | } |
| 232 | 226 | |
| 233 | 227 | if ( ! $url ) { |
| 234 | 228 | return ''; |
| @@ -238,9 +232,9 @@ | ||
| 238 | 232 | wp_parse_str( $parts['query'], $parsed_query ); |
| 239 | 233 | |
| 240 | 234 | $parsed_query = array_combine( |
| 241 | 235 | self::sanitize_encoded_text_field( array_keys( $parsed_query ) ), |
| 242 | - self::sanitize_encoded_text_field( array_values( $parsed_query ) ) | |
| 236 | + self::sanitize_encoded_text_field( array_values( $parsed_query ) ), | |
| 243 | 237 | ); |
| 244 | 238 | |
| 245 | 239 | $url = add_query_arg( $parsed_query, $url ); |
| 246 | 240 | } |
| @@ -251,12 +245,12 @@ | ||
| 251 | 245 | |
| 252 | 246 | if ( strpos( $url, '%' ) !== false ) { |
| 253 | 247 | $url = preg_replace_callback( |
| 254 | 248 | '`%[a-fA-F0-9]{2}`', |
| 255 | - static function( $octects ) { | |
| 249 | + static function ( $octects ) { | |
| 256 | 250 | return strtolower( $octects[0] ); |
| 257 | 251 | }, |
| 258 | - $url | |
| 252 | + $url, | |
| 259 | 253 | ); |
| 260 | 254 | } |
| 261 | 255 | |
| 262 | 256 | return esc_url_raw( $url, $allowed_protocols ); |
| @@ -272,9 +266,9 @@ | ||
| 272 | 266 | * @return array|string The sanitized value. |
| 273 | 267 | */ |
| 274 | 268 | public static function sanitize_encoded_text_field( $value ) { |
| 275 | 269 | if ( is_array( $value ) ) { |
| 276 | - return array_map( [ __CLASS__, 'sanitize_encoded_text_field' ], $value ); | |
| 270 | + return array_map( [ self::class, 'sanitize_encoded_text_field' ], $value ); | |
| 277 | 271 | } |
| 278 | 272 | |
| 279 | 273 | return rawurlencode( sanitize_text_field( rawurldecode( $value ) ) ); |
| 280 | 274 | } |
| @@ -400,9 +394,9 @@ | ||
| 400 | 394 | if ( is_int( $value ) ) { |
| 401 | 395 | return $value; |
| 402 | 396 | } |
| 403 | 397 | elseif ( is_float( $value ) ) { |
| 404 | - // phpcs:ignore WordPress.PHP.StrictComparisons -- Purposeful loose comparison. | |
| 398 | + // phpcs:ignore Universal.Operators.StrictComparisons -- Purposeful loose comparison. | |
| 405 | 399 | if ( (int) $value == $value && ! is_nan( $value ) ) { |
| 406 | 400 | return (int) $value; |
| 407 | 401 | } |
| 408 | 402 | else { |
| @@ -431,12 +425,14 @@ | ||
| 431 | 425 | /** |
| 432 | 426 | * Clears the WP or W3TC cache depending on which is used. |
| 433 | 427 | * |
| 434 | 428 | * @since 1.8.0 |
| 429 | + * | |
| 430 | + * @return void | |
| 435 | 431 | */ |
| 436 | 432 | public static function clear_cache() { |
| 437 | - if ( function_exists( 'w3tc_pgcache_flush' ) ) { | |
| 438 | - w3tc_pgcache_flush(); | |
| 433 | + if ( function_exists( 'w3tc_flush_posts' ) ) { | |
| 434 | + w3tc_flush_posts(); | |
| 439 | 435 | } |
| 440 | 436 | elseif ( function_exists( 'wp_cache_clear_cache' ) ) { |
| 441 | 437 | wp_cache_clear_cache(); |
| 442 | 438 | } |
| @@ -445,11 +441,13 @@ | ||
| 445 | 441 | /** |
| 446 | 442 | * Clear rewrite rules. |
| 447 | 443 | * |
| 448 | 444 | * @since 1.8.0 |
| 445 | + * | |
| 446 | + * @return void | |
| 449 | 447 | */ |
| 450 | 448 | public static function clear_rewrites() { |
| 451 | - delete_option( 'rewrite_rules' ); | |
| 449 | + update_option( 'rewrite_rules', '' ); | |
| 452 | 450 | } |
| 453 | 451 | |
| 454 | 452 | /** |
| 455 | 453 | * Do simple reliable math calculations without the risk of wrong results. |
| @@ -525,9 +523,9 @@ | ||
| 525 | 523 | case 'divide': |
| 526 | 524 | if ( $bc ) { |
| 527 | 525 | $result = bcdiv( $number1, $number2, $precision ); // String, or NULL if right_operand is 0. |
| 528 | 526 | } |
| 529 | - elseif ( $number2 != 0 ) { // phpcs:ignore WordPress.PHP.StrictComparisons -- Purposeful loose comparison. | |
| 527 | + elseif ( $number2 != 0 ) { // phpcs:ignore Universal.Operators.StrictComparisons -- Purposeful loose comparison. | |
| 530 | 528 | $result = ( $number1 / $number2 ); |
| 531 | 529 | } |
| 532 | 530 | |
| 533 | 531 | if ( ! isset( $result ) ) { |
| @@ -540,9 +538,9 @@ | ||
| 540 | 538 | case 'modulus': |
| 541 | 539 | if ( $bc ) { |
| 542 | 540 | $result = bcmod( $number1, $number2 ); // String, or NULL if modulus is 0. |
| 543 | 541 | } |
| 544 | - elseif ( $number2 != 0 ) { // phpcs:ignore WordPress.PHP.StrictComparisons -- Purposeful loose comparison. | |
| 542 | + elseif ( $number2 != 0 ) { // phpcs:ignore Universal.Operators.StrictComparisons -- Purposeful loose comparison. | |
| 545 | 543 | $result = ( $number1 % $number2 ); |
| 546 | 544 | } |
| 547 | 545 | |
| 548 | 546 | if ( ! isset( $result ) ) { |
| @@ -557,9 +555,9 @@ | ||
| 557 | 555 | if ( $bc ) { |
| 558 | 556 | $result = bccomp( $number1, $number2, $precision ); // Returns int 0, 1 or -1. |
| 559 | 557 | } |
| 560 | 558 | else { |
| 561 | - // phpcs:ignore WordPress.PHP.StrictComparisons -- Purposeful loose comparison. | |
| 559 | + // phpcs:ignore Universal.Operators.StrictComparisons -- Purposeful loose comparison. | |
| 562 | 560 | $result = ( $number1 == $number2 ) ? 0 : ( ( $number1 > $number2 ) ? 1 : -1 ); |
| 563 | 561 | } |
| 564 | 562 | break; |
| 565 | 563 | } |
| @@ -566,16 +564,16 @@ | ||
| 566 | 564 | |
| 567 | 565 | if ( isset( $result ) ) { |
| 568 | 566 | if ( $compare === false ) { |
| 569 | 567 | if ( $round === true ) { |
| 570 | - $result = round( floatval( $result ), $decimals ); | |
| 568 | + $result = round( (float) $result, $decimals ); | |
| 571 | 569 | if ( $decimals === 0 ) { |
| 572 | 570 | $result = (int) $result; |
| 573 | 571 | } |
| 574 | 572 | } |
| 575 | 573 | else { |
| 576 | - // phpcs:ignore WordPress.PHP.StrictComparisons -- Purposeful loose comparison. | |
| 577 | - $result = ( intval( $result ) == $result ) ? intval( $result ) : floatval( $result ); | |
| 574 | + // phpcs:ignore Universal.Operators.StrictComparisons -- Purposeful loose comparison. | |
| 575 | + $result = ( intval( $result ) == $result ) ? (int) $result : (float) $result; | |
| 578 | 576 | } |
| 579 | 577 | } |
| 580 | 578 | |
| 581 | 579 | return $result; |
| @@ -678,15 +676,10 @@ | ||
| 678 | 676 | * @return bool |
| 679 | 677 | */ |
| 680 | 678 | public static function is_yoast_seo_free_page( $current_page ) { |
| 681 | 679 | $yoast_seo_free_pages = [ |
| 682 | - 'wpseo_dashboard', | |
| 683 | - 'wpseo_titles', | |
| 684 | - 'wpseo_social', | |
| 685 | - 'wpseo_advanced', | |
| 686 | 680 | 'wpseo_tools', |
| 687 | 681 | 'wpseo_search_console', |
| 688 | - 'wpseo_licenses', | |
| 689 | 682 | ]; |
| 690 | 683 | |
| 691 | 684 | return in_array( $current_page, $yoast_seo_free_pages, true ); |
| 692 | 685 | } |
| @@ -691,21 +684,8 @@ | ||
| 691 | 684 | return in_array( $current_page, $yoast_seo_free_pages, true ); |
| 692 | 685 | } |
| 693 | 686 | |
| 694 | 687 | /** |
| 695 | - * Checks if we are in the premium or free plugin. | |
| 696 | - * | |
| 697 | - * @deprecated 16.0 | |
| 698 | - * @codeCoverageIgnore | |
| 699 | - * | |
| 700 | - * @return bool True when we are in the premium plugin. | |
| 701 | - */ | |
| 702 | - public static function is_yoast_seo_premium() { | |
| 703 | - _deprecated_function( __FUNCTION__, '16.0', 'YoastSEO()->helpers->product->is_premium' ); | |
| 704 | - return YoastSEO()->helpers->product->is_premium(); | |
| 705 | - } | |
| 706 | - | |
| 707 | - /** | |
| 708 | 688 | * Determine if Yoast SEO is in development mode? |
| 709 | 689 | * |
| 710 | 690 | * Inspired by JetPack (https://github.com/Automattic/jetpack/blob/master/class.jetpack.php#L1383-L1406). |
| 711 | 691 | * |
| @@ -825,9 +805,9 @@ | ||
| 825 | 805 | |
| 826 | 806 | /** |
| 827 | 807 | * Determines whether the plugin is active for the entire network. |
| 828 | 808 | * |
| 829 | - * @return bool Whether or not the plugin is network-active. | |
| 809 | + * @return bool Whether the plugin is network-active. | |
| 830 | 810 | */ |
| 831 | 811 | public static function is_plugin_network_active() { |
| 832 | 812 | return YoastSEO()->helpers->url->is_plugin_network_active(); |
| 833 | 813 | } |
| @@ -837,17 +817,13 @@ | ||
| 837 | 817 | * |
| 838 | 818 | * @return string The post type, or an empty string. |
| 839 | 819 | */ |
| 840 | 820 | public static function get_post_type() { |
| 841 | - global $post; | |
| 821 | + $wp_screen = get_current_screen(); | |
| 842 | 822 | |
| 843 | - if ( isset( $post->post_type ) ) { | |
| 844 | - return $post->post_type; | |
| 823 | + if ( $wp_screen !== null && ! empty( $wp_screen->post_type ) ) { | |
| 824 | + return $wp_screen->post_type; | |
| 845 | 825 | } |
| 846 | - elseif ( isset( $_GET['post_type'] ) ) { | |
| 847 | - return sanitize_text_field( wp_unslash( $_GET['post_type'] ) ); | |
| 848 | - } | |
| 849 | - | |
| 850 | 826 | return ''; |
| 851 | 827 | } |
| 852 | 828 | |
| 853 | 829 | /** |
| @@ -882,10 +858,14 @@ | ||
| 882 | 858 | } |
| 883 | 859 | else { |
| 884 | 860 | $label_object = WPSEO_Taxonomy::get_labels(); |
| 885 | 861 | |
| 886 | - $taxonomy_slug = filter_input( INPUT_GET, 'taxonomy', FILTER_DEFAULT, [ 'options' => [ 'default' => '' ] ] ); | |
| 887 | - $no_index = WPSEO_Options::get( 'noindex-tax-' . $taxonomy_slug, false ); | |
| 862 | + $wp_screen = get_current_screen(); | |
| 863 | + | |
| 864 | + if ( $wp_screen !== null && ! empty( $wp_screen->taxonomy ) ) { | |
| 865 | + $taxonomy_slug = $wp_screen->taxonomy; | |
| 866 | + $no_index = WPSEO_Options::get( 'noindex-tax-' . $taxonomy_slug, false ); | |
| 867 | + } | |
| 888 | 868 | } |
| 889 | 869 | |
| 890 | 870 | $wpseo_admin_l10n = [ |
| 891 | 871 | 'displayAdvancedTab' => WPSEO_Capability_Utils::current_user_can( 'wpseo_edit_advanced_metadata' ) || ! WPSEO_Options::get( 'disableadvanced_meta' ), |
| @@ -894,10 +874,9 @@ | ||
| 894 | 874 | 'postType' => get_post_type(), |
| 895 | 875 | 'postTypeNamePlural' => ( $page_type === 'post' ) ? $label_object->label : $label_object->name, |
| 896 | 876 | 'postTypeNameSingular' => ( $page_type === 'post' ) ? $label_object->labels->singular_name : $label_object->singular_name, |
| 897 | 877 | 'isBreadcrumbsDisabled' => WPSEO_Options::get( 'breadcrumbs-enable', false ) !== true && ! current_theme_supports( 'yoast-seo-breadcrumbs' ), |
| 898 | - // phpcs:ignore Generic.ControlStructures.DisallowYodaConditions -- Bug: squizlabs/PHP_CodeSniffer#2962. | |
| 899 | - 'isPrivateBlog' => ( (string) get_option( 'blog_public' ) ) === '0', | |
| 878 | + 'isAiFeatureActive' => (bool) WPSEO_Options::get( 'enable_ai_generator' ), | |
| 900 | 879 | ]; |
| 901 | 880 | |
| 902 | 881 | $additional_entries = apply_filters( 'wpseo_admin_l10n', [] ); |
| 903 | 882 | if ( is_array( $additional_entries ) ) { |
| @@ -943,12 +922,12 @@ | ||
| 943 | 922 | * Prepares data for outputting as JSON. |
| 944 | 923 | * |
| 945 | 924 | * @param array $data The data to format. |
| 946 | 925 | * |
| 947 | - * @return false|string The prepared JSON string. | |
| 926 | + * @return string|false The prepared JSON string. | |
| 948 | 927 | */ |
| 949 | 928 | public static function format_json_encode( $data ) { |
| 950 | - $flags = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; | |
| 929 | + $flags = JSON_UNESCAPED_UNICODE; | |
| 951 | 930 | |
| 952 | 931 | if ( self::is_development_mode() ) { |
| 953 | 932 | $flags = ( $flags | JSON_PRETTY_PRINT ); |
| 954 | 933 | |
| @@ -954,14 +933,14 @@ | ||
| 954 | 933 | |
| 955 | 934 | /** |
| 956 | 935 | * Filter the Yoast SEO development mode. |
| 957 | 936 | * |
| 958 | - * @api array $data Allows filtering of the JSON data for debug purposes. | |
| 937 | + * @param array $data Allows filtering of the JSON data for debug purposes. | |
| 959 | 938 | */ |
| 960 | 939 | $data = apply_filters( 'wpseo_debug_json_data', $data ); |
| 961 | 940 | } |
| 962 | 941 | |
| 963 | - // phpcs:ignore Yoast.Yoast.AlternativeFunctions.json_encode_wp_json_encodeWithAdditionalParams -- This is the definition of format_json_encode. | |
| 942 | + // phpcs:ignore Yoast.Yoast.JsonEncodeAlternative.FoundWithAdditionalParams -- This is the definition of format_json_encode. | |
| 964 | 943 | return wp_json_encode( $data, $flags ); |
| 965 | 944 | } |
| 966 | 945 | |
| 967 | 946 | /** |
| @@ -1124,297 +1103,10 @@ | ||
| 1124 | 1103 | public static function retrieve_enabled_features() { |
| 1125 | 1104 | /** |
| 1126 | 1105 | * The feature flag integration. |
| 1127 | 1106 | * |
| 1128 | - * @var Feature_Flag_Integration $feature_flag_integration; | |
| 1107 | + * @var Feature_Flag_Integration $feature_flag_integration | |
| 1129 | 1108 | */ |
| 1130 | 1109 | $feature_flag_integration = YoastSEO()->classes->get( Feature_Flag_Integration::class ); |
| 1131 | 1110 | return $feature_flag_integration->get_enabled_features(); |
| 1132 | - } | |
| 1133 | - | |
| 1134 | - /* ********************* DEPRECATED METHODS ********************* */ | |
| 1135 | - | |
| 1136 | - /** | |
| 1137 | - * List all the available user roles. | |
| 1138 | - * | |
| 1139 | - * @since 1.8.0 | |
| 1140 | - * @deprecated 15.0 | |
| 1141 | - * @codeCoverageIgnore | |
| 1142 | - * | |
| 1143 | - * @return array | |
| 1144 | - */ | |
| 1145 | - public static function get_roles() { | |
| 1146 | - _deprecated_function( __METHOD__, '15.0', 'wp_roles()->get_names()' ); | |
| 1147 | - $yoast_seo_wp_roles = wp_roles(); | |
| 1148 | - | |
| 1149 | - $roles = $yoast_seo_wp_roles->get_names(); | |
| 1150 | - | |
| 1151 | - return $roles; | |
| 1152 | - } | |
| 1153 | - | |
| 1154 | - /** | |
| 1155 | - * Checks if the current installation supports MyYoast access tokens. | |
| 1156 | - * | |
| 1157 | - * @deprecated 15.0 | |
| 1158 | - * @codeCoverageIgnore | |
| 1159 | - * | |
| 1160 | - * @return bool True if access_tokens are supported. | |
| 1161 | - */ | |
| 1162 | - public static function has_access_token_support() { | |
| 1163 | - _deprecated_function( __METHOD__, 'WPSEO 15.0' ); | |
| 1164 | - return false; | |
| 1165 | - } | |
| 1166 | - | |
| 1167 | - /** | |
| 1168 | - * Standardize whitespace in a string. | |
| 1169 | - * | |
| 1170 | - * Replace line breaks, carriage returns, tabs with a space, then remove double spaces. | |
| 1171 | - * | |
| 1172 | - * @since 1.8.0 | |
| 1173 | - * @deprecated 15.2 | |
| 1174 | - * @codeCoverageIgnore | |
| 1175 | - * | |
| 1176 | - * @param string $text String input to standardize. | |
| 1177 | - * | |
| 1178 | - * @return string | |
| 1179 | - */ | |
| 1180 | - public static function standardize_whitespace( $text ) { | |
| 1181 | - _deprecated_function( __METHOD__, 'WPSEO 15.2' ); | |
| 1182 | - | |
| 1183 | - return YoastSEO()->helpers->string->standardize_whitespace( $text ); | |
| 1184 | - } | |
| 1185 | - | |
| 1186 | - /** | |
| 1187 | - * First strip out registered and enclosing shortcodes using native WordPress strip_shortcodes function. | |
| 1188 | - * Then strip out the shortcodes with a filthy regex, because people don't properly register their shortcodes. | |
| 1189 | - * | |
| 1190 | - * @since 1.8.0 | |
| 1191 | - * @deprecated 15.2 | |
| 1192 | - * @codeCoverageIgnore | |
| 1193 | - * | |
| 1194 | - * @param string $text Input string that might contain shortcodes. | |
| 1195 | - * | |
| 1196 | - * @return string String without shortcodes. | |
| 1197 | - */ | |
| 1198 | - public static function strip_shortcode( $text ) { | |
| 1199 | - _deprecated_function( __METHOD__, 'WPSEO 15.2' ); | |
| 1200 | - | |
| 1201 | - return YoastSEO()->helpers->string->strip_shortcode( $text ); | |
| 1202 | - } | |
| 1203 | - | |
| 1204 | - /** | |
| 1205 | - * Retrieves the title separator. | |
| 1206 | - * | |
| 1207 | - * @since 3.0.0 | |
| 1208 | - * @deprecated 15.2 | |
| 1209 | - * @codeCoverageIgnore | |
| 1210 | - * | |
| 1211 | - * @return string | |
| 1212 | - */ | |
| 1213 | - public static function get_title_separator() { | |
| 1214 | - _deprecated_function( __METHOD__, 'WPSEO 15.2', 'Yoast\WP\SEO\Helpers\Options_Helper::get_title_separator' ); | |
| 1215 | - | |
| 1216 | - return YoastSEO()->helpers->options->get_title_separator(); | |
| 1217 | - } | |
| 1218 | - | |
| 1219 | - /** | |
| 1220 | - * Flush W3TC cache after successful update/add of taxonomy meta option. | |
| 1221 | - * | |
| 1222 | - * @since 1.8.0 | |
| 1223 | - * @deprecated 15.3 | |
| 1224 | - * @codeCoverageIgnore | |
| 1225 | - */ | |
| 1226 | - public static function flush_w3tc_cache() { | |
| 1227 | - _deprecated_function( __METHOD__, 'WPSEO 15.3' ); | |
| 1228 | - } | |
| 1229 | - | |
| 1230 | - /** | |
| 1231 | - * Determines whether or not WooCommerce is active. | |
| 1232 | - * | |
| 1233 | - * @deprecated 15.3 | |
| 1234 | - * @codeCoverageIgnore | |
| 1235 | - * | |
| 1236 | - * @return bool Whether or not WooCommerce is active. | |
| 1237 | - */ | |
| 1238 | - public static function is_woocommerce_active() { | |
| 1239 | - _deprecated_function( __METHOD__, 'WPSEO 15.3' ); | |
| 1240 | - | |
| 1241 | - return YoastSEO()->helpers->woocommerce->is_active(); | |
| 1242 | - } | |
| 1243 | - | |
| 1244 | - /** | |
| 1245 | - * Outputs a Schema blob. | |
| 1246 | - * | |
| 1247 | - * @deprecated 15.5 | |
| 1248 | - * @codeCoverageIgnore | |
| 1249 | - * | |
| 1250 | - * @param array $graph The Schema graph array to output. | |
| 1251 | - * @param string $class_to_add The (optional) class to add to the script tag. | |
| 1252 | - * | |
| 1253 | - * @return bool | |
| 1254 | - */ | |
| 1255 | - public static function schema_output( $graph, $class_to_add = 'yoast-schema-graph' ) { | |
| 1256 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1257 | - | |
| 1258 | - if ( ! is_array( $graph ) || empty( $graph ) ) { | |
| 1259 | - return false; | |
| 1260 | - } | |
| 1261 | - | |
| 1262 | - // phpcs:ignore WordPress.Security.EscapeOutput -- Escaping happens in WPSEO_Utils::schema_tag, which should be whitelisted. | |
| 1263 | - echo self::schema_tag( $graph, $class_to_add ); | |
| 1264 | - return true; | |
| 1265 | - } | |
| 1266 | - | |
| 1267 | - /** | |
| 1268 | - * Returns a script tag with Schema blob. | |
| 1269 | - * | |
| 1270 | - * @deprecated 15.5 | |
| 1271 | - * @codeCoverageIgnore | |
| 1272 | - * | |
| 1273 | - * @param array $graph The Schema graph array to output. | |
| 1274 | - * @param string $class_to_add The (optional) class to add to the script tag. | |
| 1275 | - * | |
| 1276 | - * @return false|string A schema blob with script tags. | |
| 1277 | - */ | |
| 1278 | - public static function schema_tag( $graph, $class_to_add = 'yoast-schema-graph' ) { | |
| 1279 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1280 | - | |
| 1281 | - if ( ! is_array( $graph ) || empty( $graph ) ) { | |
| 1282 | - return false; | |
| 1283 | - } | |
| 1284 | - | |
| 1285 | - $output = [ | |
| 1286 | - '@context' => 'https://schema.org', | |
| 1287 | - '@graph' => $graph, | |
| 1288 | - ]; | |
| 1289 | - return "<script type='application/ld+json' class='" . esc_attr( $class_to_add ) . "'>" . self::format_json_encode( $output ) . '</script>' . "\n"; | |
| 1290 | - } | |
| 1291 | - | |
| 1292 | - /** | |
| 1293 | - * Returns the SVG for the traffic light in the metabox. | |
| 1294 | - * | |
| 1295 | - * @deprecated 15.5 | |
| 1296 | - * @codeCoverageIgnore | |
| 1297 | - * | |
| 1298 | - * @return string | |
| 1299 | - */ | |
| 1300 | - public static function traffic_light_svg() { | |
| 1301 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1302 | - | |
| 1303 | - return <<<'SVG' | |
| 1304 | -<svg class="yst-traffic-light init" version="1.1" xmlns="http://www.w3.org/2000/svg" | |
| 1305 | - role="img" aria-hidden="true" focusable="false" | |
| 1306 | - x="0px" y="0px" viewBox="0 0 30 47" enable-background="new 0 0 30 47" xml:space="preserve"> | |
| 1307 | -<g id="BG_1_"> | |
| 1308 | -</g> | |
| 1309 | -<g id="traffic_light"> | |
| 1310 | - <g> | |
| 1311 | - <g> | |
| 1312 | - <g> | |
| 1313 | - <path fill="#5B2942" d="M22,0H8C3.6,0,0,3.6,0,7.9v31.1C0,43.4,3.6,47,8,47h14c4.4,0,8-3.6,8-7.9V7.9C30,3.6,26.4,0,22,0z | |
| 1314 | - M27.5,38.8c0,3.1-2.6,5.7-5.8,5.7H8.3c-3.2,0-5.8-2.5-5.8-5.7V8.3c0-1.5,0.6-2.9,1.7-4c1.1-1,2.5-1.6,4.1-1.6h13.4 | |
| 1315 | - c1.5,0,3,0.6,4.1,1.6c1.1,1.1,1.7,2.5,1.7,4V38.8z"/> | |
| 1316 | - </g> | |
| 1317 | - <g class="traffic-light-color traffic-light-red"> | |
| 1318 | - <ellipse fill="#C8C8C8" cx="15" cy="23.5" rx="5.7" ry="5.6"/> | |
| 1319 | - <ellipse fill="#DC3232" cx="15" cy="10.9" rx="5.7" ry="5.6"/> | |
| 1320 | - <ellipse fill="#C8C8C8" cx="15" cy="36.1" rx="5.7" ry="5.6"/> | |
| 1321 | - </g> | |
| 1322 | - <g class="traffic-light-color traffic-light-orange"> | |
| 1323 | - <ellipse fill="#F49A00" cx="15" cy="23.5" rx="5.7" ry="5.6"/> | |
| 1324 | - <ellipse fill="#C8C8C8" cx="15" cy="10.9" rx="5.7" ry="5.6"/> | |
| 1325 | - <ellipse fill="#C8C8C8" cx="15" cy="36.1" rx="5.7" ry="5.6"/> | |
| 1326 | - </g> | |
| 1327 | - <g class="traffic-light-color traffic-light-green"> | |
| 1328 | - <ellipse fill="#C8C8C8" cx="15" cy="23.5" rx="5.7" ry="5.6"/> | |
| 1329 | - <ellipse fill="#C8C8C8" cx="15" cy="10.9" rx="5.7" ry="5.6"/> | |
| 1330 | - <ellipse fill="#63B22B" cx="15" cy="36.1" rx="5.7" ry="5.6"/> | |
| 1331 | - </g> | |
| 1332 | - <g class="traffic-light-color traffic-light-empty"> | |
| 1333 | - <ellipse fill="#C8C8C8" cx="15" cy="23.5" rx="5.7" ry="5.6"/> | |
| 1334 | - <ellipse fill="#C8C8C8" cx="15" cy="10.9" rx="5.7" ry="5.6"/> | |
| 1335 | - <ellipse fill="#C8C8C8" cx="15" cy="36.1" rx="5.7" ry="5.6"/> | |
| 1336 | - </g> | |
| 1337 | - <g class="traffic-light-color traffic-light-init"> | |
| 1338 | - <ellipse fill="#C8C8C8" cx="15" cy="23.5" rx="5.7" ry="5.6"/> | |
| 1339 | - <ellipse fill="#C8C8C8" cx="15" cy="10.9" rx="5.7" ry="5.6"/> | |
| 1340 | - <ellipse fill="#C8C8C8" cx="15" cy="36.1" rx="5.7" ry="5.6"/> | |
| 1341 | - </g> | |
| 1342 | - </g> | |
| 1343 | - </g> | |
| 1344 | -</g> | |
| 1345 | -</svg> | |
| 1346 | -SVG; | |
| 1347 | - } | |
| 1348 | - | |
| 1349 | - /** | |
| 1350 | - * Gets the plugin name from file. | |
| 1351 | - * | |
| 1352 | - * @since 2.3.3 | |
| 1353 | - * @deprecated 15.5 | |
| 1354 | - * @codeCoverageIgnore | |
| 1355 | - * | |
| 1356 | - * @param string $plugin Plugin path relative to plugins directory. | |
| 1357 | - * | |
| 1358 | - * @return string|bool | |
| 1359 | - */ | |
| 1360 | - public static function get_plugin_name( $plugin ) { | |
| 1361 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1362 | - | |
| 1363 | - $plugin_details = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); | |
| 1364 | - | |
| 1365 | - if ( $plugin_details['Name'] !== '' ) { | |
| 1366 | - return $plugin_details['Name']; | |
| 1367 | - } | |
| 1368 | - | |
| 1369 | - return false; | |
| 1370 | - } | |
| 1371 | - | |
| 1372 | - /** | |
| 1373 | - * Returns a base64 URL for the svg for use in the menu. | |
| 1374 | - * | |
| 1375 | - * @since 3.3.0 | |
| 1376 | - * @deprecated 15.5 | |
| 1377 | - * @codeCoverageIgnore | |
| 1378 | - * | |
| 1379 | - * @param bool $base64 Whether or not to return base64'd output. | |
| 1380 | - * | |
| 1381 | - * @return string | |
| 1382 | - */ | |
| 1383 | - public static function get_icon_svg( $base64 = true ) { | |
| 1384 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1385 | - | |
| 1386 | - $svg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="100%" height="100%" style="fill:#82878c" viewBox="0 0 512 512" role="img" aria-hidden="true" focusable="false"><g><g><g><g><path d="M203.6,395c6.8-17.4,6.8-36.6,0-54l-79.4-204h70.9l47.7,149.4l74.8-207.6H116.4c-41.8,0-76,34.2-76,76V357c0,41.8,34.2,76,76,76H173C189,424.1,197.6,410.3,203.6,395z"/></g><g><path d="M471.6,154.8c0-41.8-34.2-76-76-76h-3L285.7,365c-9.6,26.7-19.4,49.3-30.3,68h216.2V154.8z"/></g></g><path stroke-width="2.974" stroke-miterlimit="10" d="M338,1.3l-93.3,259.1l-42.1-131.9h-89.1l83.8,215.2c6,15.5,6,32.5,0,48c-7.4,19-19,37.3-53,41.9l-7.2,1v76h8.3c81.7,0,118.9-57.2,149.6-142.9L431.6,1.3H338z M279.4,362c-32.9,92-67.6,128.7-125.7,131.8v-45c37.5-7.5,51.3-31,59.1-51.1c7.5-19.3,7.5-40.7,0-60l-75-192.7h52.8l53.3,166.8l105.9-294h58.1L279.4,362z"/></g></g></svg>'; | |
| 1387 | - | |
| 1388 | - if ( $base64 ) { | |
| 1389 | - //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- This encoding is intended. | |
| 1390 | - return 'data:image/svg+xml;base64,' . base64_encode( $svg ); | |
| 1391 | - } | |
| 1392 | - | |
| 1393 | - return $svg; | |
| 1394 | - } | |
| 1395 | - | |
| 1396 | - /** | |
| 1397 | - * Checks whether the current user is allowed to access the configuration. | |
| 1398 | - * | |
| 1399 | - * @since 1.8.0 | |
| 1400 | - * @deprecated 15.5 | |
| 1401 | - * @codeCoverageIgnore | |
| 1402 | - * | |
| 1403 | - * @return bool | |
| 1404 | - */ | |
| 1405 | - public static function grant_access() { | |
| 1406 | - _deprecated_function( __METHOD__, 'WPSEO 15.5' ); | |
| 1407 | - | |
| 1408 | - if ( ! is_multisite() ) { | |
| 1409 | - return true; | |
| 1410 | - } | |
| 1411 | - | |
| 1412 | - $options = get_site_option( 'wpseo_ms' ); | |
| 1413 | - | |
| 1414 | - if ( empty( $options['access'] ) || $options['access'] === 'admin' ) { | |
| 1415 | - return current_user_can( 'wpseo_manage_options' ); | |
| 1416 | - } | |
| 1417 | - | |
| 1418 | - return is_super_admin(); | |
| 1419 | 1111 | } |
| 1420 | 1112 | } |