quadmenu
/
jetpack_vendor
/
quadlayers
/
wp-notice-plugin-promote
/
src
/
Traits
/
PluginActionsLinks.php
PluginActionsLinks.php in QuadMenu – Mega Menu 3.3.7, at jetpack_vendor/quadlayers/wp-notice-plugin-promote/src/Traits/PluginActionsLinks.php
| 1 | <?php |
| 2 | /** |
| 3 | * QuadLayers WP Notice Plugin Promote |
| 4 | * |
| 5 | * @package quadlayers/wp-notice-plugin-promote |
| 6 | * @author QuadLayers |
| 7 | * @link https://github.com/quadlayers/wp-notice-plugin-promote |
| 8 | * @copyright Copyright (c) 2023 |
| 9 | * @license GPL-3.0 |
| 10 | */ |
| 11 | |
| 12 | namespace QuadLayers\WP_Notice_Plugin_Promote\Traits; |
| 13 | |
| 14 | /** |
| 15 | * Trait PluginActionsLinks |
| 16 | * |
| 17 | * @package QuadLayers\WP_Notice_Plugin_Promote\Traits\PluginActionsLinks |
| 18 | * @since 1.0.0 |
| 19 | */ |
| 20 | trait PluginActionsLinks { |
| 21 | |
| 22 | /** |
| 23 | * Plugin slug. |
| 24 | * |
| 25 | * @var string |
| 26 | */ |
| 27 | protected $plungin_slug; |
| 28 | |
| 29 | /** |
| 30 | * Check if plugin is installed. |
| 31 | * |
| 32 | * @return bool |
| 33 | */ |
| 34 | public function is_installed() { |
| 35 | if ( ! function_exists( 'get_plugins' ) ) { |
| 36 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 37 | } |
| 38 | $plugin_path = $this->get_path(); |
| 39 | $installed_plugins = get_plugins(); |
| 40 | return isset( $installed_plugins[ $plugin_path ] ); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Check if plugin is activated. |
| 45 | * |
| 46 | * @return bool |
| 47 | */ |
| 48 | public function is_activated() { |
| 49 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 50 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 51 | } |
| 52 | $plugin_path = $this->get_path(); |
| 53 | return is_plugin_active( $plugin_path ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Get plugin install link. |
| 58 | * |
| 59 | * @return string |
| 60 | */ |
| 61 | public function get_install_link() { |
| 62 | return wp_nonce_url( self_admin_url( "update.php?action=install-plugin&plugin={$this->plugin_slug}" ), "install-plugin_{$this->plugin_slug}" ); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get plugin activate link. |
| 67 | * |
| 68 | * @return string |
| 69 | */ |
| 70 | public function get_activate_link() { |
| 71 | $plugin_path = $this->get_path(); |
| 72 | return self_admin_url( wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_path . '&paged=1', 'activate-plugin_' . $plugin_path ) ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Get plugin path. |
| 77 | * |
| 78 | * @return string |
| 79 | */ |
| 80 | private function get_path() { |
| 81 | return "{$this->plugin_slug}/{$this->plugin_slug}.php"; |
| 82 | } |
| 83 | |
| 84 | |
| 85 | } |
| 86 |