PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | admin/admin-notices.php +33 -2 2.73.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * A class to manage admin notices
5 8 * displayed only to admin, based on 'manage_options' capability
@@ -8,8 +11,20 @@
8 11 * @since 2.3.9
9 12 * @since 2.7 Dismissed notices are stored in an option instead of a user meta
10 13 */
11 14 class PLL_Admin_Notices {
15 + /**
16 + * Stores the plugin options.
17 + *
18 + * @var array
19 + */
20 + protected $options;
21 +
22 + /**
23 + * Stores custom notices.
24 + *
25 + * @var string[]
26 + */
12 27 private static $notices = array();
13 28
14 29 /**
15 30 * Constructor
@@ -32,8 +47,9 @@
32 47 * @since 2.3.9
33 48 *
34 49 * @param string $name Notice name
35 50 * @param string $html Content of the notice
51 + * @return void
36 52 */
37 53 public static function add_notice( $name, $html ) {
38 54 self::$notices[ $name ] = $html;
39 55 }
@@ -38,13 +54,13 @@
38 54 self::$notices[ $name ] = $html;
39 55 }
40 56
41 57 /**
42 - * Get custom notices
58 + * Get custom notices.
43 59 *
44 60 * @since 2.3.9
45 61 *
46 - * @return array
62 + * @return string[]
47 63 */
48 64 public static function get_notices() {
49 65 return self::$notices;
50 66 }
@@ -85,8 +101,13 @@
85 101 * @return bool
86 102 */
87 103 protected function can_display_notice( $notice ) {
88 104 $screen = get_current_screen();
105 +
106 + if ( empty( $screen ) ) {
107 + return false;
108 + }
109 +
89 110 $screen_id = sanitize_title( __( 'Languages', 'polylang' ) );
90 111
91 112 /**
92 113 * Filter admin notices which can be displayed
@@ -117,8 +138,9 @@
117 138 *
118 139 * @since 2.3.9
119 140 *
120 141 * @param string $notice
142 + * @return void
121 143 */
122 144 public static function dismiss( $notice ) {
123 145 $dismissed = get_option( 'pll_dismissed_notices', array() );
124 146
@@ -131,8 +153,10 @@
131 153 /**
132 154 * Handle a click on the dismiss button
133 155 *
134 156 * @since 2.3.9
157 + *
158 + * @return void
135 159 */
136 160 public function hide_notice() {
137 161 if ( isset( $_GET['pll-hide-notice'], $_GET['_pll_notice_nonce'] ) ) {
138 162 $notice = sanitize_key( $_GET['pll-hide-notice'] );
@@ -146,8 +170,10 @@
146 170 /**
147 171 * Displays notices
148 172 *
149 173 * @since 2.3.9
174 + *
175 + * @return void
150 176 */
151 177 public function display_notices() {
152 178 if ( current_user_can( 'manage_options' ) ) {
153 179 // Core notices
@@ -180,8 +206,9 @@
180 206 *
181 207 * @since 2.3.9
182 208 *
183 209 * @param string $name Notice name
210 + * @return void
184 211 */
185 212 public function dismiss_button( $name ) {
186 213 printf(
187 214 '<a class="notice-dismiss" href="%s"><span class="screen-reader-text">%s</span></a>',
@@ -194,8 +221,10 @@
194 221 /**
195 222 * Displays a notice if WooCommerce is activated without Polylang for WooCommerce
196 223 *
197 224 * @since 2.3.9
225 + *
226 + * @return void
198 227 */
199 228 private function pllwc_notice() {
200 229 ?>
201 230 <div class="pll-notice notice notice-warning">
@@ -217,8 +246,10 @@
217 246 /**
218 247 * Displays a notice asking for a review
219 248 *
220 249 * @since 2.3.9
250 + *
251 + * @return void
221 252 */
222 253 private function review_notice() {
223 254 ?>
224 255 <div class="pll-notice notice notice-info">