Admin
1 week ago
Ajax
1 week ago
Asset
1 week ago
Context
1 week ago
Customizer
1 week ago
Debug_Bar
1 week ago
Dialog
1 week ago
Documentation
1 week ago
Duplicate
1 week ago
Editor
1 week ago
Image
1 week ago
JSON_LD
1 week ago
Languages
1 week ago
Log
1 week ago
Meta
1 week ago
Models
1 week ago
PUE
1 week ago
Process
1 week ago
Promoter
1 week ago
REST
1 week ago
Repository
1 week ago
Service_Providers
1 week ago
Shortcode
1 week ago
Support
1 week ago
Tabbed_View
1 week ago
Tooltip
1 week ago
Traits
1 week ago
Utils
1 week ago
Validator
1 week ago
Widget
1 week ago
Abstract_Deactivation.php
1 week ago
Abstract_Plugin_Register.php
1 week ago
App_Shop.php
1 week ago
Assets.php
1 week ago
Assets_Pipeline.php
1 week ago
Autoloader.php
1 week ago
Cache.php
1 week ago
Cache_Listener.php
1 week ago
Changelog_Reader.php
1 week ago
Container.php
1 week ago
Context.php
1 week ago
Cost_Utils.php
1 week ago
Credits.php
1 week ago
Customizer.php
1 week ago
DB_Lock.php
1 week ago
Data.php
1 week ago
Date_Utils.php
1 week ago
Db.php
1 week ago
Debug.php
1 week ago
Dependency.php
1 week ago
Deprecation.php
1 week ago
Editor.php
1 week ago
Error.php
1 week ago
Exception.php
1 week ago
Extension.php
1 week ago
Extension_Loader.php
1 week ago
Feature_Detection.php
1 week ago
Field.php
1 week ago
Field_Conditional.php
1 week ago
Freemius.php
1 week ago
Log.php
1 week ago
Main.php
1 week ago
Notices.php
1 week ago
Plugin_Meta_Links.php
1 week ago
Plugins.php
1 week ago
Plugins_API.php
1 week ago
Post_History.php
1 week ago
Post_Transient.php
1 week ago
Promise.php
1 week ago
Repository.php
1 week ago
Rewrite.php
1 week ago
Settings.php
1 week ago
Settings_Manager.php
1 week ago
Settings_Tab.php
1 week ago
Simple_Table.php
1 week ago
Support.php
1 week ago
Tabbed_View.php
1 week ago
Template.php
1 week ago
Template_Factory.php
1 week ago
Template_Part_Cache.php
1 week ago
Templates.php
1 week ago
Terms.php
1 week ago
Timezones.php
1 week ago
Tracker.php
1 week ago
Updater.php
1 week ago
Validate.php
1 week ago
View_Helpers.php
1 week 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 |