BP_REST_Document_Endpoint::bp_rest_document_support()
Added document support for activity, forum and messages.
Description
Source
File: bp-document/classes/class-bp-rest-document-endpoint.php
1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 | public function bp_rest_document_support() { if ( function_exists( 'bp_is_profile_document_support_enabled' ) && bp_is_profile_document_support_enabled() ) { bp_rest_register_field( 'activity' , // Id of the BuddyPress component the REST field is about. 'bp_documents' , // Used into the REST response/request. array ( 'get_callback' => array ( $this , 'bp_documents_get_rest_field_callback' ), // The function to use to get the value of the REST Field. 'update_callback' => array ( $this , 'bp_documents_update_rest_field_callback' ), // The function to use to update the value of the REST Field. 'schema' => array ( // The example_field REST schema. 'description' => 'Activity Documents.' , 'type' => 'object' , 'context' => array ( 'embed' , 'view' , 'edit' ), ), ) ); register_rest_field( 'activity_comments' , // Id of the BuddyPress component the REST field is about. 'bp_documents' , // Used into the REST response/request. array ( 'get_callback' => array ( $this , 'bp_documents_get_rest_field_callback' ), // The function to use to get the value of the REST Field. 'update_callback' => array ( $this , 'bp_documents_update_rest_field_callback' ), // The function to use to update the value of the REST Field. 'schema' => array ( // The example_field REST schema. 'description' => 'Activity Documents.' , 'type' => 'object' , 'context' => array ( 'embed' , 'view' , 'edit' ), ), ) ); } if ( function_exists( 'bp_is_messages_document_support_enabled' ) && bp_is_messages_document_support_enabled() ) { // Messages Document Support. bp_rest_register_field( 'messages' , // Id of the BuddyPress component the REST field is about. 'bp_documents' , // Used into the REST response/request. array ( 'get_callback' => array ( $this , 'bp_documents_get_rest_field_callback_messages' ), // The function to use to get the value of the REST Field. 'update_callback' => array ( $this , 'bp_documents_update_rest_field_callback_messages' ), // The function to use to update the value of the REST Field. 'schema' => array ( // The example_field REST schema. 'description' => 'Messages Medias.' , 'type' => 'object' , 'context' => array ( 'view' , 'edit' ), ), ) ); } if ( function_exists( 'bp_is_forums_document_support_enabled' ) && true === bp_is_forums_document_support_enabled() ) { // Topic Document Support. register_rest_field( 'topics' , 'bbp_documents' , array ( 'get_callback' => array ( $this , 'bbp_document_get_rest_field_callback' ), 'update_callback' => array ( $this , 'bbp_document_update_rest_field_callback' ), 'schema' => array ( 'description' => 'Topic Documentss.' , 'type' => 'object' , 'context' => array ( 'embed' , 'view' , 'edit' ), ), ) ); // Reply Document Support. register_rest_field( 'reply' , 'bbp_documents' , array ( 'get_callback' => array ( $this , 'bbp_document_get_rest_field_callback' ), 'update_callback' => array ( $this , 'bbp_document_update_rest_field_callback' ), 'schema' => array ( 'description' => 'Reply Documents.' , 'type' => 'object' , 'context' => array ( 'embed' , 'view' , 'edit' ), ), ) ); } } |
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.