Admin
2 weeks ago
Ajax
2 weeks ago
Asset
2 weeks ago
Context
2 weeks ago
Customizer
2 weeks ago
Debug_Bar
2 weeks ago
Dialog
2 weeks ago
Documentation
2 weeks ago
Duplicate
2 weeks ago
Editor
2 weeks ago
Image
2 weeks ago
JSON_LD
2 weeks ago
Languages
2 weeks ago
Log
2 weeks ago
Meta
2 weeks ago
Models
2 weeks ago
PUE
2 weeks ago
Process
2 weeks ago
Promoter
2 weeks ago
REST
2 weeks ago
Repository
2 weeks ago
Service_Providers
2 weeks ago
Shortcode
2 weeks ago
Support
2 weeks ago
Tabbed_View
2 weeks ago
Tooltip
2 weeks ago
Traits
2 weeks ago
Utils
2 weeks ago
Validator
2 weeks ago
Widget
2 weeks ago
Abstract_Deactivation.php
2 weeks ago
Abstract_Plugin_Register.php
2 weeks ago
App_Shop.php
2 weeks ago
Assets.php
2 weeks ago
Assets_Pipeline.php
2 weeks ago
Autoloader.php
2 weeks ago
Cache.php
2 weeks ago
Cache_Listener.php
2 weeks ago
Changelog_Reader.php
2 weeks ago
Container.php
2 weeks ago
Context.php
2 weeks ago
Cost_Utils.php
2 weeks ago
Credits.php
2 weeks ago
Customizer.php
2 weeks ago
DB_Lock.php
2 weeks ago
Data.php
2 weeks ago
Date_Utils.php
2 weeks ago
Db.php
2 weeks ago
Debug.php
2 weeks ago
Dependency.php
2 weeks ago
Deprecation.php
2 weeks ago
Editor.php
2 weeks ago
Error.php
2 weeks ago
Exception.php
2 weeks ago
Extension.php
2 weeks ago
Extension_Loader.php
2 weeks ago
Feature_Detection.php
2 weeks ago
Field.php
2 weeks ago
Field_Conditional.php
2 weeks ago
Freemius.php
2 weeks ago
Log.php
2 weeks ago
Main.php
2 weeks ago
Notices.php
2 weeks ago
Plugin_Meta_Links.php
2 weeks ago
Plugins.php
2 weeks ago
Plugins_API.php
2 weeks ago
Post_History.php
2 weeks ago
Post_Transient.php
2 weeks ago
Promise.php
2 weeks ago
Repository.php
2 weeks ago
Rewrite.php
2 weeks ago
Settings.php
2 weeks ago
Settings_Manager.php
2 weeks ago
Settings_Tab.php
2 weeks ago
Simple_Table.php
2 weeks ago
Support.php
2 weeks ago
Tabbed_View.php
2 weeks ago
Template.php
2 weeks ago
Template_Factory.php
2 weeks ago
Template_Part_Cache.php
2 weeks ago
Templates.php
2 weeks ago
Terms.php
2 weeks ago
Timezones.php
2 weeks ago
Tracker.php
2 weeks ago
Updater.php
2 weeks ago
Validate.php
2 weeks ago
View_Helpers.php
2 weeks ago
Notices.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | class Tribe__Notices { |
| 4 | /** |
| 5 | * Notices to be displayed in the admin |
| 6 | * @var array |
| 7 | */ |
| 8 | protected $notices = []; |
| 9 | |
| 10 | /** |
| 11 | * Define an admin notice |
| 12 | * |
| 13 | * @param string $key |
| 14 | * @param string $notice |
| 15 | * |
| 16 | * @return bool |
| 17 | */ |
| 18 | public static function set_notice( $key, $notice ) { |
| 19 | |
| 20 | /** |
| 21 | * Provides an opportunity to alter the text of admin notices. |
| 22 | * |
| 23 | * @since 4.5.5 |
| 24 | * |
| 25 | * @param string $notice The notice text. |
| 26 | * @param string $key The key of the notice being filtered. |
| 27 | * |
| 28 | * @return string. |
| 29 | */ |
| 30 | $notice = apply_filters( 'tribe_events_set_notice', $notice, $key ); |
| 31 | |
| 32 | self::instance()->notices[ $key ] = $notice; |
| 33 | |
| 34 | return true; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Check to see if an admin notice exists |
| 39 | * |
| 40 | * @param string $key |
| 41 | * |
| 42 | * @return bool |
| 43 | */ |
| 44 | public static function is_notice( $key ) { |
| 45 | return ! empty( self::instance()->notices[ $key ] ) ? true : false; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Remove an admin notice |
| 50 | * |
| 51 | * @param string $key |
| 52 | * |
| 53 | * @return bool |
| 54 | */ |
| 55 | public static function remove_notice( $key ) { |
| 56 | if ( self::is_notice( $key ) ) { |
| 57 | unset( self::instance()->notices[ $key ] ); |
| 58 | |
| 59 | return true; |
| 60 | } else { |
| 61 | return false; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get the admin notices |
| 67 | * |
| 68 | * @return array |
| 69 | */ |
| 70 | public static function get() { |
| 71 | return self::instance()->notices; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Static Singleton Factory Method |
| 76 | * |
| 77 | * @return Tribe__Notices |
| 78 | */ |
| 79 | public static function instance() { |
| 80 | static $instance; |
| 81 | |
| 82 | if ( ! $instance ) { |
| 83 | $class_name = __CLASS__; |
| 84 | $instance = new $class_name; |
| 85 | } |
| 86 | |
| 87 | return $instance; |
| 88 | } |
| 89 | } |
| 90 |