PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 7.2.2
Jetpack – WP Security, Backup, Speed, & Growth v7.2.2
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
jetpack / _inc / lib / core-api / class.jetpack-core-api-widgets-endpoints.php

class.jetpack-core-api-widgets-endpoints.php in Jetpack – WP Security, Backup, Speed, & Growth 7.2.2, at _inc/lib/core-api/class.jetpack-core-api-widgets-endpoints.php

57 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Widget information getter endpoint.
4 *
5 */
6 class Jetpack_Core_API_Widget_Endpoint {
7
8 /**
9 * @since 5.5.0
10 *
11 * @param WP_REST_Request $request {
12 * Array of parameters received by request.
13 *
14 * @type string $id Widget id.
15 * }
16 *
17 * @return WP_REST_Response|WP_Error A REST response if the request was served successfully, otherwise an error.
18 */
19 public function process( $request ) {
20 $widget_base = _get_widget_id_base( $request['id'] );
21 $widget_id = (int) substr( $request['id'], strlen( $widget_base ) + 1 );
22
23 switch( $widget_base ) {
24 case 'milestone_widget':
25 $instances = get_option( 'widget_milestone_widget', array() );
26
27 if (
28 class_exists( 'Milestone_Widget' )
29 && is_active_widget( false, $widget_base . '-' . $widget_id, $widget_base )
30 && isset( $instances[ $widget_id ] )
31 ) {
32 $instance = $instances[ $widget_id ];
33 $widget = new Milestone_Widget();
34 return $widget->get_widget_data( $instance );
35 }
36 }
37
38 return new WP_Error(
39 'not_found',
40 esc_html__( 'The requested widget was not found.', 'jetpack' ),
41 array( 'status' => 404 )
42 );
43 }
44
45 /**
46 * Check that the current user has permissions to view widget information.
47 * For the currently supported widget there are no permissions required.
48 *
49 * @since 5.5.0
50 *
51 * @return bool
52 */
53 public function can_request() {
54 return true;
55 }
56 }
57