PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 14.9.2
Jetpack – WP Security, Backup, Speed, & Growth v14.9.2
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 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
jetpack / _inc / lib / core-api / wpcom-endpoints / business-hours.php
business-hours.php
66 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 /**
3 * Build localized strings for use with the Business Hours Block.
4 *
5 * @package automattic/jetpack
6 */
7
8 /**
9 * Business Hours: Localized week
10 *
11 * @since 7.1
12 */
13 class WPCOM_REST_API_V2_Endpoint_Business_Hours extends WP_REST_Controller {
14 /**
15 * Constructor.
16 */
17 public function __construct() {
18 $this->namespace = 'wpcom/v2';
19 $this->rest_base = 'business-hours';
20 // This endpoint *does not* need to connect directly to Jetpack sites.
21 add_action( 'rest_api_init', array( $this, 'register_routes' ) );
22 }
23
24 /**
25 * Register endpoint route.
26 */
27 public function register_routes() {
28 // GET /sites/<blog_id>/business-hours/localized-week - Return the localized.
29 register_rest_route(
30 $this->namespace,
31 '/' . $this->rest_base . '/localized-week',
32 array(
33 array(
34 'methods' => WP_REST_Server::READABLE,
35 'callback' => array( $this, 'get_localized_week' ),
36 'permission_callback' => '__return_true',
37 ),
38 )
39 );
40 }
41
42 /**
43 * Retreives localized business hours
44 *
45 * @return array data object containing information about business hours
46 */
47 public function get_localized_week() {
48 global $wp_locale;
49
50 return array(
51 'days' => array(
52 'Sun' => $wp_locale->get_weekday( 0 ),
53 'Mon' => $wp_locale->get_weekday( 1 ),
54 'Tue' => $wp_locale->get_weekday( 2 ),
55 'Wed' => $wp_locale->get_weekday( 3 ),
56 'Thu' => $wp_locale->get_weekday( 4 ),
57 'Fri' => $wp_locale->get_weekday( 5 ),
58 'Sat' => $wp_locale->get_weekday( 6 ),
59 ),
60 'startOfWeek' => (int) get_option( 'start_of_week', 0 ),
61 );
62 }
63 }
64
65 wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Business_Hours' );
66