| 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.2 |
| 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 |
// PLUGIN ADVERTS |
| 71 |
'render_adverts' => true, |
| 72 |
'adverts_settings' => [ |
| 73 |
'dashboard_widget' => false, // show dashboard widget (default: false) |
| 74 |
'right_sidebar' => true, // show adverts sidebar (default: false) |
| 75 |
'notice' => false, // show notice message (default: false) |
| 76 |
], |
| 77 |
|
| 78 |
// FRAMEWORK MODULES |
| 79 |
'load_factory_modules' => [ |
| 80 |
[ 'libs/factory/bootstrap', 'factory_bootstrap_482', 'admin' ], |
| 81 |
[ 'libs/factory/forms', 'factory_forms_480', 'admin' ], |
| 82 |
[ 'libs/factory/pages', 'factory_pages_480', 'admin' ], |
| 83 |
[ 'libs/factory/templates', 'factory_templates_134', 'all' ], |
| 84 |
[ 'libs/factory/adverts', 'factory_adverts_159', 'admin' ], |
| 85 |
//array('libs/factory/logger', 'factory_logger_149', 'all') |
| 86 |
] |
| 87 |
]; |
| 88 |
|
| 89 |
$wdan_compatibility = new Wbcr_Factory480_Requirements( __FILE__, array_merge( $wdan_plugin_info, [ |
| 90 |
'plugin_already_activate' => defined( 'WDN_PLUGIN_ACTIVE' ), |
| 91 |
'required_php_version' => '7.0', |
| 92 |
'required_wp_version' => '4.8.0', |
| 93 |
'required_clearfy_check_component' => false |
| 94 |
] ) ); |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
/** |
| 99 |
* If the plugin is compatible, then it will continue its work, otherwise it will be stopped, |
| 100 |
* and the user will throw a warning. |
| 101 |
*/ |
| 102 |
if ( ! $wdan_compatibility->check() ) { |
| 103 |
return; |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* ----------------------------------------------------------------------------- |
| 108 |
* CONSTANTS |
| 109 |
* Install frequently used constants and constants for debugging, which will be |
| 110 |
* removed after compiling the plugin. |
| 111 |
* ----------------------------------------------------------------------------- |
| 112 |
*/ |
| 113 |
|
| 114 |
// This plugin is activated |
| 115 |
define( 'WDN_PLUGIN_ACTIVE', true ); |
| 116 |
define( 'WDN_PLUGIN_VERSION', $wdan_compatibility->get_plugin_version() ); |
| 117 |
define( 'WDN_PLUGIN_DIR', dirname( __FILE__ ) ); |
| 118 |
define( 'WDN_PLUGIN_BASE', plugin_basename( __FILE__ ) ); |
| 119 |
define( 'WDN_PLUGIN_URL', plugins_url( '', __FILE__ ) ); |
| 120 |
define( 'WDN_PLUGIN_FILE', __FILE__ ); |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
/** |
| 125 |
* ----------------------------------------------------------------------------- |
| 126 |
* PLUGIN INIT |
| 127 |
* ----------------------------------------------------------------------------- |
| 128 |
*/ |
| 129 |
|
| 130 |
require_once( WDN_PLUGIN_DIR . '/libs/factory/core/boot.php' ); |
| 131 |
require_once( WDN_PLUGIN_DIR . '/includes/functions.php' ); |
| 132 |
require_once( WDN_PLUGIN_DIR . '/includes/class-plugin.php' ); |
| 133 |
|
| 134 |
/** |
| 135 |
* Deactivate PRO plugin. |
| 136 |
* |
| 137 |
* @param WDN_Plugin $disable_admin_notice_obj |
| 138 |
*/ |
| 139 |
function deactivate_pro_plugin( $disable_admin_notice_obj ) { |
| 140 |
$pro_slug = 'disable-admin-notices-premium-premium/disable-admin-notices-premium.php'; |
| 141 |
|
| 142 |
// If plugin isn't active, we stop immediately. |
| 143 |
if ( ! is_plugin_active( $pro_slug ) ) { |
| 144 |
return; |
| 145 |
} |
| 146 |
|
| 147 |
// Delete premium option |
| 148 |
$disable_admin_notice_obj->deletePopulateOption( 'premium_package' ); |
| 149 |
|
| 150 |
// Remove pro plugin action. |
| 151 |
remove_action( 'plugins_loaded', 'wdan_premium_load', 20 ); |
| 152 |
|
| 153 |
// As register_deactivation_hook called, deactivate the pro plugin silently. |
| 154 |
deactivate_plugins( $pro_slug, true ); |
| 155 |
} |
| 156 |
|
| 157 |
try { |
| 158 |
require_once WDN_PLUGIN_DIR . '/vendor/autoload.php'; |
| 159 |
$disable_admin_notice = new WDN_Plugin( __FILE__, array_merge( $wdan_plugin_info, [ |
| 160 |
'plugin_version' => WDN_PLUGIN_VERSION, |
| 161 |
'plugin_text_domain' => $wdan_compatibility->get_text_domain(), |
| 162 |
] ) ); |
| 163 |
|
| 164 |
deactivate_pro_plugin( $disable_admin_notice ); |
| 165 |
} catch ( Exception $e ) { |
| 166 |
// Plugin wasn't initialized due to an error |
| 167 |
define( 'WDN_PLUGIN_THROW_ERROR', true ); |
| 168 |
|
| 169 |
$wdan_plugin_error_func = function () use ( $e ) { |
| 170 |
$error = sprintf( "The %s plugin has stopped. <b>Error:</b> %s Code: %s", 'Disable Admin Notices', $e->getMessage(), $e->getCode() ); |
| 171 |
echo '<div class="notice notice-error"><p>' . $error . '</p></div>'; |
| 172 |
}; |
| 173 |
|
| 174 |
add_action( 'admin_notices', $wdan_plugin_error_func ); |
| 175 |
add_action( 'network_admin_notices', $wdan_plugin_error_func ); |
| 176 |
} |
| 177 |
// @formatter:on |