File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ function json_oauth_server_loaded() {
117117add_action ( 'template_redirect ' , 'json_oauth_server_loaded ' , -100 );
118118
119119/**
120- * Register API routes
120+ * Register v1 API routes
121121 *
122122 * @param array $data Index data
123123 * @return array Filtered data
@@ -137,6 +137,27 @@ function json_oauth_api_routes( $data ) {
137137}
138138add_filter ( 'json_index ' , 'json_oauth_api_routes ' );
139139
140+ /**
141+ * Register v2 API routes
142+ *
143+ * @param object $response_object WP_REST_Response Object
144+ * @return object Filtered WP_REST_Response object
145+ */
146+ function json_oauth_api_routes_v2 ( $ response_object ) {
147+ if ( empty ( $ response_object ->data ['authentication ' ] ) ) {
148+ $ response_object ->data ['authentication ' ] = array ();
149+ }
150+
151+ $ response_object ->data ['authentication ' ]['oauth1 ' ] = array (
152+ 'request ' => home_url ( 'oauth1/request ' ),
153+ 'authorize ' => home_url ( 'oauth1/authorize ' ),
154+ 'access ' => home_url ( 'oauth1/access ' ),
155+ 'version ' => '0.1 ' ,
156+ );
157+ return $ response_object ;
158+ }
159+ add_filter ( 'rest_index ' , 'json_oauth_api_routes_v2 ' );
160+
140161/**
141162 * Register the authorization page
142163 *
You can’t perform that action at this time.
0 commit comments