<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[59908] trunk: Widgets: Add post type support to `get_calendar()` function.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/59908">59908</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/59908","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>audrasjb</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2025-03-03 19:54:34 +0000 (Mon, 03 Mar 2025)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Widgets: Add post type support to `get_calendar()` function.
This changeset updates the `get_calendar()` function to allow post type filtering via the `$post_type` parameter, with backard compatibility for previous params. It also updates the related `get_calendar_args` and `get_calendar` hooks accordingly.
Props sebastianpisula, swissspidy, dwainm, moxie, sukhendu2002, audrasjb, mukesh27.
Fixes <a href="https://core.trac.wordpress.org/ticket/34093">#34093</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesgeneraltemplatephp">trunk/src/wp-includes/general-template.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsfunctionsgetCalendarphp">trunk/tests/phpunit/tests/functions/getCalendar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesgeneraltemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/general-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/general-template.php 2025-03-03 18:43:08 UTC (rev 59907)
+++ trunk/src/wp-includes/general-template.php 2025-03-03 19:54:34 UTC (rev 59908)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2233,6 +2233,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * no posts for the month, then it will not be displayed.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 1.0.0
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 6.8.0 New argument $args added, with backward compatibility.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @global wpdb $wpdb WordPress database abstraction object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @global int $m
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2241,21 +2242,64 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @global WP_Locale $wp_locale WordPress date and time locale object.
</span><span class="cx" style="display: block; padding: 0 10px"> * @global array $posts
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $initial Optional. Whether to use initial calendar names. Default true.
- * @param bool $display Optional. Whether to display the calendar output. Default true.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @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'.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return void|string Void if `$display` argument is true, calendar HTML if `$display` is false.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function get_calendar( $initial = true, $display = true ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function get_calendar( $args = array() ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $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'.
+ * }
+ * @return array The arguments for the `get_calendar` function.
+ */
+ $args = apply_filters( 'get_calendar_args', wp_parse_args( $args, $defaults ) );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> $key = md5( $m . $monthnum . $year );
</span><span class="cx" style="display: block; padding: 0 10px"> $cache = wp_cache_get( 'get_calendar', 'calendar' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> /** This filter is documented in wp-includes/general-template.php */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $output = apply_filters( 'get_calendar', $cache[ $key ] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $output = apply_filters( 'get_calendar', $cache[ $key ], $args );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $display ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $args['display'] ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> echo $output;
</span><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2267,9 +2311,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cache = array();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type = $args['post_type'];
+ if ( ! post_type_exists( $post_type ) ) {
+ $post_type = 'post';
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Quick check. If we have no posts at all, abort!
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $posts ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $prepared_query = $wpdb->prepare( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' LIMIT 1", $post_type );
+ $gotsome = $wpdb->get_var( $prepared_query );
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! $gotsome ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $cache[ $key ] = '';
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( 'get_calendar', $cache, 'calendar' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2309,22 +2359,27 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $last_day = gmdate( 't', $unixmonth );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Get the next and previous month and year with at least one post.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $previous = $wpdb->get_row(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $previous_prepared_query = $wpdb->prepare(
</ins><span class="cx" style="display: block; padding: 0 10px"> "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
</span><span class="cx" style="display: block; padding: 0 10px"> FROM $wpdb->posts
</span><span class="cx" style="display: block; padding: 0 10px"> WHERE post_date < '$thisyear-$thismonth-01'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- AND post_type = 'post' AND post_status = 'publish'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ AND post_type = %s AND post_status = 'publish'
</ins><span class="cx" style="display: block; padding: 0 10px"> ORDER BY post_date DESC
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- LIMIT 1"
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ LIMIT 1",
+ $post_type
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $next = $wpdb->get_row(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $previous = $wpdb->get_row( $previous_prepared_query );
+
+ $next_prepared_query = $wpdb->prepare(
</ins><span class="cx" style="display: block; padding: 0 10px"> "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
</span><span class="cx" style="display: block; padding: 0 10px"> FROM $wpdb->posts
</span><span class="cx" style="display: block; padding: 0 10px"> WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- AND post_type = 'post' AND post_status = 'publish'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ AND post_type = %s AND post_status = 'publish'
</ins><span class="cx" style="display: block; padding: 0 10px"> ORDER BY post_date ASC
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- LIMIT 1"
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ LIMIT 1",
+ $post_type
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $next = $wpdb->get_row( $next_prepared_query );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
</span><span class="cx" style="display: block; padding: 0 10px"> $calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2344,7 +2399,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $myweek as $wd ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $day_name = $args['initial'] ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
</ins><span class="cx" style="display: block; padding: 0 10px"> $wd = esc_attr( $wd );
</span><span class="cx" style="display: block; padding: 0 10px"> $calendar_output .= "\n\t\t<th scope=\"col\" aria-label=\"$wd\">$day_name</th>";
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2358,13 +2413,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $daywithpost = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Get days with posts.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $dayswithposts = $wpdb->get_results(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $dayswithposts_prepared_query = $wpdb->prepare(
</ins><span class="cx" style="display: block; padding: 0 10px"> "SELECT DISTINCT DAYOFMONTH(post_date)
</span><span class="cx" style="display: block; padding: 0 10px"> FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- AND post_type = 'post' AND post_status = 'publish'
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ AND post_type = %s AND post_status = 'publish'
</ins><span class="cx" style="display: block; padding: 0 10px"> AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ARRAY_N
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $post_type
</ins><span class="cx" style="display: block; padding: 0 10px"> );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $dayswithposts = $wpdb->get_results( $dayswithposts_prepared_query, ARRAY_N );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $dayswithposts ) {
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( (array) $dayswithposts as $daywith ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2452,19 +2508,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $cache[ $key ] = $calendar_output;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_cache_set( 'get_calendar', $cache, 'calendar' );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $display ) {
- /**
- * Filters the HTML calendar output.
- *
- * @since 3.0.0
- *
- * @param string $calendar_output HTML output of the calendar.
- */
- echo apply_filters( 'get_calendar', $calendar_output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the HTML calendar output.
+ *
+ * @since 3.0.0
+ * @since 6.8.0 New argument $args added, with backward compatibility.
+ *
+ * @param string $calendar_output HTML output of the calendar.
+ * @param array $args {
+ * Optional. Array of display arguments.
+ *
+ * @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'.
+ * }
+ */
+ $calendar_output = apply_filters( 'get_calendar', $calendar_output, $args );
+
+ if ( $args['display'] ) {
+ echo $calendar_output;
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- /** This filter is documented in wp-includes/general-template.php */
- return apply_filters( 'get_calendar', $calendar_output );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ return $calendar_output;
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span></span></pre></div>
<a id="trunktestsphpunittestsfunctionsgetCalendarphp"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: trunk/tests/phpunit/tests/functions/getCalendar.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/functions/getCalendar.php (rev 0)
+++ trunk/tests/phpunit/tests/functions/getCalendar.php 2025-03-03 19:54:34 UTC (rev 59908)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,93 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Tests for the get_calendar() function.
+ *
+ * @since 6.8.0
+ *
+ * @group functions
+ * @group calendar
+ *
+ * @covers ::get_calendar
+ */
+class Tests_Get_Calendar extends WP_UnitTestCase {
+
+ /**
+ * Array of post IDs.
+ *
+ * @var int[]
+ */
+ protected static $post_ids = array();
+
+ /**
+ * Set up before class.
+ *
+ * @param WP_UnitTest_Factory $factory Test factory.
+ */
+ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+ self::$post_ids = $factory->post->create_many(
+ 3,
+ array(
+ 'post_date' => '2025-02-01 12:00:00',
+ )
+ );
+ }
+
+ /**
+ * Test that get_calendar() displays output when display is true.
+ *
+ * @ticket 34093
+ */
+ public function test_get_calendar_display() {
+ $expected = '<table id="wp-calendar"';
+ $actual = get_echo( 'get_calendar', array( array( 'display' => true ) ) );
+ $this->assertStringContainsString( $expected, $actual );
+ }
+
+ /**
+ * Test that get_calendar() respects the get_calendar_args filter.
+ *
+ * @ticket 34093
+ */
+ public function test_get_calendar_args_filter() {
+ $page_id = self::factory()->post->create(
+ array(
+ 'post_type' => 'page',
+ 'post_date' => '2025-02-03 12:00:00',
+ )
+ );
+
+ add_filter(
+ 'get_calendar_args',
+ function ( $args ) {
+ $args['post_type'] = 'page';
+ return $args;
+ }
+ );
+
+ $calendar_html = get_echo( 'get_calendar' );
+
+ remove_all_filters( 'get_calendar_args' );
+
+ $this->assertStringContainsString( '<table id="wp-calendar"', $calendar_html );
+ $this->assertStringContainsString( 'Posts published on February 3, 2025', $calendar_html );
+ $this->assertStringContainsString( 'February 2025', $calendar_html );
+ }
+
+ /**
+ * Test that get_calendar() maintains backwards compatibility with old parameter format.
+ *
+ * @ticket 34093
+ */
+ public function test_get_calendar_backwards_compatibility() {
+ $first_calendar_html = get_echo( 'get_calendar', array( false ) );
+
+ wp_cache_delete( 'get_calendar', 'calendar' );
+
+ $second_calendar_html = get_calendar( false, false );
+
+ $this->assertStringContainsString( '<th scope="col" aria-label="Monday">Mon</th>', $first_calendar_html );
+ $this->assertStringContainsString( 'February 2025', $first_calendar_html );
+ $this->assertStringContainsString( '<table id="wp-calendar"', $second_calendar_html );
+ $this->assertStringContainsString( '<th scope="col" aria-label="Monday">Mon</th>', $second_calendar_html );
+ }
+}
</ins><span class="cx" style="display: block; padding: 0 10px">Property changes on: trunk/tests/phpunit/tests/functions/getCalendar.php
</span><span class="cx" style="display: block; padding: 0 10px">___________________________________________________________________
</span></span></pre></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Added: svn:eol-style</h4></div>
<ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+native
</ins><span class="cx" style="display: block; padding: 0 10px">\ No newline at end of property
</span></div>
</body>
</html>