get_calendar( array $args = array() ): void|string
- Since
- 1.0.0, 6.8.0
- Source
wp-includes/general-template.php:2477
Description
The calendar is cached, which will be retrieved, if it exists. If there are no posts for the month, then it will not be displayed.
Compatibility
- WordPress
- since 6.8.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$argsarrayoptional- Arguments for the
get_calendarfunction.Default:array()$initialbooldefault: trueWhether to use initial calendar names.$displaybooldefault: trueWhether to display the calendar output.$post_typestringdefault: 'post'Optional. Post type.
Return value
void|string- Void if
$displayargument is true, calendar HTML if$displayis false.
Performance profile
How much work a call to get_calendar() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Scales with input
- Instructions
- 256–323
- Plugin surface
- 2 hooks
- Called by
- 2
Reaches the database via ->get_row().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 553.
Third-party callbacks on 'get_calendar_args', 'get_calendar' run inside this call, and their cost is not bounded by anything here.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly - cacheobject cache
wp_cache_get()called directly - optionoption read or write
get_option()called directly - serializeserialisation
serialize()called directly - sqldatabase query
->get_row()called directly
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 24 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_calendar() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$pad && !$day | 256–264 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$pad && !$day | 258–265 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 262–270 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 264–271 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 264–270 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 266–271 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && $pad && !$day | 270–276 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && $pad && !$day | 272–277 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$pad && !$day | 279–287 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$pad && !$day | 281–288 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 285–293 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 287–294 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
12 further outcomes, up to 323 instructions
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 287–293 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 289–294 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && $pad && !$day | 293–299 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && $pad && !$day | 295–300 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$pad && !$day | 302–310 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$pad && !$day | 304–311 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 308–316 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 310–317 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && !$day | 310–316 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && !$day | 312–317 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && empty($m) && !$wdcount && $pad && !$day | 316–322 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), current_time(), current_time(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
empty($original_args) && post_type_exists() && !isset($value) && is_array($cache) && empty($monthnum) && empty($w) && !empty($m) && !$wdcount && $pad && !$day | 318–323 | wp_parse_args(), apply_filters(), post_type_exists(), wp_recursive_ksort(), serialize(), md5(), wp_cache_get(), get_option(), mktime(), gmdate(), zeroise(), ->prepare(), ->get_row(), zeroise(), ->prepare(), ->get_row(), _x(), ->get_month(), gmdate(), sprintf(), zeroise(), zeroise(), ->prepare(), ->get_results(), gmdate(), calendar_week_mod(), esc_attr(), gmdate(), mktime(), gmdate(), calendar_week_mod(), esc_attr(), __(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), get_month_link(), ->get_month(), ->get_month_abbrev(), sprintf(), wp_cache_set(), apply_filters() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 551 | 256–323 | 40 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 553 | 256–323 | 40 | |
| 8.4 | 553 | 256–323 | 40 | 11 fewer instructions than PHP 8.3 |
| 8.3 | 564 | 256–329 | 40 | |
| 8.2 | 564 | 256–329 | 40 | |
| 8.1 | 564 | 256–329 | 40 | |
| 7.4 | 564 | 256–329 | 40 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 3
3 hooks fire while get_calendar() runs, in this order:
- apply_filters( get_calendar_args )filterline 2515 (+38 into the body)
Filter the `get_calendar` function arguments before they are used.
Uses · 15
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_parse_args()Merges user defined arguments into defaults array.
- post_type_exists()Determines whether a post type is registered.
- wp_recursive_ksort()Sorts the keys of an array alphabetically.
- wp_cache_get()Retrieves the cache contents from the cache by key and group.
- wp_cache_set()Saves the data to the cache.
- get_option()Retrieves an option value based on an option name.
- current_time()Retrieves the current time based on specified type.
- zeroise()Add leading zeros when necessary.
- _x()Retrieves translated string with gettext context.
- esc_attr()Escaping for HTML attributes.
- calendar_week_mod()Gets number of days since the start of the week.
Show all 15
- __()Retrieves the translation of $text.
- get_day_link()Retrieves the permalink for the day archives with year and month.
- get_month_link()Retrieves the permalink for the month archives with year.
Used by · 2
- WP_Widget_Calendar::widget()Outputs the content for the current Calendar widget instance.
- render_block_core_calendar()Renders the `core/calendar` block on server.
Source code
function get_calendar( $args = array() ) { global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; $defaults = array( 'initial' => true, 'display' => true, 'post_type' => 'post', ); $original_args = func_get_args(); $args = array(); if ( ! empty( $original_args ) ) { if ( ! is_array( $original_args[0] ) ) { if ( isset( $original_args[0] ) && is_bool( $original_args[0] ) ) { $defaults['initial'] = $original_args[0]; } if ( isset( $original_args[1] ) && is_bool( $original_args[1] ) ) { $defaults['display'] = $original_args[1]; } } else { $args = $original_args[0]; } } /** * Filter the `get_calendar` function arguments before they are used. * * @since 6.8.0 * * @param array $args { * Optional. Arguments for the `get_calendar` function. * * @type bool $initial Whether to use initial calendar names. Default true. * @type bool $display Whether to display the calendar output. Default true. * @type string $post_type Optional. Post type. Default 'post'. * } */ $args = apply_filters( 'get_calendar_args', wp_parse_args( $args, $defaults ) ); if ( ! post_type_exists( $args['post_type'] ) ) { $args['post_type'] = 'post'; } $w = 0; if ( isset( $_GET['w'] ) ) { $w = (int) $_GET['w']; } /* * Normalize the cache key. * * The following ensures the same cache key is used for the same parameter * and parameter equivalents. This prevents `post_type > post, initial > true` * from generating a different key from the same values in the reverse order. * * `display` is excluded from the cache key as the cache contains the same * HTML regardless of this function's need to echo or return the output. * * The global values contain data generated by the URL query string variables. */ $cache_args = $args; unset( $cache_args['display'] ); $cache_args['globals'] = array( 'm' => $m, 'monthnum' => $monthnum, 'year' => $year, 'week' => $w, ); wp_recursive_ksort( $cache_args ); $key = md5( serialize( $cache_args ) ); $cache = wp_cache_get( 'get_calendar', 'calendar' ); if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) { /** This filter is documented in wp-includes/general-template.php */ $output = apply_filters( 'get_calendar', $cache[ $key ], $args ); if ( $args['display'] ) {Changelog
Introduced in 1.0.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$args added.verified against source$initial removed.verified against source$display removed.verified against source$args parameter, with backward compatibility for the replaced $initial and $display parameters.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/general-template.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.