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