| 开发者 | wvdploeg |
|---|---|
| 更新时间 | 2026年10月25日 21:12 |
| PHP版本: | 8.1 及以上 |
| WordPress版本: | 7.1 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
[wxp_opening_times]
Attributes:
schedule - id of the schedule, shown in the admin (default: the first schedule).template - default (week table) or compact (one line), or a template from your theme.show_status - yes or no: the Open/Closed badge (default yes).show_title - yes or no: the schedule name as a heading (default no); heading_level sets the level (2-6, default 3).show_dates - yes or no: the date next to each weekday (default no).week_nav - yes or no: previous/next week buttons (default no); weeks_ahead sets how far visitors can look ahead (0-26, default 4).text_closed, text_open, text_separator, text_open_until, text_closed_opens - other words for this block only, for example text_closed="Absent". They win over the texts set for the schedule in the admin. Use {time} in the last two for the time.schema="yes" to the shortcode (or switch on "Structured data for search engines" in the block or the Elementor widget) and the page also gets the opening times as schema.org JSON-LD (openingHoursSpecification), so search engines can show them. The weekly hours are included, and so are the exceptions of the next 365 days: a closed day has opens and closes "00:00". It is printed once per schedule on a page, and not in the editor previews. The business is a LocalBusiness with the site name and address of the home page; change the type or add details (address, phone number) with the wxp_opening_times_schema filter, for example to make it a Restaurant.
If an SEO plugin already prints the data of your business, use wxp_opening_times_get_schema() to get the same array, and add it there.
For developers
Template override: copy a file from the plugin's templates folder to wxp-opening-times/ in your (child) theme. The markup contract is described at the top of _base.html.twig.
Helper functions (call them after the init action):
wxp_opening_times_is_open( $schedule = '', $at = null ) returns true when open. $at is an optional DateTimeImmutable.wxp_opening_times_get_holidays( $date ) returns the holidays on a date (Y-m-d) as a list of key, label and calendar.wxp_opening_times_get_schedules() returns configured (whether anything was saved yet) and the schedules (id and name).wxp_opening_times_get_status( $schedule = '', $at = null ) returns open, closes_at, opens_at, next_change (Unix times) and schedule, or null for an unknown schedule.wxp_opening_times_status, wxp_opening_times_template_context, wxp_opening_times_template_paths, wxp_opening_times_twig_cache, wxp_opening_times_schema, wxp_opening_times_schema_days, wxp_opening_times_load_css (return false to load your own CSS) and wxp_opening_times_holidays (add holiday providers, for example for other calendars).
CSS custom properties on .wxp-opening-times (--wxp-ot-open-bg, --wxp-ot-closed-bg and more) change the colours.
/wp-content/plugins/ and activate it.[wxp_opening_times] to a page.Opening times belong to a place, not to the visitor. Set the right time zone under Settings, General.
Yes. The status is refreshed in the browser when the page was cached for more than five minutes, and at the moment the status changes.
Secular and Christian holidays, with the Christian ones calculated from Easter. Islamic and Jewish holidays come with the add-on WXP Opening Times: Jewish and Islamic holidays.
wxp_opening_times_get_holidays( $date ) (the holidays on a date) and wxp_opening_times_get_schedules(), used by WXP Local Events to warn about events on holidays and closed days.schema="yes", block toggle, Elementor switch), with the filters wxp_opening_times_schema and wxp_opening_times_schema_days and the function wxp_opening_times_get_schema().text_* shortcode attributes.[wxp_opening_times] shortcode with Twig templates.