PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 2.7.0
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v2.7.0
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | inc/layout/endpoints.php +26 -9 2.6.12.7.0 View file →
@@ -9,9 +9,9 @@
9 9
10 10 use \WP_REST_Response;
11 11 use \WP_REST_Server;
12 12
13 -const AB_API_NAMESPACE = 'blockspare/v1';
13 +const BS_API_NAMESPACE = 'blockspare/v1';
14 14
15 15 const LAYOUTS_ROUTE = 'layouts';
16 16 const SINGLE_LAYOUT_ROUTE = 'layouts/([A-Za-z])\w+/';
17 17
@@ -25,9 +25,9 @@
25 25 const SINGLE_PAGE_ROUTE = 'pages/([A-Za-z])\w+/';
26 26
27 27 const FAVORITE_LAYOUTS_ROUTE = 'layouts/favorites';
28 28 const ALL_LAYOUTS_ROUTE = 'layouts/all';
29 -
29 +const IMPORT_ROUTE = 'importdata';
30 30 add_action( 'rest_api_init', __NAMESPACE__ . '\register_layout_endpoints' );
31 31 /**
32 32 * Create custom endpoints for block settings
33 33 */
@@ -39,9 +39,9 @@
39 39 * Note: Keep this route before the other routes
40 40 * otherwise they may override this one.
41 41 */
42 42 register_rest_route(
43 - AB_API_NAMESPACE,
43 + BS_API_NAMESPACE,
44 44 FAVORITE_LAYOUTS_ROUTE,
45 45 [
46 46 'methods' => WP_REST_Server::READABLE,
47 47 'callback' => function () {
@@ -58,9 +58,9 @@
58 58 * that combines all sections, layouts,
59 59 * and additional layouts.
60 60 */
61 61 register_rest_route(
62 - AB_API_NAMESPACE,
62 + BS_API_NAMESPACE,
63 63 ALL_LAYOUTS_ROUTE,
64 64 [
65 65 'methods' => WP_REST_Server::READABLE,
66 66 'callback' => function ( \WP_REST_Request $request ) {
@@ -111,9 +111,9 @@
111 111 * Register the layouts GET endpoint.
112 112 * Returns all registered layouts.
113 113 */
114 114 register_rest_route(
115 - AB_API_NAMESPACE,
115 + BS_API_NAMESPACE,
116 116 LAYOUTS_ROUTE,
117 117 [
118 118 'methods' => WP_REST_Server::READABLE,
119 119 'callback' => function () {
@@ -129,9 +129,9 @@
129 129 * Register the single layout GET endpoint.
130 130 * Returns a single requested layout.
131 131 */
132 132 register_rest_route(
133 - AB_API_NAMESPACE,
133 + BS_API_NAMESPACE,
134 134 SINGLE_LAYOUT_ROUTE,
135 135 [
136 136 'methods' => WP_REST_Server::READABLE,
137 137 'callback' => function ( $request ) {
@@ -153,9 +153,9 @@
153 153 /**
154 154 * Register the favorites update endpoint.
155 155 */
156 156 register_rest_route(
157 - AB_API_NAMESPACE,
157 + BS_API_NAMESPACE,
158 158 FAVORITE_LAYOUTS_ROUTE,
159 159 [
160 160 'methods' => 'PATCH',
161 161 'callback' => function ( $request ) {
@@ -187,9 +187,9 @@
187 187 /**
188 188 * Register the favorites delete endpoint.
189 189 */
190 190 register_rest_route(
191 - AB_API_NAMESPACE,
191 + BS_API_NAMESPACE,
192 192 FAVORITE_LAYOUTS_ROUTE,
193 193 [
194 194 'methods' => 'DELETE',
195 195 'callback' => function ( $request ) {
@@ -220,14 +220,31 @@
220 220 * Register the sections GET endpoint.
221 221 * Returns all registered sections.
222 222 */
223 223 register_rest_route(
224 - AB_API_NAMESPACE,
224 + BS_API_NAMESPACE,
225 225 SECTIONS_ROUTE,
226 226 [
227 227 'methods' => WP_REST_Server::READABLE,
228 228 'callback' => function () {
229 229 return new WP_REST_Response( (array) blockspare_get_sections() );
230 + },
231 + 'permission_callback' => function () {
232 + return current_user_can( 'edit_posts' );
233 + },
234 + ]
235 + );
236 +
237 + register_rest_route(
238 + BS_API_NAMESPACE,
239 + IMPORT_ROUTE,
240 + [
241 + 'methods' => WP_REST_Server::EDITABLE,
242 + 'callback' => function (\WP_REST_Request $request) {
243 + $request_params = $request->get_params();
244 +
245 + $data = blockspare_import_images_replace_url($request_params['content'] ) ;
246 + return new WP_REST_Response( $data );
230 247 },
231 248 'permission_callback' => function () {
232 249 return current_user_can( 'edit_posts' );
233 250 },