Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 39 additions & 19 deletions class-tgm-plugin-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,11 +516,10 @@ protected function do_plugin_install() {
$url = wp_nonce_url(
add_query_arg(
array(
'page' => urlencode( $this->menu ),
'plugin' => urlencode( $slug ),
'tgmpa-install' => 'install-plugin',
),
self_admin_url( $this->parent_slug )
$this->get_tgmpa_url()
),
'tgmpa-install'
);
Expand Down Expand Up @@ -566,7 +565,13 @@ protected function do_plugin_install() {

// Prep variables for Plugin_Installer_Skin class.
$title = sprintf( $this->strings['installing'], $plugin['name'] );
$url = add_query_arg( array( 'action' => 'install-plugin', 'plugin' => urlencode( $slug ) ), 'update.php' );
$url = add_query_arg(
array(
'action' => 'install-plugin',
'plugin' => urlencode( $slug )
),
'update.php'
);
$url = esc_url_raw( $url );

$nonce = 'install-plugin_' . $slug;
Expand All @@ -593,7 +598,7 @@ protected function do_plugin_install() {

if ( is_wp_error( $activate ) ) {
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>',
'<p><a href="', esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
'<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
return true; // End it here if there is an error with automatic activation

} else {
Expand All @@ -605,7 +610,7 @@ protected function do_plugin_install() {
$complete = true;
foreach ( $this->plugins as $plugin ) {
if ( ! is_plugin_active( $plugin['file_path'] ) ) {
echo '<p><a href="', esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
$complete = false;
break;
}
Expand All @@ -630,7 +635,7 @@ protected function do_plugin_install() {

if ( is_wp_error( $activate ) ) {
echo '<div id="message" class="error"><p>', wp_kses_post( $activate->get_error_message() ), '</p></div>';
echo '<p><a href="', esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
echo '<p><a href="', esc_url( $this->get_tgmpa_url() ), '" target="_parent">', esc_html( $this->strings['return'] ), '</a></p>';
return true; // End it here if there is an error with activation.

} else {
Expand Down Expand Up @@ -865,8 +870,8 @@ public function notices() {
unset( $type, $plugin_group, $linked_plugins, $count, $last_plugin, $imploded );

// Setup variables to determine if action links are needed.
$show_install_link = $install_link ? '<a href="' . esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ) . '">' . translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ) . '</a>' : '';
$show_activate_link = $activate_link ? '<a href="' . esc_url( add_query_arg( 'page', urlencode( $this->menu ), self_admin_url( $this->parent_slug ) ) ) . '">' . translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ) . '</a>' : '';
$show_install_link = $install_link ? '<a href="' . esc_url( $this->get_tgmpa_url() ) . '">' . translate_nooped_plural( $this->strings['install_link'], $install_link_count, 'tgmpa' ) . '</a>' : '';
$show_activate_link = $activate_link ? '<a href="' . esc_url( $this->get_tgmpa_url() ) . '">' . translate_nooped_plural( $this->strings['activate_link'], $activate_link_count, 'tgmpa' ) . '</a>' : '';

// Define all of the action links.
$action_links = apply_filters(
Expand Down Expand Up @@ -1140,6 +1145,28 @@ protected function is_tgmpa_page() {

}

/**
* Retrieve the url to the TGMPA Install page.
*
* @since 2.5.0
*
* @return string Properly encoded url (not escaped).
*/
public function get_tgmpa_url() {
static $url;

if ( ! isset( $url ) ) {
$url = add_query_arg(
array(
'page' => urlencode( $this->menu ),
),
self_admin_url( $this->parent_slug )
);
}

return $url;
}

/**
* Delete dismissable nag option when theme is switched.
*
Expand Down Expand Up @@ -1478,11 +1505,10 @@ public function column_plugin( $item ) {
$install_nonce_url = wp_nonce_url(
add_query_arg(
array(
'page' => urlencode( $this->tgmpa->menu ),
'plugin' => urlencode( $item['slug'] ),
'tgmpa-install' => 'install-plugin',
),
self_admin_url( $this->tgmpa->parent_slug )
$this->tgmpa->get_tgmpa_url()
),
'tgmpa-install'
);
Expand All @@ -1499,12 +1525,11 @@ public function column_plugin( $item ) {
elseif ( is_plugin_inactive( $item['file_path'] ) ) {
$activate_url = add_query_arg(
array(
'page' => urlencode( $this->tgmpa->menu ),
'plugin' => urlencode( $item['slug'] ),
'tgmpa-activate' => 'activate-plugin',
'tgmpa-activate-nonce' => urlencode( wp_create_nonce( 'tgmpa-activate' ) ),
),
self_admin_url( $this->tgmpa->parent_slug )
$this->tgmpa->get_tgmpa_url()
);

$actions = array(
Expand Down Expand Up @@ -1651,12 +1676,7 @@ public function process_bulk_actions() {

// Pass all necessary information if WP_Filesystem is needed.
$url = wp_nonce_url(
add_query_arg(
array(
'page' => urlencode( $this->tgmpa->menu ),
),
self_admin_url( $this->tgmpa->parent_slug )
),
$this->tgmpa->get_tgmpa_url(),
'bulk-' . $this->_args['plural']
);

Expand Down Expand Up @@ -1719,7 +1739,7 @@ public function process_bulk_actions() {
unset( $slug, $name, $source );

// Finally, all the data is prepared to be sent to the installer.
$url = esc_url_raw( add_query_arg( array( 'page' => urlencode( $this->tgmpa->menu ) ), self_admin_url( $this->tgmpa->parent_slug ) ) );
$url = esc_url_raw( $this->tgmpa->get_tgmpa_url() );
$nonce = 'bulk-plugins';

// Create a new instance of TGM_Bulk_Installer.
Expand Down