business-hours.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-bar.php
2 months ago
class-wpcom-rest-api-v2-endpoint-admin-color.php
7 months ago
class-wpcom-rest-api-v2-endpoint-admin-menu.php
1 month ago
class-wpcom-rest-api-v2-endpoint-agent-guidelines-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-ai.php
1 week ago
class-wpcom-rest-api-v2-endpoint-app-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-application-password-extras.php
3 months ago
class-wpcom-rest-api-v2-endpoint-block-editor-assets.php
1 week ago
class-wpcom-rest-api-v2-endpoint-blog-stats.php
7 months ago
class-wpcom-rest-api-v2-endpoint-email-preview.php
2 months ago
class-wpcom-rest-api-v2-endpoint-external-media.php
7 months ago
class-wpcom-rest-api-v2-endpoint-following.php
7 months ago
class-wpcom-rest-api-v2-endpoint-goodreads.php
7 months ago
class-wpcom-rest-api-v2-endpoint-google-docs.php
7 months ago
class-wpcom-rest-api-v2-endpoint-guidelines-banner-dismissed.php
1 week ago
class-wpcom-rest-api-v2-endpoint-instagram-gallery.php
2 months ago
class-wpcom-rest-api-v2-endpoint-mailchimp.php
7 months ago
class-wpcom-rest-api-v2-endpoint-mcp-settings.php
2 days ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-list.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-categories-subscriptions-count.php
7 months ago
class-wpcom-rest-api-v2-endpoint-newsletter-email-sent-status.php
3 months ago
class-wpcom-rest-api-v2-endpoint-podcast-player.php
2 months ago
class-wpcom-rest-api-v2-endpoint-profile.php
7 months ago
class-wpcom-rest-api-v2-endpoint-related-posts.php
7 months ago
class-wpcom-rest-api-v2-endpoint-resolve-redirect.php
7 months ago
class-wpcom-rest-api-v2-endpoint-search.php
1 week ago
class-wpcom-rest-api-v2-endpoint-send-email-preview.php
1 month ago
class-wpcom-rest-api-v2-endpoint-subscribers-list.php
1 week ago
class-wpcom-rest-api-v2-endpoint-template-loader.php
7 months ago
class-wpcom-rest-api-v2-endpoint-top-posts.php
2 months ago
class-wpcom-rest-api-v2-endpoint-transient.php
7 months ago
class-wpcom-rest-api-v3-endpoint-blogging-prompts.php
7 months ago
class-wpcom-rest-api-v3-endpoint-jitm.php
7 months ago
gutenberg-available-extensions.php
7 months ago
hello.php
7 months ago
memberships.php
1 week ago
publicize-connection-test-results.php
7 months ago
service-api-keys.php
1 month ago
sites-posts-featured-media-url.php
7 months ago
subscribers.php
7 months ago
business-hours.php
70 lines
| 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' ); |
| 70 |