BP_REST_Topics_Endpoint:: get_endpoint_args_for_item_schema (字符串美元的方法WP_REST_Server:创造性的

编辑端点的CREATABLE、EDITABLE和DELETABLE方法的一些参数。

描述

参数

美元的方法

字符串(可选)请求的HTTP方法。

默认值:WP_REST_Server::创造性的

返回

(数组)端点参数。

文件:bp-forums /类/ class-bp-rest-topics-endpoint.php

public function get_endpoint_args_for_item_schema($method = WP_REST_Server::CREATABLE) {$args = WP_REST_Controller::get_endpoint_args_for_item_schema($method);美元关键=“create_item”;如果(WP_REST_Server:: deleteable === $method) {$key = 'delete_item';$args = array('id' => array('description' => __('主题的唯一数字id。”、“buddyboss”),“类型”= >“整数”、“要求”= >真的,));} elseif (WP_REST_Server::可编辑方法= = = $ | | WP_REST_Server::创造性的= = = $方法){$ unset_keys =阵列(“日期”、“date_gmt”,“密码”,“鼻涕虫”,“链接”,‘作者’,‘total_reply_count’,‘last_reply_id’,‘last_active_author’,‘last_active_time’,‘is_closed’,‘类’,‘voice_count’,‘forum_id’,‘is_topic_anonymous’,‘anonymous_author_data’,'action_states', 'current_user_permissions', 'revisions',);如果(!foreach ($unset_keys as $k) {if (array_key_exists($k, $args)) {unset($args[$k]);}}} $args['title']['type'] = 'string';$ args['标题'][‘需要’]= true; $args['content']['type'] = 'string'; $args['content']['required'] = true; $args['status']['default'] = 'publish'; $args['status']['enum'] = array_keys( bbp_get_topic_statuses() ); $args['sticky']['type'] = 'string'; $args['sticky']['enum'] = array( 'stick', 'super', 'unstick' ); $args['parent']['description'] = __( 'ID of the parent Forum.', 'buddyboss' ); $args['parent']['required'] = true; $args['group']['type'] = 'integer'; $args['group']['description'] = __( 'ID of the forum\'s group', 'buddyboss' ); $params['subscribe'] = array( 'description' => __( 'whether user subscribe topic or no', 'buddyboss' ), 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean', 'validate_callback' => 'rest_validate_request_arg', ); } if ( WP_REST_Server::EDITABLE === $method ) { $key = 'update_item'; $args['reason_editing'] = array( 'description' => __( 'Reason for editing a topic.', 'buddyboss' ), 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg', ); $args['log'] = array( 'description' => __( 'Keep a log of topic edit.', 'buddyboss' ), 'type' => 'boolean', 'default' => true, 'sanitize_callback' => 'rest_sanitize_boolean', 'validate_callback' => 'rest_validate_request_arg', ); $params['subscribe'] = array( 'description' => __( 'whether user subscribe topic or no', 'buddyboss' ), 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean', 'validate_callback' => 'rest_validate_request_arg', ); } /** * Filters the method query arguments. * * @param array $args Query arguments. * @param string $method HTTP method of the request. * * @since 0.1.0 */ return apply_filters( "bp_rest_topic_{$key}_query_arguments", $args, $method ); }

更新日志

更新日志
版本 描述
0.1.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档,联络支持,或与我们联系销售团队