BP_REST_Topics_Endpoint::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )
Edit some arguments for the endpoint’s CREATABLE, EDITABLE and DELETABLE methods.
Description
Parameters
- $method
-
(Optional) HTTP method of the request.
Default value: WP_REST_Server::CREATABLE
Return
(array) Endpoint arguments.
Source
File: bp-forums/classes/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 ); $key = 'create_item'; if ( WP_REST_Server::DELETABLE === $method ) { $key = 'delete_item'; $args = array( 'id' => array( 'description' => __( 'A unique numeric ID for the topic.', 'buddyboss' ), 'type' => 'integer', 'required' => true, ), ); } elseif ( WP_REST_Server::EDITABLE === $method || WP_REST_Server::CREATABLE === $method ) { $unset_keys = array( 'date', 'date_gmt', 'password', 'slug', 'link', 'author', 'total_reply_count', 'last_reply_id', 'last_active_author', 'last_active_time', 'is_closed', 'classes', 'voice_count', 'forum_id', 'is_topic_anonymous', 'anonymous_author_data', 'action_states', 'current_user_permissions', 'revisions', ); if ( ! empty( $unset_keys ) ) { foreach ( $unset_keys as $k ) { if ( array_key_exists( $k, $args ) ) { unset( $args[ $k ] ); } } } $args['title']['type'] = 'string'; $args['title']['required'] = 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 ); }
Changelog
Version | Description |
---|---|
0.1.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.