BP_REST_Messages_Endpoint::get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )
Select the item schema arguments needed for the 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-messages/classes/class-bp-rest-messages-endpoint.php
1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 | public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE ) { $key = 'get_item' ; $args = WP_REST_Controller::get_endpoint_args_for_item_schema( $method ); $args [ 'id' ][ 'description' ] = __( 'ID of the Messages Thread.' , 'buddyboss' ); if ( WP_REST_Server::CREATABLE === $method ) { $key = 'create_item' ; // Edit the Thread ID description and default properties. $args [ 'id' ][ 'description' ] = __( 'ID of the Messages Thread. Required when replying to an existing Thread.' , 'buddyboss' ); $args [ 'id' ][ 'default' ] = 0; // Add the sender_id argument. $args [ 'sender_id' ] = array ( 'description' => __( 'The user ID of the Message sender.' , 'buddyboss' ), 'required' => false, 'default' => bp_loggedin_user_id(), 'type' => 'integer' , 'sanitize_callback' => 'absint' , 'validate_callback' => 'rest_validate_request_arg' , ); // Edit subject's properties. $args [ 'subject' ][ 'type' ] = 'string' ; $args [ 'subject' ][ 'default' ] = false; $args [ 'subject' ][ 'description' ] = __( 'Subject of the Message initializing the Thread.' , 'buddyboss' ); // Edit message's properties. $args [ 'message' ][ 'type' ] = 'string' ; $args [ 'message' ][ 'description' ] = __( 'Content of the Message to add to the Thread.' , 'buddyboss' ); // Edit recipients properties. $args [ 'recipients' ][ 'required' ] = false; $args [ 'recipients' ][ 'items' ] = array ( 'type' => 'integer' ); $args [ 'recipients' ][ 'sanitize_callback' ] = 'wp_parse_id_list' ; $args [ 'recipients' ][ 'validate_callback' ] = 'rest_validate_request_arg' ; $args [ 'recipients' ][ 'description' ] = __( 'The list of the recipients user IDs of the Message.' , 'buddyboss' ); // Remove unused properties for this transport method. unset( $args [ 'subject' ][ 'properties' ], $args [ 'message' ][ 'properties' ] ); } else { unset( $args [ 'sender_id' ], $args [ 'subject' ], $args [ 'message' ], $args [ 'recipients' ] ); if ( WP_REST_Server::EDITABLE === $method ) { $key = 'update_item' ; $args [ 'message_id' ] = array ( 'description' => __( 'By default the latest message of the thread will be updated. Specify this message ID to edit another message of the thread.' , 'buddyboss' ), 'required' => false, 'type' => 'integer' , 'sanitize_callback' => 'absint' , 'validate_callback' => 'rest_validate_request_arg' , ); } if ( WP_REST_Server::DELETABLE === $method ) { $key = 'delete_item' ; $args [ 'user_id' ] = array ( 'description' => __( 'The user ID to remove from the thread' , 'buddyboss' ), 'required' => true, 'type' => 'integer' , 'sanitize_callback' => 'absint' , 'validate_callback' => 'rest_validate_request_arg' , 'default' => bp_loggedin_user_id(), ); } } /** * 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_messages_{$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.