Skip to content

gocodebox/banner-notifications

Repository files navigation

Banner Notifications

Test PHPUnit PHP Code Coverage Report Coding Standards Maintainability Test Coverage

WordPress Editor (Gutenberg) blocks for LifterLMS.


Installing

TBW

  • Adding notification area in admin header
    <?php
    // Default to showing notification banners.
    $show_notifications = true;

    // Hide notifications on certain pages.
    $hide_on_these_pages = array( 'pmpro-updates' );
    if ( ! empty( $_REQUEST['page'] ) && in_array( sanitize_text_field( $_REQUEST['page'] ), $hide_on_these_pages ) ) {
        $show_notifications = false;
    }

    // Hide notifications if the user has disabled them.
    if( pmpro_get_max_notification_priority() < 1 ) {
        $show_notifications = false;
    }

    if( $show_notifications ) :
    ?>
    <div id="pmpro_notifications">
    </div>
    <?php
        // To debug a specific notification.
        if ( !empty( $_REQUEST['pmpro_notification'] ) ) {
            $specific_notification = '&pmpro_notification=' . intval( $_REQUEST['pmpro_notification'] );
        } else {
            $specific_notification = '';
        }
    ?>
    <script>
        jQuery(document).ready(function() {
            jQuery.get('<?php echo esc_url_raw( admin_url( "admin-ajax.php?action=pmpro_notifications" . $specific_notification ) ); ?>', function(data) {
                if(data && data != 'NULL')
                    jQuery('#pmpro_notifications').html(data);
            });
        });
    </script>
    <?php endif; ?>
  • Loading an instance of the class with unique slug (ie. for the )
$GLOBALS['pmpro_banner_notifications'] = new Gocodebox_Banner_Notifier( array( 
    'prefix' => 'pmpro',
    'version' => PMPRO_VERSION, 
    'notifications_url' => 'https://notifications.paidmembershipspro.com/v2/notifications.json'
) );

Development

TBW

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages