تابع rest_sanitize_request_arg استاندارد سازی مسیر آدرس داده شده بر اساس آرگومان

تابع rest_sanitize_request_arg استاندارد سازی مسیر آدرس داده شده بر اساس آرگومان

تابع ووکامرسی rest_sanitize_request_arg – استاندارد سازی مسیر آدرس داده شده بر اساس آرگومان

Syntax – سینتکس

rest_sanitize_request_arg( (mixed) $value, (WP_REST_Request) $request, (string) $param ); 

Parameters – پارامتر ها (3)

  • 1- $value (mixed)
  • 2- $request (WP_REST_Request)
  • 3- $param (string)

Usage – نحوه استفاده

if ( !function_exists( 'rest_sanitize_request_arg' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/vendor/wp-rest-functions.php'; 
} 
  
// The value. 
$value = null; 
  
// The request. 
$request = null; 
  
// The param. 
$param = ''; 
  
// NOTICE! Understand what this does before running. 
$result = rest_sanitize_request_arg($value, $request, $param); 
    

Defined – محل تعریف

/includes/vendor/wp-rest-functions.php

function rest_sanitize_request_arg( $value, $request, $param ) { 
 
    $attributes = $request->get_attributes(); 
    if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) { 
        return $value; 
    } 
    $args = $attributes['args'][ $param ]; 
 
    if ( 'integer' === $args['type'] ) { 
        return (int) $value; 
    } 
 
    if ( 'boolean' === $args['type'] ) { 
        return rest_sanitize_boolean( $value ); 
    } 
 
    if ( isset( $args['format'] ) ) { 
        switch ( $args['format'] ) { 
            case 'date-time' : 
                return sanitize_text_field( $value ); 
 
            case 'email' : 
                /** 
                 * sanitize_email() validates, which would be unexpected 
                 */ 
                return sanitize_text_field( $value ); 
 
            case 'uri' : 
                return esc_url_raw( $value ); 
 
            case 'ipv4' : 
                return sanitize_text_field( $value ); 
        } 
    } 
 
    return $value; 
} 

versions – نسخه ها

از نسخه : 3.0.2

نسخه فعلی : 3.0.6

دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2

ارسال نظر

جهت استفاده از کد حتما از تگ pre استفاده نمایید .

contact us