| @@ -124,12 +124,15 @@ | ||
| 124 | 124 | $type = 'success', |
| 125 | 125 | $is_sticky = false, |
| 126 | 126 | $id = '', |
| 127 | 127 | $store_if_sticky = true, |
| 128 | - $network_level_or_blog_id = null, | |
| 129 | - $is_dimissible = null | |
| 128 | + $network_level_or_blog_id = null | |
| 130 | 129 | ) { |
| 131 | - $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id ); | |
| 130 | + if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) { | |
| 131 | + $notices = $this->_network_notices; | |
| 132 | + } else { | |
| 133 | + $notices = $this->get_site_notices( $network_level_or_blog_id ); | |
| 134 | + } | |
| 132 | 135 | |
| 133 | 136 | $notices->add( |
| 134 | 137 | $message, |
| 135 | 138 | $title, |
| @@ -135,13 +138,9 @@ | ||
| 135 | 138 | $title, |
| 136 | 139 | $type, |
| 137 | 140 | $is_sticky, |
| 138 | 141 | $id, |
| 139 | - $store_if_sticky, | |
| 140 | - null, | |
| 141 | - null, | |
| 142 | - false, | |
| 143 | - $is_dimissible | |
| 142 | + $store_if_sticky | |
| 144 | 143 | ); |
| 145 | 144 | } |
| 146 | 145 | |
| 147 | 146 | /** |
| @@ -149,11 +148,10 @@ | ||
| 149 | 148 | * @since 1.0.7 |
| 150 | 149 | * |
| 151 | 150 | * @param string|string[] $ids |
| 152 | 151 | * @param int|null $network_level_or_blog_id |
| 153 | - * @param bool $store | |
| 154 | 152 | */ |
| 155 | - function remove_sticky( $ids, $network_level_or_blog_id = null, $store = true ) { | |
| 153 | + function remove_sticky( $ids, $network_level_or_blog_id = null ) { | |
| 156 | 154 | if ( ! is_array( $ids ) ) { |
| 157 | 155 | $ids = array( $ids ); |
| 158 | 156 | } |
| 159 | 157 | |
| @@ -162,9 +160,9 @@ | ||
| 162 | 160 | } else { |
| 163 | 161 | $notices = $this->get_site_notices( $network_level_or_blog_id ); |
| 164 | 162 | } |
| 165 | 163 | |
| 166 | - return $notices->remove_sticky( $ids, $store ); | |
| 164 | + return $notices->remove_sticky( $ids ); | |
| 167 | 165 | } |
| 168 | 166 | |
| 169 | 167 | /** |
| 170 | 168 | * Check if sticky message exists by id. |
| @@ -177,9 +175,13 @@ | ||
| 177 | 175 | * |
| 178 | 176 | * @return bool |
| 179 | 177 | */ |
| 180 | 178 | function has_sticky( $id, $network_level_or_blog_id = null ) { |
| 181 | - $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id ); | |
| 179 | + if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) { | |
| 180 | + $notices = $this->_network_notices; | |
| 181 | + } else { | |
| 182 | + $notices = $this->get_site_notices( $network_level_or_blog_id ); | |
| 183 | + } | |
| 182 | 184 | |
| 183 | 185 | return $notices->has_sticky( $id ); |
| 184 | 186 | } |
| 185 | 187 | |
| @@ -197,9 +199,8 @@ | ||
| 197 | 199 | * @param number|null $wp_user_id |
| 198 | 200 | * @param string|null $plugin_title |
| 199 | 201 | * @param bool $is_network_and_blog_admins Whether or not the message should be shown both on network and |
| 200 | 202 | * blog admin pages. |
| 201 | - * @param bool $is_dismissible | |
| 202 | 203 | */ |
| 203 | 204 | function add_sticky( |
| 204 | 205 | $message, |
| 205 | 206 | $id, |
| @@ -207,35 +208,20 @@ | ||
| 207 | 208 | $type = 'success', |
| 208 | 209 | $network_level_or_blog_id = null, |
| 209 | 210 | $wp_user_id = null, |
| 210 | 211 | $plugin_title = null, |
| 211 | - $is_network_and_blog_admins = false, | |
| 212 | - $is_dismissible = true, | |
| 213 | - $data = array() | |
| 212 | + $is_network_and_blog_admins = false | |
| 214 | 213 | ) { |
| 215 | - $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id ); | |
| 214 | + if ( $this->should_use_network_notices( $id, $network_level_or_blog_id ) ) { | |
| 215 | + $notices = $this->_network_notices; | |
| 216 | + } else { | |
| 217 | + $notices = $this->get_site_notices( $network_level_or_blog_id ); | |
| 218 | + } | |
| 216 | 219 | |
| 217 | - $notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins, $is_dismissible, $data ); | |
| 220 | + $notices->add_sticky( $message, $id, $title, $type, $wp_user_id, $plugin_title, $is_network_and_blog_admins ); | |
| 218 | 221 | } |
| 219 | 222 | |
| 220 | 223 | /** |
| 221 | - * Retrieves the data of a sticky notice. | |
| 222 | - * | |
| 223 | - * @author Leo Fajardo (@leorw) | |
| 224 | - * @since 2.4.3 | |
| 225 | - * | |
| 226 | - * @param string $id | |
| 227 | - * @param int|null $network_level_or_blog_id | |
| 228 | - * | |
| 229 | - * @return array|null | |
| 230 | - */ | |
| 231 | - function get_sticky( $id, $network_level_or_blog_id ) { | |
| 232 | - $notices = $this->get_site_or_network_notices( $id, $network_level_or_blog_id ); | |
| 233 | - | |
| 234 | - return $notices->get_sticky( $id ); | |
| 235 | - } | |
| 236 | - | |
| 237 | - /** | |
| 238 | 224 | * Clear all sticky messages. |
| 239 | 225 | * |
| 240 | 226 | * @author Vova Feldman (@svovaf) |
| 241 | 227 | * @since 2.0.0 |
| @@ -240,11 +226,10 @@ | ||
| 240 | 226 | * @author Vova Feldman (@svovaf) |
| 241 | 227 | * @since 2.0.0 |
| 242 | 228 | * |
| 243 | 229 | * @param int|null $network_level_or_blog_id |
| 244 | - * @param bool $is_temporary | |
| 245 | 230 | */ |
| 246 | - function clear_all_sticky( $network_level_or_blog_id = null, $is_temporary = false ) { | |
| 231 | + function clear_all_sticky( $network_level_or_blog_id = null ) { | |
| 247 | 232 | if ( ! $this->_is_multisite || |
| 248 | 233 | false === $network_level_or_blog_id || |
| 249 | 234 | 0 == $network_level_or_blog_id || |
| 250 | 235 | is_null( $network_level_or_blog_id ) |
| @@ -249,15 +234,15 @@ | ||
| 249 | 234 | 0 == $network_level_or_blog_id || |
| 250 | 235 | is_null( $network_level_or_blog_id ) |
| 251 | 236 | ) { |
| 252 | 237 | $notices = $this->get_site_notices( $network_level_or_blog_id ); |
| 253 | - $notices->clear_all_sticky( $is_temporary ); | |
| 238 | + $notices->clear_all_sticky(); | |
| 254 | 239 | } |
| 255 | 240 | |
| 256 | 241 | if ( $this->_is_multisite && |
| 257 | 242 | ( true === $network_level_or_blog_id || is_null( $network_level_or_blog_id ) ) |
| 258 | 243 | ) { |
| 259 | - $this->_network_notices->clear_all_sticky( $is_temporary ); | |
| 244 | + $this->_network_notices->clear_all_sticky(); | |
| 260 | 245 | } |
| 261 | 246 | } |
| 262 | 247 | |
| 263 | 248 | /** |
| @@ -329,25 +314,8 @@ | ||
| 329 | 314 | return $network_level_or_blog_id; |
| 330 | 315 | } |
| 331 | 316 | |
| 332 | 317 | return fs_is_network_admin(); |
| 333 | - } | |
| 334 | - | |
| 335 | - /** | |
| 336 | - * Retrieves an instance of FS_Admin_Notice_Manager. | |
| 337 | - * | |
| 338 | - * @author Leo Fajardo (@leorw) | |
| 339 | - * @since 2.5.0 | |
| 340 | - * | |
| 341 | - * @param string $id | |
| 342 | - * @param int|null $network_level_or_blog_id | |
| 343 | - * | |
| 344 | - * @return FS_Admin_Notice_Manager | |
| 345 | - */ | |
| 346 | - private function get_site_or_network_notices( $id, $network_level_or_blog_id ) { | |
| 347 | - return $this->should_use_network_notices( $id, $network_level_or_blog_id ) ? | |
| 348 | - $this->_network_notices : | |
| 349 | - $this->get_site_notices( $network_level_or_blog_id ); | |
| 350 | 318 | } |
| 351 | 319 | |
| 352 | 320 | #endregion |
| 353 | 321 | } |