disable-admin-notices.php
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin Name: Webcraftic Disable Admin Notices Individually |
| 4 | * Plugin URI: https://webcraftic.com |
| 5 | * Description: Disable admin notices plugin gives you the option to hide updates warnings and inline notices in the admin panel. |
| 6 | * Author: Webcraftic <wordpress.webraftic@gmail.com> |
| 7 | * Version: 1.1.3 |
| 8 | * Text Domain: disable-admin-notices |
| 9 | * Domain Path: /languages/ |
| 10 | * Author URI: https://webcraftic.com |
| 11 | * Framework Version: FACTORY_429_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 | |
| 27 | // Exit if accessed directly |
| 28 | if( !defined('ABSPATH') ) { |
| 29 | exit; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * ----------------------------------------------------------------------------- |
| 34 | * CHECK REQUIREMENTS |
| 35 | * Check compatibility with php and wp version of the user's site. As well as checking |
| 36 | * compatibility with other plugins from Webcraftic. |
| 37 | * ----------------------------------------------------------------------------- |
| 38 | */ |
| 39 | |
| 40 | require_once(dirname(__FILE__) . '/libs/factory/core/includes/class-factory-requirements.php'); |
| 41 | |
| 42 | // @formatter:off |
| 43 | $wdan_plugin_info = array( |
| 44 | 'prefix' => 'wbcr_dan_', |
| 45 | 'plugin_name' => 'wbcr_dan', |
| 46 | 'plugin_title' => __('Webcraftic disable admin notices', 'disable-admin-notices'), |
| 47 | |
| 48 | // PLUGIN SUPPORT |
| 49 | 'support_details' => array( |
| 50 | 'url' => 'https://webcraftic.com', |
| 51 | 'pages_map' => array( |
| 52 | 'support' => 'support', // {site}/support |
| 53 | 'docs' => 'docs' // {site}/docs |
| 54 | ) |
| 55 | ), |
| 56 | |
| 57 | // PLUGIN ADVERTS |
| 58 | 'render_adverts' => true, |
| 59 | 'adverts_settings' => array( |
| 60 | 'dashboard_widget' => false, // show dashboard widget (default: false) |
| 61 | 'right_sidebar' => true, // show adverts sidebar (default: false) |
| 62 | 'notice' => false, // show notice message (default: false) |
| 63 | ), |
| 64 | |
| 65 | // FRAMEWORK MODULES |
| 66 | 'load_factory_modules' => array( |
| 67 | array('libs/factory/bootstrap', 'factory_bootstrap_430', 'admin'), |
| 68 | array('libs/factory/forms', 'factory_forms_427', 'admin'), |
| 69 | array('libs/factory/pages', 'factory_pages_429', 'admin'), |
| 70 | array('libs/factory/clearfy', 'factory_clearfy_221', 'all'), |
| 71 | array('libs/factory/adverts', 'factory_adverts_109', 'admin') |
| 72 | ) |
| 73 | ); |
| 74 | |
| 75 | $wdan_compatibility = new Wbcr_Factory429_Requirements(__FILE__, array_merge($wdan_plugin_info, array( |
| 76 | 'plugin_already_activate' => defined('WDN_PLUGIN_ACTIVE'), |
| 77 | 'required_php_version' => '5.4', |
| 78 | 'required_wp_version' => '4.2.0', |
| 79 | 'required_clearfy_check_component' => false |
| 80 | ))); |
| 81 | |
| 82 | /** |
| 83 | * If the plugin is compatible, then it will continue its work, otherwise it will be stopped, |
| 84 | * and the user will throw a warning. |
| 85 | */ |
| 86 | if( !$wdan_compatibility->check() ) { |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * ----------------------------------------------------------------------------- |
| 92 | * CONSTANTS |
| 93 | * Install frequently used constants and constants for debugging, which will be |
| 94 | * removed after compiling the plugin. |
| 95 | * ----------------------------------------------------------------------------- |
| 96 | */ |
| 97 | |
| 98 | // This plugin is activated |
| 99 | define('WDN_PLUGIN_ACTIVE', true); |
| 100 | define('WDN_PLUGIN_VERSION', $wdan_compatibility->get_plugin_version()); |
| 101 | define('WDN_PLUGIN_DIR', dirname(__FILE__)); |
| 102 | define('WDN_PLUGIN_BASE', plugin_basename(__FILE__)); |
| 103 | define('WDN_PLUGIN_URL', plugins_url(null, __FILE__)); |
| 104 | |
| 105 | |
| 106 | |
| 107 | /** |
| 108 | * ----------------------------------------------------------------------------- |
| 109 | * PLUGIN INIT |
| 110 | * ----------------------------------------------------------------------------- |
| 111 | */ |
| 112 | |
| 113 | require_once(WDN_PLUGIN_DIR . '/libs/factory/core/boot.php'); |
| 114 | require_once(WDN_PLUGIN_DIR . '/includes/class-plugin.php'); |
| 115 | |
| 116 | try { |
| 117 | new WDN_Plugin(__FILE__, array_merge($wdan_plugin_info, array( |
| 118 | 'plugin_version' => WDN_PLUGIN_VERSION, |
| 119 | 'plugin_text_domain' => $wdan_compatibility->get_text_domain(), |
| 120 | ))); |
| 121 | } catch( Exception $e ) { |
| 122 | // Plugin wasn't initialized due to an error |
| 123 | define('WDN_PLUGIN_THROW_ERROR', true); |
| 124 | |
| 125 | $wdan_plugin_error_func = function () use ($e) { |
| 126 | $error = sprintf("The %s plugin has stopped. <b>Error:</b> %s Code: %s", 'Webcraftic Disable Admin Notices', $e->getMessage(), $e->getCode()); |
| 127 | echo '<div class="notice notice-error"><p>' . $error . '</p></div>'; |
| 128 | }; |
| 129 | |
| 130 | add_action('admin_notices', $wdan_plugin_error_func); |
| 131 | add_action('network_admin_notices', $wdan_plugin_error_func); |
| 132 | } |
| 133 | // @formatter:on |