Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: rest-api.php
function rest_validate_number_value_from_schema( $value, $args, $param ) {
[2500] Fix | Delete
if ( ! is_numeric( $value ) ) {
[2501] Fix | Delete
return new WP_Error(
[2502] Fix | Delete
'rest_invalid_type',
[2503] Fix | Delete
/* translators: 1: Parameter, 2: Type name. */
[2504] Fix | Delete
sprintf( __( '%1$s is not of type %2$s.' ), $param, $args['type'] ),
[2505] Fix | Delete
array( 'param' => $param )
[2506] Fix | Delete
);
[2507] Fix | Delete
}
[2508] Fix | Delete
[2509] Fix | Delete
if ( isset( $args['multipleOf'] ) && fmod( $value, $args['multipleOf'] ) !== 0.0 ) {
[2510] Fix | Delete
return new WP_Error(
[2511] Fix | Delete
'rest_invalid_multiple',
[2512] Fix | Delete
/* translators: 1: Parameter, 2: Multiplier. */
[2513] Fix | Delete
sprintf( __( '%1$s must be a multiple of %2$s.' ), $param, $args['multipleOf'] )
[2514] Fix | Delete
);
[2515] Fix | Delete
}
[2516] Fix | Delete
[2517] Fix | Delete
if ( isset( $args['minimum'] ) && ! isset( $args['maximum'] ) ) {
[2518] Fix | Delete
if ( ! empty( $args['exclusiveMinimum'] ) && $value <= $args['minimum'] ) {
[2519] Fix | Delete
return new WP_Error(
[2520] Fix | Delete
'rest_out_of_bounds',
[2521] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number. */
[2522] Fix | Delete
sprintf( __( '%1$s must be greater than %2$d' ), $param, $args['minimum'] )
[2523] Fix | Delete
);
[2524] Fix | Delete
}
[2525] Fix | Delete
[2526] Fix | Delete
if ( empty( $args['exclusiveMinimum'] ) && $value < $args['minimum'] ) {
[2527] Fix | Delete
return new WP_Error(
[2528] Fix | Delete
'rest_out_of_bounds',
[2529] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number. */
[2530] Fix | Delete
sprintf( __( '%1$s must be greater than or equal to %2$d' ), $param, $args['minimum'] )
[2531] Fix | Delete
);
[2532] Fix | Delete
}
[2533] Fix | Delete
}
[2534] Fix | Delete
[2535] Fix | Delete
if ( isset( $args['maximum'] ) && ! isset( $args['minimum'] ) ) {
[2536] Fix | Delete
if ( ! empty( $args['exclusiveMaximum'] ) && $value >= $args['maximum'] ) {
[2537] Fix | Delete
return new WP_Error(
[2538] Fix | Delete
'rest_out_of_bounds',
[2539] Fix | Delete
/* translators: 1: Parameter, 2: Maximum number. */
[2540] Fix | Delete
sprintf( __( '%1$s must be less than %2$d' ), $param, $args['maximum'] )
[2541] Fix | Delete
);
[2542] Fix | Delete
}
[2543] Fix | Delete
[2544] Fix | Delete
if ( empty( $args['exclusiveMaximum'] ) && $value > $args['maximum'] ) {
[2545] Fix | Delete
return new WP_Error(
[2546] Fix | Delete
'rest_out_of_bounds',
[2547] Fix | Delete
/* translators: 1: Parameter, 2: Maximum number. */
[2548] Fix | Delete
sprintf( __( '%1$s must be less than or equal to %2$d' ), $param, $args['maximum'] )
[2549] Fix | Delete
);
[2550] Fix | Delete
}
[2551] Fix | Delete
}
[2552] Fix | Delete
[2553] Fix | Delete
if ( isset( $args['minimum'], $args['maximum'] ) ) {
[2554] Fix | Delete
if ( ! empty( $args['exclusiveMinimum'] ) && ! empty( $args['exclusiveMaximum'] ) ) {
[2555] Fix | Delete
if ( $value >= $args['maximum'] || $value <= $args['minimum'] ) {
[2556] Fix | Delete
return new WP_Error(
[2557] Fix | Delete
'rest_out_of_bounds',
[2558] Fix | Delete
sprintf(
[2559] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */
[2560] Fix | Delete
__( '%1$s must be between %2$d (exclusive) and %3$d (exclusive)' ),
[2561] Fix | Delete
$param,
[2562] Fix | Delete
$args['minimum'],
[2563] Fix | Delete
$args['maximum']
[2564] Fix | Delete
)
[2565] Fix | Delete
);
[2566] Fix | Delete
}
[2567] Fix | Delete
}
[2568] Fix | Delete
[2569] Fix | Delete
if ( ! empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
[2570] Fix | Delete
if ( $value > $args['maximum'] || $value <= $args['minimum'] ) {
[2571] Fix | Delete
return new WP_Error(
[2572] Fix | Delete
'rest_out_of_bounds',
[2573] Fix | Delete
sprintf(
[2574] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */
[2575] Fix | Delete
__( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ),
[2576] Fix | Delete
$param,
[2577] Fix | Delete
$args['minimum'],
[2578] Fix | Delete
$args['maximum']
[2579] Fix | Delete
)
[2580] Fix | Delete
);
[2581] Fix | Delete
}
[2582] Fix | Delete
}
[2583] Fix | Delete
[2584] Fix | Delete
if ( ! empty( $args['exclusiveMaximum'] ) && empty( $args['exclusiveMinimum'] ) ) {
[2585] Fix | Delete
if ( $value >= $args['maximum'] || $value < $args['minimum'] ) {
[2586] Fix | Delete
return new WP_Error(
[2587] Fix | Delete
'rest_out_of_bounds',
[2588] Fix | Delete
sprintf(
[2589] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */
[2590] Fix | Delete
__( '%1$s must be between %2$d (inclusive) and %3$d (exclusive)' ),
[2591] Fix | Delete
$param,
[2592] Fix | Delete
$args['minimum'],
[2593] Fix | Delete
$args['maximum']
[2594] Fix | Delete
)
[2595] Fix | Delete
);
[2596] Fix | Delete
}
[2597] Fix | Delete
}
[2598] Fix | Delete
[2599] Fix | Delete
if ( empty( $args['exclusiveMinimum'] ) && empty( $args['exclusiveMaximum'] ) ) {
[2600] Fix | Delete
if ( $value > $args['maximum'] || $value < $args['minimum'] ) {
[2601] Fix | Delete
return new WP_Error(
[2602] Fix | Delete
'rest_out_of_bounds',
[2603] Fix | Delete
sprintf(
[2604] Fix | Delete
/* translators: 1: Parameter, 2: Minimum number, 3: Maximum number. */
[2605] Fix | Delete
__( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ),
[2606] Fix | Delete
$param,
[2607] Fix | Delete
$args['minimum'],
[2608] Fix | Delete
$args['maximum']
[2609] Fix | Delete
)
[2610] Fix | Delete
);
[2611] Fix | Delete
}
[2612] Fix | Delete
}
[2613] Fix | Delete
}
[2614] Fix | Delete
[2615] Fix | Delete
return true;
[2616] Fix | Delete
}
[2617] Fix | Delete
[2618] Fix | Delete
/**
[2619] Fix | Delete
* Validates a string value based on a schema.
[2620] Fix | Delete
*
[2621] Fix | Delete
* @since 5.7.0
[2622] Fix | Delete
*
[2623] Fix | Delete
* @param mixed $value The value to validate.
[2624] Fix | Delete
* @param array $args Schema array to use for validation.
[2625] Fix | Delete
* @param string $param The parameter name, used in error messages.
[2626] Fix | Delete
* @return true|WP_Error
[2627] Fix | Delete
*/
[2628] Fix | Delete
function rest_validate_string_value_from_schema( $value, $args, $param ) {
[2629] Fix | Delete
if ( ! is_string( $value ) ) {
[2630] Fix | Delete
return new WP_Error(
[2631] Fix | Delete
'rest_invalid_type',
[2632] Fix | Delete
/* translators: 1: Parameter, 2: Type name. */
[2633] Fix | Delete
sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ),
[2634] Fix | Delete
array( 'param' => $param )
[2635] Fix | Delete
);
[2636] Fix | Delete
}
[2637] Fix | Delete
[2638] Fix | Delete
if ( isset( $args['minLength'] ) && mb_strlen( $value ) < $args['minLength'] ) {
[2639] Fix | Delete
return new WP_Error(
[2640] Fix | Delete
'rest_too_short',
[2641] Fix | Delete
sprintf(
[2642] Fix | Delete
/* translators: 1: Parameter, 2: Number of characters. */
[2643] Fix | Delete
_n(
[2644] Fix | Delete
'%1$s must be at least %2$s character long.',
[2645] Fix | Delete
'%1$s must be at least %2$s characters long.',
[2646] Fix | Delete
$args['minLength']
[2647] Fix | Delete
),
[2648] Fix | Delete
$param,
[2649] Fix | Delete
number_format_i18n( $args['minLength'] )
[2650] Fix | Delete
)
[2651] Fix | Delete
);
[2652] Fix | Delete
}
[2653] Fix | Delete
[2654] Fix | Delete
if ( isset( $args['maxLength'] ) && mb_strlen( $value ) > $args['maxLength'] ) {
[2655] Fix | Delete
return new WP_Error(
[2656] Fix | Delete
'rest_too_long',
[2657] Fix | Delete
sprintf(
[2658] Fix | Delete
/* translators: 1: Parameter, 2: Number of characters. */
[2659] Fix | Delete
_n(
[2660] Fix | Delete
'%1$s must be at most %2$s character long.',
[2661] Fix | Delete
'%1$s must be at most %2$s characters long.',
[2662] Fix | Delete
$args['maxLength']
[2663] Fix | Delete
),
[2664] Fix | Delete
$param,
[2665] Fix | Delete
number_format_i18n( $args['maxLength'] )
[2666] Fix | Delete
)
[2667] Fix | Delete
);
[2668] Fix | Delete
}
[2669] Fix | Delete
[2670] Fix | Delete
if ( isset( $args['pattern'] ) && ! rest_validate_json_schema_pattern( $args['pattern'], $value ) ) {
[2671] Fix | Delete
return new WP_Error(
[2672] Fix | Delete
'rest_invalid_pattern',
[2673] Fix | Delete
/* translators: 1: Parameter, 2: Pattern. */
[2674] Fix | Delete
sprintf( __( '%1$s does not match pattern %2$s.' ), $param, $args['pattern'] )
[2675] Fix | Delete
);
[2676] Fix | Delete
}
[2677] Fix | Delete
[2678] Fix | Delete
return true;
[2679] Fix | Delete
}
[2680] Fix | Delete
[2681] Fix | Delete
/**
[2682] Fix | Delete
* Validates an integer value based on a schema.
[2683] Fix | Delete
*
[2684] Fix | Delete
* @since 5.7.0
[2685] Fix | Delete
*
[2686] Fix | Delete
* @param mixed $value The value to validate.
[2687] Fix | Delete
* @param array $args Schema array to use for validation.
[2688] Fix | Delete
* @param string $param The parameter name, used in error messages.
[2689] Fix | Delete
* @return true|WP_Error
[2690] Fix | Delete
*/
[2691] Fix | Delete
function rest_validate_integer_value_from_schema( $value, $args, $param ) {
[2692] Fix | Delete
$is_valid_number = rest_validate_number_value_from_schema( $value, $args, $param );
[2693] Fix | Delete
if ( is_wp_error( $is_valid_number ) ) {
[2694] Fix | Delete
return $is_valid_number;
[2695] Fix | Delete
}
[2696] Fix | Delete
[2697] Fix | Delete
if ( ! rest_is_integer( $value ) ) {
[2698] Fix | Delete
return new WP_Error(
[2699] Fix | Delete
'rest_invalid_type',
[2700] Fix | Delete
/* translators: 1: Parameter, 2: Type name. */
[2701] Fix | Delete
sprintf( __( '%1$s is not of type %2$s.' ), $param, 'integer' ),
[2702] Fix | Delete
array( 'param' => $param )
[2703] Fix | Delete
);
[2704] Fix | Delete
}
[2705] Fix | Delete
[2706] Fix | Delete
return true;
[2707] Fix | Delete
}
[2708] Fix | Delete
[2709] Fix | Delete
/**
[2710] Fix | Delete
* Sanitize a value based on a schema.
[2711] Fix | Delete
*
[2712] Fix | Delete
* @since 4.7.0
[2713] Fix | Delete
* @since 5.5.0 Added the `$param` parameter.
[2714] Fix | Delete
* @since 5.6.0 Support the "anyOf" and "oneOf" keywords.
[2715] Fix | Delete
* @since 5.9.0 Added `text-field` and `textarea-field` formats.
[2716] Fix | Delete
*
[2717] Fix | Delete
* @param mixed $value The value to sanitize.
[2718] Fix | Delete
* @param array $args Schema array to use for sanitization.
[2719] Fix | Delete
* @param string $param The parameter name, used in error messages.
[2720] Fix | Delete
* @return mixed|WP_Error The sanitized value or a WP_Error instance if the value cannot be safely sanitized.
[2721] Fix | Delete
*/
[2722] Fix | Delete
function rest_sanitize_value_from_schema( $value, $args, $param = '' ) {
[2723] Fix | Delete
if ( isset( $args['anyOf'] ) ) {
[2724] Fix | Delete
$matching_schema = rest_find_any_matching_schema( $value, $args, $param );
[2725] Fix | Delete
if ( is_wp_error( $matching_schema ) ) {
[2726] Fix | Delete
return $matching_schema;
[2727] Fix | Delete
}
[2728] Fix | Delete
[2729] Fix | Delete
if ( ! isset( $args['type'] ) ) {
[2730] Fix | Delete
$args['type'] = $matching_schema['type'];
[2731] Fix | Delete
}
[2732] Fix | Delete
[2733] Fix | Delete
$value = rest_sanitize_value_from_schema( $value, $matching_schema, $param );
[2734] Fix | Delete
}
[2735] Fix | Delete
[2736] Fix | Delete
if ( isset( $args['oneOf'] ) ) {
[2737] Fix | Delete
$matching_schema = rest_find_one_matching_schema( $value, $args, $param );
[2738] Fix | Delete
if ( is_wp_error( $matching_schema ) ) {
[2739] Fix | Delete
return $matching_schema;
[2740] Fix | Delete
}
[2741] Fix | Delete
[2742] Fix | Delete
if ( ! isset( $args['type'] ) ) {
[2743] Fix | Delete
$args['type'] = $matching_schema['type'];
[2744] Fix | Delete
}
[2745] Fix | Delete
[2746] Fix | Delete
$value = rest_sanitize_value_from_schema( $value, $matching_schema, $param );
[2747] Fix | Delete
}
[2748] Fix | Delete
[2749] Fix | Delete
$allowed_types = array( 'array', 'object', 'string', 'number', 'integer', 'boolean', 'null' );
[2750] Fix | Delete
[2751] Fix | Delete
if ( ! isset( $args['type'] ) ) {
[2752] Fix | Delete
/* translators: %s: Parameter. */
[2753] Fix | Delete
_doing_it_wrong( __FUNCTION__, sprintf( __( 'The "type" schema keyword for %s is required.' ), $param ), '5.5.0' );
[2754] Fix | Delete
}
[2755] Fix | Delete
[2756] Fix | Delete
if ( is_array( $args['type'] ) ) {
[2757] Fix | Delete
$best_type = rest_handle_multi_type_schema( $value, $args, $param );
[2758] Fix | Delete
[2759] Fix | Delete
if ( ! $best_type ) {
[2760] Fix | Delete
return null;
[2761] Fix | Delete
}
[2762] Fix | Delete
[2763] Fix | Delete
$args['type'] = $best_type;
[2764] Fix | Delete
}
[2765] Fix | Delete
[2766] Fix | Delete
if ( ! in_array( $args['type'], $allowed_types, true ) ) {
[2767] Fix | Delete
_doing_it_wrong(
[2768] Fix | Delete
__FUNCTION__,
[2769] Fix | Delete
/* translators: 1: Parameter, 2: The list of allowed types. */
[2770] Fix | Delete
wp_sprintf( __( 'The "type" schema keyword for %1$s can only be one of the built-in types: %2$l.' ), $param, $allowed_types ),
[2771] Fix | Delete
'5.5.0'
[2772] Fix | Delete
);
[2773] Fix | Delete
}
[2774] Fix | Delete
[2775] Fix | Delete
if ( 'array' === $args['type'] ) {
[2776] Fix | Delete
$value = rest_sanitize_array( $value );
[2777] Fix | Delete
[2778] Fix | Delete
if ( ! empty( $args['items'] ) ) {
[2779] Fix | Delete
foreach ( $value as $index => $v ) {
[2780] Fix | Delete
$value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' );
[2781] Fix | Delete
}
[2782] Fix | Delete
}
[2783] Fix | Delete
[2784] Fix | Delete
if ( ! empty( $args['uniqueItems'] ) && ! rest_validate_array_contains_unique_items( $value ) ) {
[2785] Fix | Delete
/* translators: %s: Parameter. */
[2786] Fix | Delete
return new WP_Error( 'rest_duplicate_items', sprintf( __( '%s has duplicate items.' ), $param ) );
[2787] Fix | Delete
}
[2788] Fix | Delete
[2789] Fix | Delete
return $value;
[2790] Fix | Delete
}
[2791] Fix | Delete
[2792] Fix | Delete
if ( 'object' === $args['type'] ) {
[2793] Fix | Delete
$value = rest_sanitize_object( $value );
[2794] Fix | Delete
[2795] Fix | Delete
foreach ( $value as $property => $v ) {
[2796] Fix | Delete
if ( isset( $args['properties'][ $property ] ) ) {
[2797] Fix | Delete
$value[ $property ] = rest_sanitize_value_from_schema( $v, $args['properties'][ $property ], $param . '[' . $property . ']' );
[2798] Fix | Delete
continue;
[2799] Fix | Delete
}
[2800] Fix | Delete
[2801] Fix | Delete
$pattern_property_schema = rest_find_matching_pattern_property_schema( $property, $args );
[2802] Fix | Delete
if ( null !== $pattern_property_schema ) {
[2803] Fix | Delete
$value[ $property ] = rest_sanitize_value_from_schema( $v, $pattern_property_schema, $param . '[' . $property . ']' );
[2804] Fix | Delete
continue;
[2805] Fix | Delete
}
[2806] Fix | Delete
[2807] Fix | Delete
if ( isset( $args['additionalProperties'] ) ) {
[2808] Fix | Delete
if ( false === $args['additionalProperties'] ) {
[2809] Fix | Delete
unset( $value[ $property ] );
[2810] Fix | Delete
} elseif ( is_array( $args['additionalProperties'] ) ) {
[2811] Fix | Delete
$value[ $property ] = rest_sanitize_value_from_schema( $v, $args['additionalProperties'], $param . '[' . $property . ']' );
[2812] Fix | Delete
}
[2813] Fix | Delete
}
[2814] Fix | Delete
}
[2815] Fix | Delete
[2816] Fix | Delete
return $value;
[2817] Fix | Delete
}
[2818] Fix | Delete
[2819] Fix | Delete
if ( 'null' === $args['type'] ) {
[2820] Fix | Delete
return null;
[2821] Fix | Delete
}
[2822] Fix | Delete
[2823] Fix | Delete
if ( 'integer' === $args['type'] ) {
[2824] Fix | Delete
return (int) $value;
[2825] Fix | Delete
}
[2826] Fix | Delete
[2827] Fix | Delete
if ( 'number' === $args['type'] ) {
[2828] Fix | Delete
return (float) $value;
[2829] Fix | Delete
}
[2830] Fix | Delete
[2831] Fix | Delete
if ( 'boolean' === $args['type'] ) {
[2832] Fix | Delete
return rest_sanitize_boolean( $value );
[2833] Fix | Delete
}
[2834] Fix | Delete
[2835] Fix | Delete
// This behavior matches rest_validate_value_from_schema().
[2836] Fix | Delete
if ( isset( $args['format'] )
[2837] Fix | Delete
&& ( ! isset( $args['type'] ) || 'string' === $args['type'] || ! in_array( $args['type'], $allowed_types, true ) )
[2838] Fix | Delete
) {
[2839] Fix | Delete
switch ( $args['format'] ) {
[2840] Fix | Delete
case 'hex-color':
[2841] Fix | Delete
return (string) sanitize_hex_color( $value );
[2842] Fix | Delete
[2843] Fix | Delete
case 'date-time':
[2844] Fix | Delete
return sanitize_text_field( $value );
[2845] Fix | Delete
[2846] Fix | Delete
case 'email':
[2847] Fix | Delete
// sanitize_email() validates, which would be unexpected.
[2848] Fix | Delete
return sanitize_text_field( $value );
[2849] Fix | Delete
[2850] Fix | Delete
case 'uri':
[2851] Fix | Delete
return sanitize_url( $value );
[2852] Fix | Delete
[2853] Fix | Delete
case 'ip':
[2854] Fix | Delete
return sanitize_text_field( $value );
[2855] Fix | Delete
[2856] Fix | Delete
case 'uuid':
[2857] Fix | Delete
return sanitize_text_field( $value );
[2858] Fix | Delete
[2859] Fix | Delete
case 'text-field':
[2860] Fix | Delete
return sanitize_text_field( $value );
[2861] Fix | Delete
[2862] Fix | Delete
case 'textarea-field':
[2863] Fix | Delete
return sanitize_textarea_field( $value );
[2864] Fix | Delete
}
[2865] Fix | Delete
}
[2866] Fix | Delete
[2867] Fix | Delete
if ( 'string' === $args['type'] ) {
[2868] Fix | Delete
return (string) $value;
[2869] Fix | Delete
}
[2870] Fix | Delete
[2871] Fix | Delete
return $value;
[2872] Fix | Delete
}
[2873] Fix | Delete
[2874] Fix | Delete
/**
[2875] Fix | Delete
* Append result of internal request to REST API for purpose of preloading data to be attached to a page.
[2876] Fix | Delete
* Expected to be called in the context of `array_reduce`.
[2877] Fix | Delete
*
[2878] Fix | Delete
* @since 5.0.0
[2879] Fix | Delete
*
[2880] Fix | Delete
* @param array $memo Reduce accumulator.
[2881] Fix | Delete
* @param string $path REST API path to preload.
[2882] Fix | Delete
* @return array Modified reduce accumulator.
[2883] Fix | Delete
*/
[2884] Fix | Delete
function rest_preload_api_request( $memo, $path ) {
[2885] Fix | Delete
/*
[2886] Fix | Delete
* array_reduce() doesn't support passing an array in PHP 5.2,
[2887] Fix | Delete
* so we need to make sure we start with one.
[2888] Fix | Delete
*/
[2889] Fix | Delete
if ( ! is_array( $memo ) ) {
[2890] Fix | Delete
$memo = array();
[2891] Fix | Delete
}
[2892] Fix | Delete
[2893] Fix | Delete
if ( empty( $path ) ) {
[2894] Fix | Delete
return $memo;
[2895] Fix | Delete
}
[2896] Fix | Delete
[2897] Fix | Delete
$method = 'GET';
[2898] Fix | Delete
if ( is_array( $path ) && 2 === count( $path ) ) {
[2899] Fix | Delete
$method = end( $path );
[2900] Fix | Delete
$path = reset( $path );
[2901] Fix | Delete
[2902] Fix | Delete
if ( ! in_array( $method, array( 'GET', 'OPTIONS' ), true ) ) {
[2903] Fix | Delete
$method = 'GET';
[2904] Fix | Delete
}
[2905] Fix | Delete
}
[2906] Fix | Delete
[2907] Fix | Delete
$path = untrailingslashit( $path );
[2908] Fix | Delete
if ( empty( $path ) ) {
[2909] Fix | Delete
$path = '/';
[2910] Fix | Delete
}
[2911] Fix | Delete
[2912] Fix | Delete
$path_parts = parse_url( $path );
[2913] Fix | Delete
if ( false === $path_parts ) {
[2914] Fix | Delete
return $memo;
[2915] Fix | Delete
}
[2916] Fix | Delete
[2917] Fix | Delete
$request = new WP_REST_Request( $method, $path_parts['path'] );
[2918] Fix | Delete
if ( ! empty( $path_parts['query'] ) ) {
[2919] Fix | Delete
parse_str( $path_parts['query'], $query_params );
[2920] Fix | Delete
$request->set_query_params( $query_params );
[2921] Fix | Delete
}
[2922] Fix | Delete
[2923] Fix | Delete
$response = rest_do_request( $request );
[2924] Fix | Delete
if ( 200 === $response->status ) {
[2925] Fix | Delete
$server = rest_get_server();
[2926] Fix | Delete
/** This filter is documented in wp-includes/rest-api/class-wp-rest-server.php */
[2927] Fix | Delete
$response = apply_filters( 'rest_post_dispatch', rest_ensure_response( $response ), $server, $request );
[2928] Fix | Delete
$embed = $request->has_param( '_embed' ) ? rest_parse_embed_param( $request['_embed'] ) : false;
[2929] Fix | Delete
$data = (array) $server->response_to_data( $response, $embed );
[2930] Fix | Delete
[2931] Fix | Delete
if ( 'OPTIONS' === $method ) {
[2932] Fix | Delete
$memo[ $method ][ $path ] = array(
[2933] Fix | Delete
'body' => $data,
[2934] Fix | Delete
'headers' => $response->headers,
[2935] Fix | Delete
);
[2936] Fix | Delete
} else {
[2937] Fix | Delete
$memo[ $path ] = array(
[2938] Fix | Delete
'body' => $data,
[2939] Fix | Delete
'headers' => $response->headers,
[2940] Fix | Delete
);
[2941] Fix | Delete
}
[2942] Fix | Delete
}
[2943] Fix | Delete
[2944] Fix | Delete
return $memo;
[2945] Fix | Delete
}
[2946] Fix | Delete
[2947] Fix | Delete
/**
[2948] Fix | Delete
* Parses the "_embed" parameter into the list of resources to embed.
[2949] Fix | Delete
*
[2950] Fix | Delete
* @since 5.4.0
[2951] Fix | Delete
*
[2952] Fix | Delete
* @param string|array $embed Raw "_embed" parameter value.
[2953] Fix | Delete
* @return true|string[] Either true to embed all embeds, or a list of relations to embed.
[2954] Fix | Delete
*/
[2955] Fix | Delete
function rest_parse_embed_param( $embed ) {
[2956] Fix | Delete
if ( ! $embed || 'true' === $embed || '1' === $embed ) {
[2957] Fix | Delete
return true;
[2958] Fix | Delete
}
[2959] Fix | Delete
[2960] Fix | Delete
$rels = wp_parse_list( $embed );
[2961] Fix | Delete
[2962] Fix | Delete
if ( ! $rels ) {
[2963] Fix | Delete
return true;
[2964] Fix | Delete
}
[2965] Fix | Delete
[2966] Fix | Delete
return $rels;
[2967] Fix | Delete
}
[2968] Fix | Delete
[2969] Fix | Delete
/**
[2970] Fix | Delete
* Filters the response to remove any fields not available in the given context.
[2971] Fix | Delete
*
[2972] Fix | Delete
* @since 5.5.0
[2973] Fix | Delete
* @since 5.6.0 Support the "patternProperties" keyword for objects.
[2974] Fix | Delete
* Support the "anyOf" and "oneOf" keywords.
[2975] Fix | Delete
*
[2976] Fix | Delete
* @param array|object $response_data The response data to modify.
[2977] Fix | Delete
* @param array $schema The schema for the endpoint used to filter the response.
[2978] Fix | Delete
* @param string $context The requested context.
[2979] Fix | Delete
* @return array|object The filtered response data.
[2980] Fix | Delete
*/
[2981] Fix | Delete
function rest_filter_response_by_context( $response_data, $schema, $context ) {
[2982] Fix | Delete
if ( isset( $schema['anyOf'] ) ) {
[2983] Fix | Delete
$matching_schema = rest_find_any_matching_schema( $response_data, $schema, '' );
[2984] Fix | Delete
if ( ! is_wp_error( $matching_schema ) ) {
[2985] Fix | Delete
if ( ! isset( $schema['type'] ) ) {
[2986] Fix | Delete
$schema['type'] = $matching_schema['type'];
[2987] Fix | Delete
}
[2988] Fix | Delete
[2989] Fix | Delete
$response_data = rest_filter_response_by_context( $response_data, $matching_schema, $context );
[2990] Fix | Delete
}
[2991] Fix | Delete
}
[2992] Fix | Delete
[2993] Fix | Delete
if ( isset( $schema['oneOf'] ) ) {
[2994] Fix | Delete
$matching_schema = rest_find_one_matching_schema( $response_data, $schema, '', true );
[2995] Fix | Delete
if ( ! is_wp_error( $matching_schema ) ) {
[2996] Fix | Delete
if ( ! isset( $schema['type'] ) ) {
[2997] Fix | Delete
$schema['type'] = $matching_schema['type'];
[2998] Fix | Delete
}
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function