| 1 |
<?php |
| 2 |
/** |
| 3 |
* Main Watchful class. |
| 4 |
* |
| 5 |
* @version 2016-12-20 11:41 UTC+01 |
| 6 |
* @package Watchful WP Client |
| 7 |
* @author Watchful |
| 8 |
* @authorUrl https://watchful.net |
| 9 |
* @copyright Copyright (c) 2020 watchful.net |
| 10 |
* @license GNU/GPL |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace Watchful; |
| 14 |
|
| 15 |
if (!defined('ABSPATH')) { |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Main Watchful class. |
| 21 |
*/ |
| 22 |
class Main |
| 23 |
{ |
| 24 |
|
| 25 |
/** |
| 26 |
* Plugin version, used for cache-busting of style and script file references. |
| 27 |
* |
| 28 |
* @since 0.1 |
| 29 |
* |
| 30 |
* @var string |
| 31 |
*/ |
| 32 |
public $version = '0.1'; |
| 33 |
|
| 34 |
/** |
| 35 |
* Plugin file. |
| 36 |
* |
| 37 |
* @since 0.1 |
| 38 |
* |
| 39 |
* @var string |
| 40 |
*/ |
| 41 |
public $file = __FILE__; |
| 42 |
|
| 43 |
/** |
| 44 |
* Constructor |
| 45 |
*/ |
| 46 |
public function __construct() |
| 47 |
{ |
| 48 |
} // end constructor |
| 49 |
|
| 50 |
/** |
| 51 |
* Initializes the plugin by setting localization, filters, and administration functions. |
| 52 |
*/ |
| 53 |
public function init() |
| 54 |
{ |
| 55 |
// Add Message after activation. |
| 56 |
add_action('admin_notices', array($this, 'watchful_admin_notice')); |
| 57 |
add_action('network_admin_notices', array($this, 'watchful_admin_notice')); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Display admin notice. |
| 62 |
* |
| 63 |
* @since 0.1 |
| 64 |
*/ |
| 65 |
public function watchful_admin_notice() |
| 66 |
{ |
| 67 |
// Make sure the plugin is activated. |
| 68 |
if (is_plugin_active('watchful/watchful.php')) { |
| 69 |
global $pagenow; |
| 70 |
|
| 71 |
// Only need to display this on the plugin view page. |
| 72 |
if ('plugins.php' !== $pagenow || !current_user_can('install_plugins') || !get_option('watchfulMessage')) { |
| 73 |
return; |
| 74 |
} |
| 75 |
?> |
| 76 |
<div id="message" class="updated notice is-dismissible"> |
| 77 |
<?php |
| 78 |
$my_settings_page = new Settings(); |
| 79 |
$my_settings_page->print_watchful_form(); |
| 80 |
?> |
| 81 |
<br/> |
| 82 |
</div> |
| 83 |
<?php |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
} // end Watchful_Main Class |
| 88 |
|