18 register_activation_hook(
GRAVITYVIEW_FILE, array(
'GravityView_Admin_Notices',
'flush_dismissed_notices' ) );
39 add_action(
'network_admin_notices', array( $this,
'dismiss_notice' ), 50 );
40 add_action(
'admin_notices', array( $this,
'dismiss_notice' ), 50 );
41 add_action(
'admin_notices', array( $this,
'admin_notice' ), 100 );
42 add_action(
'network_admin_notices', array( $this,
'admin_notice' ), 100 );
52 delete_transient(
'gravityview_dismissed_notices' );
63 if( empty( $_GET[
'gv-dismiss'] ) || empty( $_GET[
'notice'] ) ) {
68 if( !wp_verify_nonce( $_GET[
'gv-dismiss'],
'dismiss' ) ) {
72 $notice_id = esc_attr( $_GET[
'notice'] );
100 if( empty( self::$dismissed_notices ) ) {
105 $is_dismissed = !empty( $notice[
'dismiss'] ) && in_array( $notice[
'dismiss'], self::$dismissed_notices );
107 return $is_dismissed ? true :
false;
116 return self::$admin_notices;
130 if( ! is_multisite() ) {
135 if (
gravityview()->plugin->is_network_activated() && ! is_main_site() ) {
140 if( ! is_super_admin() ) {
161 $notices = apply_filters(
'gravityview/admin/notices', self::$admin_notices );
169 self::$dismissed_notices = isset( $_GET[
'show-dismissed-notices'] ) ? array() : (array)get_transient(
'gravityview_dismissed_notices' );
173 foreach( $notices as $notice ) {
177 gravityview()->log->debug(
'Notice not shown because user does not have the capability to view it.', array(
'data' => $notice ) );
182 gravityview()->log->debug(
'Notice not shown because the notice has already been dismissed.', array(
'data' => $notice ) );
186 $output .=
'<div id="message" style="position:relative" class="notice '. gravityview_sanitize_html_class( $notice[
'class'] ).
'">';
191 if( !empty( $notice[
'title'] ) ) {
192 $output .=
'<h3>'.esc_html( $notice[
'title'] ) .
'</h3>';
195 $message = isset( $notice[
'message'] ) ? $notice[
'message'] :
'';
197 if( !empty( $notice[
'dismiss'] ) ) {
199 $dismiss = esc_attr($notice[
'dismiss']);
201 $url = esc_url( add_query_arg( array(
'gv-dismiss' => wp_create_nonce(
'dismiss' ),
'notice' => $dismiss ) ) );
203 $align = is_rtl() ?
'alignleft' :
'alignright';
204 $message .=
'<a href="'.$url.
'" data-notice="'.$dismiss.
'" class="' . $align .
' button button-link">'.esc_html__(
'Dismiss',
'gk-gravityview' ).
'</a></p>';
207 $output .= wpautop( $message );
209 $output .=
'<div class="clear"></div>';
216 unset( $output, $align, $message, $notices );
219 self::$admin_notices = array();
236 if( !isset( $notice[
'message'] ) ) {
237 gravityview()->log->error(
'Notice not set', array(
'data' => $notice ) );
241 $notice[
'class'] = empty( $notice[
'class'] ) ?
'error' : $notice[
'class'];
243 self::$admin_notices[] = $notice;
gravityview_get_floaty( $height=87, $css_class=null)
Get an image of our intrepid explorer friend.
static $dismissed_notices
new GravityView_Admin_Notices
admin_notice()
Outputs the admin notices generated by the plugin.
Handle displaying and storing of admin notices for GravityView.
is_notice_dismissed( $notice)
Has the notice been dismissed already in the admin?
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
static flush_dismissed_notices()
Clear out the dismissed notices when the plugin gets activated.
dismiss_notice()
Dismiss a GravityView notice - stores the dismissed notices for 16 weeks.
static add_notice( $notice=array())
Add a notice to be displayed in the admin.
gravityview()
The main GravityView wrapper function.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
static get_notices()
Get admin notices.
check_show_multisite_notices()
Handle whether to display notices in Multisite based on plugin activation status. ...