Skip to content

Function

Display admin notices.

tml_admin_notices( )

Source

function tml_admin_notices() {
    global $plugin_page;

    $screen = get_current_screen();

    // Bail if not on Dashboard or a TML page
    if ( 'dashboard' !== $screen->id && 'theme-my-login' !== $screen->parent_base ) {
        return;
    }

    // Bail if the user cannot activate plugins
    if ( ! current_user_can( 'activate_plugins' ) ) {
        return;
    }

    if ( 'theme-my-login' === $screen->parent_base ) {
        tml_admin_promotion_notice();
        tml_admin_review_notice();
    }

    $previous_version = tml_get_previous_version();
    $is_pre_7         = $previous_version && version_compare( $previous_version, '7.0', '<' );

    if ( 'theme-my-login-extensions' === $plugin_page && $is_pre_7 ) {
        ?>

        <div class="notice notice-info">
            <p><?php echo wp_kses_post( __( 'As a token of our gratitude, we would like to offer your an incentive for upgrading Theme My Login to version 7.0. For a limited time, we are offering a <strong>20% discount</strong> when you use the code <strong>SAVINGFACE</strong> at checkout. Act now - this offer won\'t last!', 'theme-my-login' ) ); ?></p>
        </div>

        <?php
    }

    $response = tml_admin_get_extensions_feed();
    if ( ! empty( $response ) && ! is_wp_error( $response ) ) {
        $extension = reset( $response );

        $notice_key = 'new_extension-' . $extension->info->slug;

        if ( ! in_array( $notice_key, get_site_option( '_tml_dismissed_notices', array() ), true ) ) :
            ?>

        <div class="notice notice-info tml-notice is-dismissible" data-notice="<?php echo esc_attr( $notice_key ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( $notice_key ) ); ?>">
            <?php
            echo wp_kses_post(
                implode(
                    "\n",
                    array(
                        '<p>' . __( 'A new <strong>Theme My Login</strong> extension is available!', 'theme-my-login' ) . '</p>',
                        '<p>' . sprintf(
                            '<strong>%s</strong>: %s',
                            esc_html( $extension->info->title ),
                            esc_html( $extension->info->excerpt )
                        ) . '</p>',
                        '<p>' . sprintf(
                            '<a class="button button-primary" href="%s">%s</a>',
                            esc_url( $extension->info->link ),
                            __( 'Get This Extension', 'theme-my-login' )
                        ) . '</p>',
                    )
                )
            );
            ?>
        </div>

            <?php
        endif;
    }
}

Uses

Changelog

VersionDescription
7.0 Introduced.