disable-admin-notices
Last commit date
admin
1 month ago
includes
1 month ago
languages
3 years ago
libs
1 month ago
migrations
1 year ago
vendor
1 month ago
CHANGELOG.md
1 month ago
clearfy.php
7 months ago
disable-admin-notices.php
1 month ago
readme.txt
1 month ago
uninstall.php
2 years ago
disable-admin-notices.php
168 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Disable Admin Notices Individually |
| 4 | * Plugin URI: https://clearfy.pro/disable-admin-notices |
| 5 | * Description: Disable admin notices plugin gives you the option to hide updates warnings and inline notices in the admin panel. |
| 6 | * Author: Themeisle |
| 7 | * Version: 1.4.6 |
| 8 | * Text Domain: disable-admin-notices |
| 9 | * Domain Path: /languages/ |
| 10 | * Author URI: https://themeisle.com |
| 11 | * Framework Version: FACTORY_480_VERSION |
| 12 | */ |
| 13 | |
| 14 | /** |
| 15 | * Developers who contributions in the development plugin: |
| 16 | * |
| 17 | * Alexander Kovalev |
| 18 | * --------------------------------------------------------------------------------- |
| 19 | * Full plugin development. |
| 20 | * |
| 21 | * Email: alex.kovalevv@gmail.com |
| 22 | * Personal card: https://alexkovalevv.github.io |
| 23 | * Personal repo: https://github.com/alexkovalevv |
| 24 | * --------------------------------------------------------------------------------- |
| 25 | * |
| 26 | * Artem Prihodko |
| 27 | * --------------------------------------------------------------------------------- |
| 28 | * Updates and fixes |
| 29 | * |
| 30 | * Email: webtemyk@yandex.ru |
| 31 | * GitHub: https://github.com/temyk |
| 32 | * --------------------------------------------------------------------------------- |
| 33 | */ |
| 34 | |
| 35 | // Exit if accessed directly |
| 36 | if ( ! defined( 'ABSPATH' ) ) { |
| 37 | exit; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * ----------------------------------------------------------------------------- |
| 42 | * CHECK REQUIREMENTS |
| 43 | * Check compatibility with php and wp version of the user's site. As well as checking |
| 44 | * compatibility with other plugins from Webcraftic. |
| 45 | * ----------------------------------------------------------------------------- |
| 46 | */ |
| 47 | |
| 48 | require_once( dirname( __FILE__ ) . '/libs/factory/core/includes/class-factory-requirements.php' ); |
| 49 | |
| 50 | // @formatter:off |
| 51 | $wdan_plugin_info = [ |
| 52 | 'prefix' => 'wbcr_dan_', |
| 53 | 'plugin_name' => 'wbcr_dan', |
| 54 | 'plugin_title' => 'Disable admin notices', |
| 55 | |
| 56 | // PLUGIN SUPPORT |
| 57 | 'support_details' => [ |
| 58 | 'url' => 'https://clearfy.pro/', |
| 59 | 'pages_map' => [ |
| 60 | 'support' => 'support', // {site}/support |
| 61 | 'docs' => 'docs', // {site}/docs, |
| 62 | 'pricing' => 'disable-admin-notices' |
| 63 | ] |
| 64 | ], |
| 65 | |
| 66 | // PLUGIN SUBSCRIBE FORM |
| 67 | 'subscribe_widget' => true, |
| 68 | 'subscribe_settings' => [ 'group_id' => '105407140' ], |
| 69 | |
| 70 | // FRAMEWORK MODULES |
| 71 | 'load_factory_modules' => [ |
| 72 | [ 'libs/factory/bootstrap', 'factory_bootstrap_482', 'admin' ], |
| 73 | [ 'libs/factory/forms', 'factory_forms_480', 'admin' ], |
| 74 | [ 'libs/factory/pages', 'factory_pages_480', 'admin' ], |
| 75 | [ 'libs/factory/templates', 'factory_templates_134', 'all' ], |
| 76 | //array('libs/factory/logger', 'factory_logger_149', 'all') |
| 77 | ] |
| 78 | ]; |
| 79 | |
| 80 | $wdan_compatibility = new Wbcr_Factory480_Requirements( __FILE__, array_merge( $wdan_plugin_info, [ |
| 81 | 'plugin_already_activate' => defined( 'WDN_PLUGIN_ACTIVE' ), |
| 82 | 'required_php_version' => '7.0', |
| 83 | 'required_wp_version' => '4.8.0', |
| 84 | 'required_clearfy_check_component' => false |
| 85 | ] ) ); |
| 86 | |
| 87 | |
| 88 | |
| 89 | /** |
| 90 | * If the plugin is compatible, then it will continue its work, otherwise it will be stopped, |
| 91 | * and the user will throw a warning. |
| 92 | */ |
| 93 | if ( ! $wdan_compatibility->check() ) { |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * ----------------------------------------------------------------------------- |
| 99 | * CONSTANTS |
| 100 | * Install frequently used constants and constants for debugging, which will be |
| 101 | * removed after compiling the plugin. |
| 102 | * ----------------------------------------------------------------------------- |
| 103 | */ |
| 104 | |
| 105 | // This plugin is activated |
| 106 | define( 'WDN_PLUGIN_ACTIVE', true ); |
| 107 | define( 'WDN_PLUGIN_VERSION', $wdan_compatibility->get_plugin_version() ); |
| 108 | define( 'WDN_PLUGIN_DIR', dirname( __FILE__ ) ); |
| 109 | define( 'WDN_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
| 110 | define( 'WDN_PLUGIN_URL', plugins_url( '', __FILE__ ) ); |
| 111 | define( 'WDN_PLUGIN_FILE', __FILE__ ); |
| 112 | define( 'WDN_PRODUCT_SLUG', basename( dirname( __FILE__ ) ) ); |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * ----------------------------------------------------------------------------- |
| 117 | * PLUGIN INIT |
| 118 | * ----------------------------------------------------------------------------- |
| 119 | */ |
| 120 | |
| 121 | require_once( WDN_PLUGIN_DIR . '/libs/factory/core/boot.php' ); |
| 122 | require_once( WDN_PLUGIN_DIR . '/includes/functions.php' ); |
| 123 | require_once( WDN_PLUGIN_DIR . '/includes/class-plugin.php' ); |
| 124 | |
| 125 | /** |
| 126 | * Deactivate PRO plugin. |
| 127 | * |
| 128 | * @param WDN_Plugin $disable_admin_notice_obj |
| 129 | */ |
| 130 | function deactivate_pro_plugin( $disable_admin_notice_obj ) { |
| 131 | $pro_slug = 'disable-admin-notices-premium-premium/disable-admin-notices-premium.php'; |
| 132 | |
| 133 | // If plugin isn't active, we stop immediately. |
| 134 | if ( ! is_plugin_active( $pro_slug ) ) { |
| 135 | return; |
| 136 | } |
| 137 | |
| 138 | // Delete premium option |
| 139 | $disable_admin_notice_obj->deletePopulateOption( 'premium_package' ); |
| 140 | |
| 141 | // Remove pro plugin action. |
| 142 | remove_action( 'plugins_loaded', 'wdan_premium_load', 20 ); |
| 143 | |
| 144 | // As register_deactivation_hook called, deactivate the pro plugin silently. |
| 145 | deactivate_plugins( $pro_slug, true ); |
| 146 | } |
| 147 | |
| 148 | try { |
| 149 | require_once WDN_PLUGIN_DIR . '/vendor/autoload.php'; |
| 150 | $disable_admin_notice = new WDN_Plugin( __FILE__, array_merge( $wdan_plugin_info, [ |
| 151 | 'plugin_version' => WDN_PLUGIN_VERSION, |
| 152 | 'plugin_text_domain' => $wdan_compatibility->get_text_domain(), |
| 153 | ] ) ); |
| 154 | |
| 155 | deactivate_pro_plugin( $disable_admin_notice ); |
| 156 | } catch ( Exception $e ) { |
| 157 | // Plugin wasn't initialized due to an error |
| 158 | define( 'WDN_PLUGIN_THROW_ERROR', true ); |
| 159 | |
| 160 | $wdan_plugin_error_func = function () use ( $e ) { |
| 161 | $error = sprintf( "The %s plugin has stopped. <b>Error:</b> %s Code: %s", 'Disable Admin Notices', $e->getMessage(), $e->getCode() ); |
| 162 | echo '<div class="notice notice-error"><p>' . $error . '</p></div>'; |
| 163 | }; |
| 164 | |
| 165 | add_action( 'admin_notices', $wdan_plugin_error_func ); |
| 166 | add_action( 'network_admin_notices', $wdan_plugin_error_func ); |
| 167 | } |
| 168 | // @formatter:on |