Yoast\WP\SEO\Actions\Addon_Installation
Addon_Install_Action::install_addon
Installs the plugin based on the given slug.
Метод класса: Addon_Install_Action{}
Хуков нет.
Возвращает
true|false. True when install is successful.
Использование
$Addon_Install_Action = new Addon_Install_Action(); $Addon_Install_Action->install_addon( $plugin_slug, $download_url );
- $plugin_slug(строка) (обязательный)
- The plugin slug to install.
- $download_url(строка) (обязательный)
- The plugin download URL.
Код Addon_Install_Action::install_addon() Addon Install Action::install addon Yoast 27.4
public function install_addon( $plugin_slug, $download_url ) {
if ( ! \current_user_can( 'install_plugins' ) ) {
throw new User_Cannot_Install_Plugins_Exception( $plugin_slug );
}
if ( $this->is_installed( $plugin_slug ) ) {
throw new Addon_Already_Installed_Exception( $plugin_slug );
}
$this->load_wordpress_classes();
$install_result = $this->install( $download_url );
if ( \is_wp_error( $install_result ) ) {
throw new Addon_Installation_Error_Exception( $install_result->get_error_message() );
}
return $install_result;
}