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
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 | 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.