2016-05-10 13:11:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2016-05-10 13:31:28 +02:00
|
|
|
* Upgrader API: Plugin_Installer_Skin class
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Upgrader
|
2016-05-10 13:31:28 +02:00
|
|
|
* @since 4.6.0
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plugin Installer Skin for WordPress Plugin Installer.
|
|
|
|
*
|
|
|
|
* @since 2.8.0
|
2016-05-13 22:59:27 +02:00
|
|
|
* @since 4.6.0 Moved to its own file from wp-admin/includes/class-wp-upgrader-skins.php.
|
2016-07-09 15:45:33 +02:00
|
|
|
*
|
|
|
|
* @see WP_Upgrader_Skin
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
|
|
|
public $api;
|
|
|
|
public $type;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $args
|
|
|
|
*/
|
2017-12-01 00:11:00 +01:00
|
|
|
public function __construct( $args = array() ) {
|
|
|
|
$defaults = array(
|
|
|
|
'type' => 'web',
|
|
|
|
'url' => '',
|
|
|
|
'plugin' => '',
|
|
|
|
'nonce' => '',
|
|
|
|
'title' => '',
|
|
|
|
);
|
|
|
|
$args = wp_parse_args( $args, $defaults );
|
2016-05-10 13:11:30 +02:00
|
|
|
|
|
|
|
$this->type = $args['type'];
|
2017-12-01 00:11:00 +01:00
|
|
|
$this->api = isset( $args['api'] ) ? $args['api'] : array();
|
2016-05-10 13:11:30 +02:00
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
parent::__construct( $args );
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
public function before() {
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! empty( $this->api ) ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$this->upgrader->strings['process_success'] = sprintf(
|
2019-09-03 02:41:05 +02:00
|
|
|
/* translators: 1: Plugin name, 2: Plugin version. */
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
__( 'Successfully installed the plugin <strong>%1$s %2$s</strong>.' ),
|
|
|
|
$this->api->name,
|
|
|
|
$this->api->version
|
|
|
|
);
|
2017-12-01 00:11:00 +01:00
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*/
|
|
|
|
public function after() {
|
|
|
|
$plugin_file = $this->upgrader->plugin_info();
|
|
|
|
|
|
|
|
$install_actions = array();
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
$from = isset( $_GET['from'] ) ? wp_unslash( $_GET['from'] ) : 'plugins';
|
2016-05-10 13:11:30 +02:00
|
|
|
|
2017-09-24 16:22:54 +02:00
|
|
|
if ( 'import' == $from ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['activate_plugin'] = sprintf(
|
|
|
|
'<a class="button button-primary" href="%s" target="_parent">%s</a>',
|
|
|
|
wp_nonce_url( 'plugins.php?action=activate&from=import&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
|
|
|
|
__( 'Activate Plugin & Run Importer' )
|
|
|
|
);
|
2017-12-01 00:11:00 +01:00
|
|
|
} elseif ( 'press-this' == $from ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['activate_plugin'] = sprintf(
|
|
|
|
'<a class="button button-primary" href="%s" target="_parent">%s</a>',
|
|
|
|
wp_nonce_url( 'plugins.php?action=activate&from=press-this&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
|
|
|
|
__( 'Activate Plugin & Return to Press This' )
|
|
|
|
);
|
2017-09-24 16:22:54 +02:00
|
|
|
} else {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['activate_plugin'] = sprintf(
|
|
|
|
'<a class="button button-primary" href="%s" target="_parent">%s</a>',
|
|
|
|
wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
|
|
|
|
__( 'Activate Plugin' )
|
|
|
|
);
|
2017-09-24 16:22:54 +02:00
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
|
|
|
|
if ( is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['network_activate'] = sprintf(
|
|
|
|
'<a class="button button-primary" href="%s" target="_parent">%s</a>',
|
|
|
|
wp_nonce_url( 'plugins.php?action=activate&networkwide=1&plugin=' . urlencode( $plugin_file ), 'activate-plugin_' . $plugin_file ),
|
|
|
|
__( 'Network Activate' )
|
|
|
|
);
|
2016-05-10 13:11:30 +02:00
|
|
|
unset( $install_actions['activate_plugin'] );
|
|
|
|
}
|
|
|
|
|
2020-02-09 17:55:09 +01:00
|
|
|
if ( 'import' === $from ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['importers_page'] = sprintf(
|
|
|
|
'<a href="%s" target="_parent">%s</a>',
|
|
|
|
admin_url( 'import.php' ),
|
|
|
|
__( 'Return to Importers' )
|
|
|
|
);
|
2020-02-09 17:55:09 +01:00
|
|
|
} elseif ( 'web' === $this->type ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['plugins_page'] = sprintf(
|
|
|
|
'<a href="%s" target="_parent">%s</a>',
|
|
|
|
self_admin_url( 'plugin-install.php' ),
|
|
|
|
__( 'Return to Plugin Installer' )
|
|
|
|
);
|
2020-02-09 17:55:09 +01:00
|
|
|
} elseif ( 'upload' === $this->type && 'plugins' === $from ) {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['plugins_page'] = sprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
self_admin_url( 'plugin-install.php' ),
|
|
|
|
__( 'Return to Plugin Installer' )
|
|
|
|
);
|
2016-05-10 13:11:30 +02:00
|
|
|
} else {
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 19:13:59 +02:00
|
|
|
$install_actions['plugins_page'] = sprintf(
|
|
|
|
'<a href="%s" target="_parent">%s</a>',
|
|
|
|
self_admin_url( 'plugins.php' ),
|
|
|
|
__( 'Return to Plugins page' )
|
|
|
|
);
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
|
2017-12-01 00:11:00 +01:00
|
|
|
if ( ! $this->result || is_wp_error( $this->result ) ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
unset( $install_actions['activate_plugin'], $install_actions['network_activate'] );
|
2017-08-22 16:02:44 +02:00
|
|
|
} elseif ( ! current_user_can( 'activate_plugin', $plugin_file ) ) {
|
2016-05-10 13:11:30 +02:00
|
|
|
unset( $install_actions['activate_plugin'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-22 20:01:30 +02:00
|
|
|
* Filters the list of action links available following a single plugin installation.
|
2016-05-10 13:11:30 +02:00
|
|
|
*
|
|
|
|
* @since 2.7.0
|
|
|
|
*
|
2018-03-22 21:27:32 +01:00
|
|
|
* @param string[] $install_actions Array of plugin action links.
|
|
|
|
* @param object $api Object containing WordPress.org API plugin data. Empty
|
|
|
|
* for non-API installs, such as when a plugin is installed
|
|
|
|
* via upload.
|
|
|
|
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
|
2016-05-10 13:11:30 +02:00
|
|
|
*/
|
|
|
|
$install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
|
|
|
|
|
2016-09-17 18:23:27 +02:00
|
|
|
if ( ! empty( $install_actions ) ) {
|
|
|
|
$this->feedback( implode( ' ', (array) $install_actions ) );
|
|
|
|
}
|
2016-05-10 13:11:30 +02:00
|
|
|
}
|
|
|
|
}
|