Skip to content

Function

Get the sale currently announced by thememylogin.com, if any.

The announcement arrives with the extensions feed, so it is cached for as long as the feed is.

tml_admin_get_promotion( int|null $now = null )

Parameters

$now int|null Default null
The current time. Defaults to now.

Return

array|null The promotion, or null if none is running.

Source

function tml_admin_get_promotion( $now = null ) {
    $promotion = get_site_transient( 'tml_promotion' );

    if ( false === $promotion ) {
        delete_site_transient( 'tml_extensions_feed-' . md5( http_build_query( array( 'number' => 12 ) ) ) );
        tml_admin_get_extensions_feed();
        $promotion = get_site_transient( 'tml_promotion' );
    }

    // A failed fetch sets nothing, so hold off an hour rather than retry on every screen load.
    if ( false === $promotion ) {
        $promotion = array();
        set_site_transient( 'tml_promotion', $promotion, HOUR_IN_SECONDS );
    }

    return tml_admin_sanitize_promotion( $promotion, null === $now ? time() : $now );
}

Uses

Used by

Changelog

VersionDescription
7.3 Introduced.