# defender-security/3.1.0/src/traits/plugin.php

Defender Security – Malware Scanner, Login Security &amp; Firewall, version 3.1.0. 36 lines.

- Page: https://pluginprobe.com/plugins/defender-security/3.1.0/code/src/traits/plugin.php
- Raw: https://pluginprobe.com/plugins/defender-security/3.1.0/raw/src/traits/plugin.php
- Modified: 2022-07-11T08:21:36+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/defender-security/3.1.0/code/src/traits/plugin.php#L10-L20`.

```php
<?php

namespace WP_Defender\Traits;

trait Plugin {

	/**
	 * Get all installed plugins.
	 *
	 * @return array
	 */
	public function get_plugins() {
		if ( ! function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}

		// WordPress caches this internally.
		return get_plugins();
	}

	/**
	 * Get all slugs.
	 *
	 * @return array
	 */
	public function get_plugin_slugs() {
		$slugs = array();
		foreach ( $this->get_plugins() as $slug => $plugin ) {
			$base_slug = explode( '/', $slug );
			$slugs[]   = array_shift( $base_slug );
		}

		return $slugs;
	}
}

```
