تابع ووکامرسی register_rest_field ثبت فیلد rest بر روی وردپرس

تابع ووکامرسی register_rest_field – ثبت فیلد rest بر روی وردپرس
Syntax – سینتکس
register_rest_field( (string|array) $object_type, (string) $attribute, (array) $args = array() );
Parameters – پارامتر ها (3)
- 1- $object_type (string|array)
- 2- $attribute (string)
- 3- $args (array)
Usage – نحوه استفاده
if ( !function_exists( 'register_rest_field' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/vendor/wp-rest-functions.php';
}
// Object(s) the field is being registered
// to, "post"|"term"|"comment" etc.
$object_type = null;
// The attribute name.
$attribute = '';
// Optional. An array of arguments used to handle the registered field.
$args = array(
'get_callback' => 'null',
'update_callback' => 'null'
);
// NOTICE! Understand what this does before running.
$result = register_rest_field($object_type, $attribute, $args);
Defined – محل تعریف
/includes/vendor/wp-rest-functions.php
function register_rest_field( $object_type, $attribute, $args = array() ) {
$defaults = array(
'get_callback' => null,
'update_callback' => null,
'schema' => null,
);
$args = wp_parse_args( $args, $defaults );
global $wp_rest_additional_fields;
$object_types = (array) $object_type;
foreach ( $object_types as $object_type ) {
$wp_rest_additional_fields[ $object_type ][ $attribute ] = $args;
}
}
versions – نسخه ها
از نسخه : 3.0.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر