PluginProbe ʕ •ᴥ•ʔ
MonsterInsights – Google Analytics Dashboard for WordPress (Website Stats Made Easy) / 10.1.3
MonsterInsights – Google Analytics Dashboard for WordPress (Website Stats Made Easy) v10.1.3
10.2.2 10.2.1 10.2.0 10.1.3 trunk 10.0.0 10.0.1 10.0.2 10.0.3 10.1.1 10.1.2 8.1.0 8.10.0 8.10.1 8.11.0 8.12.0 8.12.1 8.13.0 8.13.1 8.14.0 8.14.1 8.15 8.16 8.17 8.18 8.19.0 8.2.0 8.20.0 8.20.1 8.21.0 8.22.0 8.23.0 8.23.1 8.24.0 8.25.0 8.26.0 8.27.0 8.28.0 8.3.0 8.3.1 8.3.2 8.3.3 8.3.4 8.4.0 8.5.0 8.5.1 8.5.2 8.5.3 8.6.0 8.7.0 8.8.0 8.8.1 8.8.2 8.9.0 8.9.1 9.0.0 9.0.1 9.1.0 9.1.1 9.10.0 9.10.1 9.11.0 9.11.1 9.2.0 9.2.1 9.2.2 9.2.3 9.2.4 9.3.0 9.3.1 9.4.0 9.4.1 9.5.1 9.5.2 9.5.3 9.6.0 9.6.1 9.7.0 9.8.0 9.9.0
google-analytics-for-wordpress / includes / admin / notice.php
google-analytics-for-wordpress / includes / admin Last commit date
feature-feedback 1 year ago licensing 1 year ago notifications 6 months ago pages 1 month ago reports 1 month ago site-notes 1 month ago admin-assets.php 1 month ago admin.php 1 month ago ajax.php 1 month ago api-auth.php 1 month ago class-monsterinsights-am-deactivation-survey.php 8 months ago class-monsterinsights-charitable-notice.php 7 months ago class-monsterinsights-onboarding.php 1 month ago class-monsterinsights-usage-tracking.php 1 month ago common.php 1 month ago eea-compliance.php 1 month ago exclude-page-metabox.php 1 month ago index.php 3 years ago notice.php 1 year ago notification-event-runner.php 1 year ago notification-event.php 1 year ago notifications.php 1 month ago product-feed-cronjob.php 6 months ago reporting.php 3 years ago review.php 1 year ago routes.php 1 month ago setup-checklist.php 1 month ago sharedcount.php 1 year ago tracking.php 7 months ago translations.php 1 year ago uninstall.php 4 years ago wp-site-health.php 3 years ago
notice.php
250 lines
1 <?php
2 /**
3 * Notices admin class.
4 *
5 * Handles retrieving whether a particular notice has been dismissed or not,
6 * as well as marking a notice as dismissed.
7 *
8 * @since 6.0.0
9 *
10 * @package MonsterInsights
11 * @subpackage Notices
12 * @author Chris Christoff
13 */
14
15 // Exit if accessed directly
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 final class MonsterInsights_Notice_Admin {
21
22 /**
23 * Holds all dismissed notices
24 *
25 * @access public
26 * @since 6.0.0
27 * @var array $notices Array of dismissed notices.
28 */
29 public $notices;
30
31 /**
32 * Primary class constructor.
33 *
34 * @access public
35 * @since 6.0.0
36 */
37 public function __construct() {
38
39 // Populate $notices
40 $this->notices = get_option( 'monsterinsights_notices' );
41 if ( ! is_array( $this->notices ) ) {
42 $this->notices = array();
43 }
44
45 }
46
47 /**
48 * Checks if a given notice has been dismissed or not
49 *
50 * @access public
51 *
52 * @param string $notice Programmatic Notice Name
53 *
54 * @return bool Notice Dismissed
55 * @since 6.0.0
56 *
57 */
58
59 public function is_dismissed( $notice ) {
60 if ( ! isset( $this->notices[ $notice ] ) ) {
61 return false;
62 }
63
64 return true;
65
66 }
67
68 /**
69 * Marks the given notice as dismissed
70 *
71 * @access public
72 *
73 * @param string $notice Programmatic Notice Name
74 *
75 * @return null
76 * @since 6.0.0
77 *
78 */
79 public function dismiss( $notice ) {
80 $this->notices[ $notice ] = true;
81 update_option( 'monsterinsights_notices', $this->notices );
82
83 }
84
85
86 /**
87 * Marks a notice as not dismissed
88 *
89 * @access public
90 *
91 * @param string $notice Programmatic Notice Name
92 *
93 * @return null
94 * @since 6.0.0
95 *
96 */
97 public function undismiss( $notice ) {
98 unset( $this->notices[ $notice ] );
99 update_option( 'monsterinsights_notices', $this->notices );
100
101 }
102
103 /**
104 * Displays an inline notice with some MonsterInsights styling.
105 *
106 * @access public
107 *
108 * @param string $notice Programmatic Notice Name
109 * @param string $title Title
110 * @param string $message Message
111 * @param string $type Message Type (updated|warning|error) - green, yellow/orange and red respectively.
112 * @param string $button_text Button Text (optional)
113 * @param string $button_url Button URL (optional)
114 * @param bool $is_dismissible User can Dismiss Message (default: false)
115 *
116 * @since 6.0.0
117 *
118 */
119 public function display_inline_notice( $name, $title, $message, $type = 'success', $is_dismissible = false, $args = array() ) {
120 /* Available/Planned $args options
121 * $args = array(
122 * 'primary' => array(
123 * 'text' => '',
124 * 'url' => '',
125 * 'target' => '',
126 * 'class' => 'button button-primary',
127 * ),
128 * 'secondary' => array(
129 * 'text' => '',
130 * 'url' => '',
131 * 'target' => '',
132 * 'class' => 'button button-secondary',
133 * ),
134 * 'skip_message_escape' => true // note: This param is for internal use only. Do not use as a developer.
135 * );
136 */
137
138
139 // Check if the notice is dismissible, and if so has been dismissed.
140 if ( $is_dismissible && $this->is_dismissed( $name ) ) {
141 // Nothing to show here, return!
142 return '';
143 }
144
145 $dismissible = ( $is_dismissible ) ? ' is-dismissible' : '';
146
147 // Display inline notice
148 ob_start();
149 ?>
150 <div
151 class="monsterinsights-notice <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice' . esc_attr($dismissible); ?>"
152 data-notice="<?php echo esc_attr( $name ); ?>">
153 <div
154 class="monsterinsights-notice-icon <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-icon' ?>">
155 </div>
156 <div
157 class="monsterinsights-notice-text <?php echo 'monsterinsights-' . esc_attr( $type ) . '-notice-text' ?>">
158 <?php
159 // Title
160 if ( ! empty ( $title ) ) {
161 ?>
162 <p class="monsterinsights-notice-title"><?php echo esc_html( $title ); ?></p>
163 <?php
164 }
165
166 // Message
167 if ( ! empty( $message ) ) {
168 if ( empty( $args['skip_message_escape'] ) ) {
169 ?>
170 <p class="monsterinsights-notice-message"><?php echo esc_html( $message ); ?></p>
171 <?php
172 } else {
173 ?>
174 <p class="monsterinsights-notice-message"><?php echo $message; // phpcs:ignore ?></p>
175 <?php
176 }
177 }
178
179 // Primary Button
180 if ( ! empty( $args['primary']['text'] ) ) {
181
182 $text = '';
183 if ( ! empty( $args['primary']['text'] ) ) {
184 $text = $args['primary']['text'];
185 }
186
187 $url = '#';
188 if ( ! empty( $args['primary']['url'] ) ) {
189 $url = $args['primary']['url'];
190 }
191
192 $target = '';
193 if ( ! empty( $args['primary']['target'] ) && $args['primary']['target'] === 'blank' ) {
194 $target = ' target="_blank" rel="noopener noreferrer"';
195 }
196
197 $class = 'button button-primary';
198 if ( ! empty( $args['primary']['class'] ) ) {
199 $class = ' class="' . $args['primary']['class'] . '"';
200 }
201 ?>
202 <a href="<?php echo esc_url( $url ); ?>"<?php echo esc_attr($target); ?><?php echo esc_attr($class); ?>><?php echo esc_html( $text ); ?></a>
203 <?php
204 }
205
206 // Secondary Button
207 if ( ! empty( $args['secondary']['text'] ) ) {
208
209 $text = '';
210 if ( ! empty( $args['secondary']['text'] ) ) {
211 $text = $args['secondary']['text'];
212 }
213
214 $url = '#';
215 if ( ! empty( $args['secondary']['url'] ) ) {
216 $url = $args['secondary']['url'];
217 }
218
219 $target = '';
220 if ( ! empty( $args['secondary']['target'] ) && $args['secondary']['target'] === 'blank' ) {
221 $target = ' target="_blank" rel="noopener noreferrer"';
222 }
223
224 $class = 'button button-secondary';
225 if ( ! empty( $args['secondary']['class'] ) ) {
226 $class = ' class="' . $args['secondary']['class'] . '"';
227 }
228 ?>
229 <a href="<?php echo esc_url( $url ); ?>"<?php echo esc_attr($target); ?><?php echo esc_attr($class); ?>><?php echo esc_html( $text ); ?></a>
230 <?php
231 }
232
233 // Dismiss Button
234 if ( $is_dismissible ) {
235 ?>
236 <button type="button" class="notice-dismiss<?php echo esc_attr($dismissible); ?>">
237 <span class="screen-reader-text">
238 <?php esc_html_e( 'Dismiss this notice', 'google-analytics-for-wordpress' ); ?>
239 </span>
240 </button>
241 <?php
242 }
243 ?>
244 </div>
245 </div>
246 <?php
247 return ob_get_clean();
248 }
249 }
250