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

Description

Formats a year and week number into a text label for weeks in the calendar (e.g. "Week 12").

Parameters:

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

Returns:

string A formatted week label

Information

Fileclass-calendar.php line 304

Full Code

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

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

    // Build timestamp
    $timestamp = self::calculate_timestamp_week_start( $year, $week );

    // Define default label
    $default = sprintf( /*
             * Translators:
             * %d: A week number (1-53)
             */
            __( 'Week %d', 'wp-stager-integration' ),
            $week,
    );

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