gocodebox/banner-notifications

Library for showing admin-area banner notices.

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

Type:wordpress-plugin

1.0.1 2025-05-23 16:18 UTC

This package is auto-updated.

Last update: 2025-06-03 07:19:11 UTC


README

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