PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
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
← All changes | _inc/lib/core-api/wpcom-endpoints/business-hours.php +69 -0 16.2-beta → 16.3 View file →
@@ -1,0 +1,69 @@
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 +if ( ! defined( 'ABSPATH' ) ) {
9 + exit( 0 );
10 +}
11 +
12 +/**
13 + * Business Hours: Localized week
14 + *
15 + * @since 7.1
16 + */
17 +class WPCOM_REST_API_V2_Endpoint_Business_Hours extends WP_REST_Controller {
18 + /**
19 + * Constructor.
20 + */
21 + public function __construct() {
22 + $this->namespace = 'wpcom/v2';
23 + $this->rest_base = 'business-hours';
24 + // This endpoint *does not* need to connect directly to Jetpack sites.
25 + add_action( 'rest_api_init', array( $this, 'register_routes' ) );
26 + }
27 +
28 + /**
29 + * Register endpoint route.
30 + */
31 + public function register_routes() {
32 + // GET /sites/<blog_id>/business-hours/localized-week - Return the localized.
33 + register_rest_route(
34 + $this->namespace,
35 + '/' . $this->rest_base . '/localized-week',
36 + array(
37 + array(
38 + 'methods' => WP_REST_Server::READABLE,
39 + 'callback' => array( $this, 'get_localized_week' ),
40 + 'permission_callback' => '__return_true',
41 + ),
42 + )
43 + );
44 + }
45 +
46 + /**
47 + * Retreives localized business hours
48 + *
49 + * @return array data object containing information about business hours
50 + */
51 + public function get_localized_week() {
52 + global $wp_locale;
53 +
54 + return array(
55 + 'days' => array(
56 + 'Sun' => $wp_locale->get_weekday( 0 ),
57 + 'Mon' => $wp_locale->get_weekday( 1 ),
58 + 'Tue' => $wp_locale->get_weekday( 2 ),
59 + 'Wed' => $wp_locale->get_weekday( 3 ),
60 + 'Thu' => $wp_locale->get_weekday( 4 ),
61 + 'Fri' => $wp_locale->get_weekday( 5 ),
62 + 'Sat' => $wp_locale->get_weekday( 6 ),
63 + ),
64 + 'startOfWeek' => (int) get_option( 'start_of_week', 0 ),
65 + );
66 + }
67 +}
68 +
69 +wpcom_rest_api_v2_load_plugin( 'WPCOM_REST_API_V2_Endpoint_Business_Hours' );