first commit
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Isolation;
|
||||
|
||||
interface Plugin_Status_Adapter_Interface {
|
||||
|
||||
public function is_plugin_installed( $plugin_path ): bool;
|
||||
|
||||
public function get_install_plugin_url( $plugin_path ): string;
|
||||
|
||||
public function get_activate_plugin_url( $plugin_path ): string;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Isolation;
|
||||
|
||||
class Plugin_Status_Adapter implements Plugin_Status_Adapter_Interface {
|
||||
|
||||
public Wordpress_Adapter $wordpress_adapter;
|
||||
|
||||
public function __construct( $wordpress_adapter ) {
|
||||
$this->wordpress_adapter = $wordpress_adapter;
|
||||
}
|
||||
|
||||
public function is_plugin_installed( $plugin_path ): bool {
|
||||
$installed_plugins = $this->wordpress_adapter->get_plugins();
|
||||
|
||||
return isset( $installed_plugins[ $plugin_path ] );
|
||||
}
|
||||
|
||||
public function get_install_plugin_url( $plugin_path ): string {
|
||||
$slug = dirname( $plugin_path );
|
||||
$admin_base_url = $this->wordpress_adapter->self_admin_url( 'update.php' );
|
||||
|
||||
$admin_url = add_query_arg( [
|
||||
'action' => 'install-plugin',
|
||||
'plugin' => $slug,
|
||||
], $admin_base_url );
|
||||
|
||||
return $this->wordpress_adapter->wp_nonce_url( $admin_url, 'install-plugin_' . $slug );
|
||||
}
|
||||
|
||||
public function get_activate_plugin_url( $plugin_path ): string {
|
||||
$admin_base_url = $this->wordpress_adapter->self_admin_url( 'plugins.php' );
|
||||
|
||||
$admin_url = add_query_arg( [
|
||||
'action' => 'activate',
|
||||
'plugin' => $plugin_path,
|
||||
'plugin_status' => 'all',
|
||||
'paged' => 1,
|
||||
's' => '',
|
||||
], $admin_base_url );
|
||||
|
||||
return $this->wordpress_adapter->wp_nonce_url( $admin_url, 'activate-plugin_' . $plugin_path );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Isolation;
|
||||
|
||||
interface Wordpress_Adapter_Interface {
|
||||
|
||||
public function get_plugins();
|
||||
|
||||
public function is_plugin_active( $plugin_path );
|
||||
|
||||
public function wp_nonce_url( $url, $action );
|
||||
|
||||
public function self_admin_url( $path );
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace Elementor\Core\Isolation;
|
||||
|
||||
class Wordpress_Adapter implements Wordpress_Adapter_Interface {
|
||||
|
||||
public function get_plugins(): array {
|
||||
return get_plugins();
|
||||
}
|
||||
|
||||
public function is_plugin_active( $plugin_path ): bool {
|
||||
return is_plugin_active( $plugin_path );
|
||||
}
|
||||
|
||||
public function wp_nonce_url( $url, $action ): string {
|
||||
return wp_nonce_url( $url, $action );
|
||||
}
|
||||
|
||||
public function self_admin_url( $path ): string {
|
||||
return self_admin_url( $path );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user