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

Description

Formats a year number into a text label for years in the calendar (e.g. "2000").

Parameters:

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

Returns:

string A formatted year label

Information

Fileclass-calendar.php line 385

Full Code

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

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

    // Build timestamp
    $timestamp = self::calculate_timestamp_year_start( $year );

    // Define default label
    $default = (string) $year;

    /**
     * Filters the default calendar "year" label text.
     *
     * @param string    $label      The label text
     * @param int       $year       A year number (e.g. 2000)
     * @param int       $timestamp  A Unix timestamp of the start of the first day (00:00:00 in the site's timezone) of the year
     * @param array     $args       Additional arguments passed to the component template.
     *
     * @return string   Must return a string
     */
    $label = (string) apply_filters( 'wpstagerintegration_calendar_label_year', $default, $year, $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!