\WP_Stager_Integration\Calendar::format_month_label(int $year, int $month, array $args = array()): string

Description

Formats a year and month number into a text label for months in the calendar (e.g. "January 2000").

Parameters:

ParameterTypeDescription
$year int The year (e.g. 2000)
$month int The month (1–12)
$args array (Optional) Additional arguments passed to the component template.

Returns:

string A formatted month label

Information

Fileclass-calendar.php line 348

Full Code

/**
 * Formats a year and month number into a text label for months in the calendar (e.g. "January 2000").
 *
 * @param int $year    The year (e.g. 2000)
 * @param int $month   The month (1–12)
 * @param array $args   (Optional) Additional arguments passed to the component template.
 *
 * @return string   A formatted month label
 */
public static function format_month_label( $year, $month, $args = array() ) {

    // Type casting
    $year  = (int) $year;
    $month = (int) $month;
    $args  = (array) $args;

    // Build timestamp
    $timestamp = self::calculate_timestamp_month_start( $year, $month );

    // Define default label
    $default = wp_date( 'F Y', $timestamp );

    /**
     * Filters the default calendar "month" label text.
     *
     * @param string    $label      The label text
     * @param int       $year       A year number (e.g. 2000)
     * @param int       $month      A month number (1-12)
     * @param int       $timestamp  A Unix timestamp of the start of the first day (00:00:00 in the site's timezone) of the month
     * @param array     $args       Additional arguments passed to the component template.
     *
     * @return string   Must return a string
     */
    $label = (string) apply_filters( 'wpstagerintegration_calendar_label_month', $default, $year, $month, $timestamp, $args );

    return $label;
}

💡 If you ever get stuck or have a question, please check our FAQs, our Free Integration Service, our paid Full Integration Service, or reach out to us!

Get WP Stager Integration

🎁 Limited offer: Use code WELCOME26 to get your first month for free!