| 1 |
<?php |
| 2 |
namespace Elementor\Modules\System_Info\Reporters; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor network plugins report. |
| 10 |
* |
| 11 |
* Elementor system report handler class responsible for generating a report for |
| 12 |
* network plugins. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
*/ |
| 16 |
class Network_Plugins extends Base_Plugin { |
| 17 |
|
| 18 |
/** |
| 19 |
* Network plugins. |
| 20 |
* |
| 21 |
* Holds the sites network plugins list. |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
* @access private |
| 25 |
* |
| 26 |
* @var array |
| 27 |
*/ |
| 28 |
private $plugins; |
| 29 |
|
| 30 |
/** |
| 31 |
* Get network plugins reporter title. |
| 32 |
* |
| 33 |
* Retrieve network plugins reporter title. |
| 34 |
* |
| 35 |
* @since 1.0.0 |
| 36 |
* @access public |
| 37 |
* |
| 38 |
* @return string Reporter title. |
| 39 |
*/ |
| 40 |
public function get_title() { |
| 41 |
return 'Network Plugins'; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Get active network plugins. |
| 46 |
* |
| 47 |
* Retrieve the active network plugins from the list of active site-wide plugins. |
| 48 |
* |
| 49 |
* @since 2.0.0 |
| 50 |
* @access private |
| 51 |
* |
| 52 |
* @return array Active network plugins. |
| 53 |
*/ |
| 54 |
private function get_network_plugins() { |
| 55 |
if ( ! $this->plugins ) { |
| 56 |
$active_plugins = get_site_option( 'active_sitewide_plugins' ); |
| 57 |
$this->plugins = array_intersect_key( get_plugins(), $active_plugins ); |
| 58 |
} |
| 59 |
|
| 60 |
return $this->plugins; |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Is enabled. |
| 65 |
* |
| 66 |
* Whether there are active network plugins or not. |
| 67 |
* |
| 68 |
* @since 1.0.0 |
| 69 |
* @access public |
| 70 |
* |
| 71 |
* @return bool True if the site has active network plugins, False otherwise. |
| 72 |
*/ |
| 73 |
public function is_enabled() { |
| 74 |
if ( ! is_multisite() ) { |
| 75 |
return false; |
| 76 |
}; |
| 77 |
|
| 78 |
return (bool) $this->get_network_plugins(); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Get network plugins report fields. |
| 83 |
* |
| 84 |
* Retrieve the required fields for the network plugins report. |
| 85 |
* |
| 86 |
* @since 1.0.0 |
| 87 |
* @access public |
| 88 |
* |
| 89 |
* @return array Required report fields with field ID and field label. |
| 90 |
*/ |
| 91 |
public function get_fields() { |
| 92 |
return [ |
| 93 |
'network_active_plugins' => 'Network Plugins', |
| 94 |
]; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Get active network plugins. |
| 99 |
* |
| 100 |
* Retrieve the sites active network plugins. |
| 101 |
* |
| 102 |
* @since 1.0.0 |
| 103 |
* @access public |
| 104 |
* |
| 105 |
* @return array { |
| 106 |
* Report data. |
| 107 |
* |
| 108 |
* @type string $value The active network plugins list. |
| 109 |
* } |
| 110 |
*/ |
| 111 |
public function get_network_active_plugins() { |
| 112 |
return [ |
| 113 |
'value' => $this->get_network_plugins(), |
| 114 |
]; |
| 115 |
} |
| 116 |
} |
| 117 |
|