Gocodebox_Banner_Notifier::__construct( array $args = array() )
Constructor.
Contents
Parameters Parameters
- $args
-
(array) (Optional) Either a string (used as the prefix) or an associative array.<br>
- 'prefix'
(string) Unique slug for hooks, options, transients, etc.<br> - 'notifications_url'
(string) Feed URL.<br>
Default value: array()
- 'prefix'
Source Source
File: libraries/banner-notifications/src/notifications.php
public function __construct( $args = array() ) {
// Accept just a string prefix for convenience.
if ( is_string( $args ) ) {
$args = array( 'prefix' => $args );
}
$defaults = array(
'prefix' => '',
'notifications_url' => '',
'version' => '',
);
$args = wp_parse_args( $args, $defaults );
if ( ! $args['prefix'] || ! $args['notifications_url'] || ! $args['version'] ) {
throw new Exception( 'Missing required arguments: prefix, version and/or notifications_url.' );
}
$this->prefix = sanitize_key( $args['prefix'] );
$this->version = sanitize_title( $args['version'] );
$this->notifications_url = sanitize_url( $args['notifications_url'] );
add_action( "wp_ajax_{$this->prefix}_notifications", array( $this, 'notifications' ) );
add_action( "wp_ajax_{$this->prefix}_hide_notice", array( $this, 'hide_notice' ) );
// Add filters for standard checks.
add_filter( "{$this->prefix}_notification_test_plugins_active", array( $this, 'notification_test_plugins_active' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_check_plugin_version", array( $this, 'notification_test_check_plugin_version' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_license", array( $this, 'notification_test_pmpro_license' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_num_members", array( $this, 'notification_test_pmpro_num_members' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_num_levels", array( $this, 'notification_test_pmpro_num_levels' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_num_discount_codes", array( $this, 'notification_test_pmpro_num_discount_codes' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_revenue", array( $this, 'notification_test_pmpro_revenue' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_num_orders", array( $this, 'notification_test_pmpro_num_orders' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_pmpro_setting", array( $this, 'notification_test_pmpro_setting' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_llms_setting", array( $this, 'notification_test_llms_setting' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_llms_revenue", array( $this, 'notification_test_llms_revenue' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_llms_num_orders", array( $this, 'notification_test_llms_num_orders' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_site_url_match", array( $this, 'notification_test_site_url_match' ), 10, 2 );
add_filter( "{$this->prefix}_notification_test_check_option", array( $this, 'notification_test_check_option' ), 10, 2 );
}
Expand full source code Collapse full source code View on GitHub