| 1 |
<?php |
| 2 |
|
| 3 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 4 |
namespace Yoast\WP\SEO\Plans\Application; |
| 5 |
|
| 6 |
use WPSEO_Admin_Utils; |
| 7 |
|
| 8 |
/** |
| 9 |
* The Yoast SEO Duplicate Post plugin Manager. |
| 10 |
*/ |
| 11 |
class Duplicate_Post_Manager { |
| 12 |
|
| 13 |
/** |
| 14 |
* The Duplicate post main file. |
| 15 |
* |
| 16 |
* @var string |
| 17 |
*/ |
| 18 |
public const PLUGIN_FILE = 'duplicate-post/duplicate-post.php'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Checks if the plugin is installed and activated in WordPress. |
| 22 |
* |
| 23 |
* @return bool True when installed and activated. |
| 24 |
*/ |
| 25 |
protected function is_activated() { |
| 26 |
return \is_plugin_active( self::PLUGIN_FILE ); |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Checks if the plugin is installed in WordPress. |
| 31 |
* |
| 32 |
* @return bool True when installed. |
| 33 |
*/ |
| 34 |
protected function is_installed() { |
| 35 |
return \file_exists( \WP_PLUGIN_DIR . '/' . self::PLUGIN_FILE ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Gets the duplicate post plans page params |
| 40 |
* |
| 41 |
* @return array<string|bool> The list of params. |
| 42 |
*/ |
| 43 |
public function get_params() { |
| 44 |
return [ |
| 45 |
'isInstalled' => $this->is_installed(), |
| 46 |
'isActivated' => $this->is_activated(), |
| 47 |
'installationUrl' => \html_entity_decode( WPSEO_Admin_Utils::get_install_url( self::PLUGIN_FILE ) ), |
| 48 |
'activationUrl' => \html_entity_decode( WPSEO_Admin_Utils::get_activation_url( self::PLUGIN_FILE ) ), |
| 49 |
]; |
| 50 |
} |
| 51 |
} |
| 52 |
|