| @@ -11,8 +11,20 @@ | ||
| 11 | 11 | * @since 2.3.9 |
| 12 | 12 | * @since 2.7 Dismissed notices are stored in an option instead of a user meta |
| 13 | 13 | */ |
| 14 | 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 | + */ | |
| 15 | 27 | private static $notices = array(); |
| 16 | 28 | |
| 17 | 29 | /** |
| 18 | 30 | * Constructor |
| @@ -35,8 +47,9 @@ | ||
| 35 | 47 | * @since 2.3.9 |
| 36 | 48 | * |
| 37 | 49 | * @param string $name Notice name |
| 38 | 50 | * @param string $html Content of the notice |
| 51 | + * @return void | |
| 39 | 52 | */ |
| 40 | 53 | public static function add_notice( $name, $html ) { |
| 41 | 54 | self::$notices[ $name ] = $html; |
| 42 | 55 | } |
| @@ -41,13 +54,13 @@ | ||
| 41 | 54 | self::$notices[ $name ] = $html; |
| 42 | 55 | } |
| 43 | 56 | |
| 44 | 57 | /** |
| 45 | - * Get custom notices | |
| 58 | + * Get custom notices. | |
| 46 | 59 | * |
| 47 | 60 | * @since 2.3.9 |
| 48 | 61 | * |
| 49 | - * @return array | |
| 62 | + * @return string[] | |
| 50 | 63 | */ |
| 51 | 64 | public static function get_notices() { |
| 52 | 65 | return self::$notices; |
| 53 | 66 | } |
| @@ -88,8 +101,13 @@ | ||
| 88 | 101 | * @return bool |
| 89 | 102 | */ |
| 90 | 103 | protected function can_display_notice( $notice ) { |
| 91 | 104 | $screen = get_current_screen(); |
| 105 | + | |
| 106 | + if ( empty( $screen ) ) { | |
| 107 | + return false; | |
| 108 | + } | |
| 109 | + | |
| 92 | 110 | $screen_id = sanitize_title( __( 'Languages', 'polylang' ) ); |
| 93 | 111 | |
| 94 | 112 | /** |
| 95 | 113 | * Filter admin notices which can be displayed |
| @@ -120,8 +138,9 @@ | ||
| 120 | 138 | * |
| 121 | 139 | * @since 2.3.9 |
| 122 | 140 | * |
| 123 | 141 | * @param string $notice |
| 142 | + * @return void | |
| 124 | 143 | */ |
| 125 | 144 | public static function dismiss( $notice ) { |
| 126 | 145 | $dismissed = get_option( 'pll_dismissed_notices', array() ); |
| 127 | 146 | |
| @@ -134,8 +153,10 @@ | ||
| 134 | 153 | /** |
| 135 | 154 | * Handle a click on the dismiss button |
| 136 | 155 | * |
| 137 | 156 | * @since 2.3.9 |
| 157 | + * | |
| 158 | + * @return void | |
| 138 | 159 | */ |
| 139 | 160 | public function hide_notice() { |
| 140 | 161 | if ( isset( $_GET['pll-hide-notice'], $_GET['_pll_notice_nonce'] ) ) { |
| 141 | 162 | $notice = sanitize_key( $_GET['pll-hide-notice'] ); |
| @@ -149,8 +170,10 @@ | ||
| 149 | 170 | /** |
| 150 | 171 | * Displays notices |
| 151 | 172 | * |
| 152 | 173 | * @since 2.3.9 |
| 174 | + * | |
| 175 | + * @return void | |
| 153 | 176 | */ |
| 154 | 177 | public function display_notices() { |
| 155 | 178 | if ( current_user_can( 'manage_options' ) ) { |
| 156 | 179 | // Core notices |
| @@ -183,8 +206,9 @@ | ||
| 183 | 206 | * |
| 184 | 207 | * @since 2.3.9 |
| 185 | 208 | * |
| 186 | 209 | * @param string $name Notice name |
| 210 | + * @return void | |
| 187 | 211 | */ |
| 188 | 212 | public function dismiss_button( $name ) { |
| 189 | 213 | printf( |
| 190 | 214 | '<a class="notice-dismiss" href="%s"><span class="screen-reader-text">%s</span></a>', |
| @@ -197,8 +221,10 @@ | ||
| 197 | 221 | /** |
| 198 | 222 | * Displays a notice if WooCommerce is activated without Polylang for WooCommerce |
| 199 | 223 | * |
| 200 | 224 | * @since 2.3.9 |
| 225 | + * | |
| 226 | + * @return void | |
| 201 | 227 | */ |
| 202 | 228 | private function pllwc_notice() { |
| 203 | 229 | ?> |
| 204 | 230 | <div class="pll-notice notice notice-warning"> |
| @@ -220,8 +246,10 @@ | ||
| 220 | 246 | /** |
| 221 | 247 | * Displays a notice asking for a review |
| 222 | 248 | * |
| 223 | 249 | * @since 2.3.9 |
| 250 | + * | |
| 251 | + * @return void | |
| 224 | 252 | */ |
| 225 | 253 | private function review_notice() { |
| 226 | 254 | ?> |
| 227 | 255 | <div class="pll-notice notice notice-info"> |