Skip to content

Commit

Permalink
Merge pull request #3463 from WordImpress/issue/3438
Browse files Browse the repository at this point in the history
fix(admin-plugins): fix on activation/deactivation of add-on plugin menu change #3438
  • Loading branch information
ravinderk committed Jul 13, 2018
2 parents c90795a + d2c3cb5 commit c7e1c81
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions includes/admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function give_plugin_action_links( $actions ) {
*
* @since 1.4
*
* @param array $plugin_meta An array of the plugin's metadata.
* @param array $plugin_meta An array of the plugin's metadata.
* @param string $plugin_file Path to the plugin file, relative to the plugins directory.
*
* @return array
Expand Down Expand Up @@ -94,7 +94,7 @@ function give_plugin_row_meta( $plugin_meta, $plugin_file ) {
*
* @since 1.8.17
*
* @global array $submenu
* @global array $submenu
* @global string $plugin_page
*
* @return string $title Page title
Expand Down Expand Up @@ -199,6 +199,27 @@ function give_filter_addons_do_filter_addons( $plugin_menu ) {
add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' );
add_filter( 'show_network_active_plugins', 'give_filter_addons_do_filter_addons' );

/**
* Keep activating the same add-on when admin activate or deactivate from Give Menu
*
* @since 2.2.0
*
* @param $action
* @param $result
*/
function give_prepare_filter_addons_referer( $action, $result ) {
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$screen = get_current_screen();
if ( is_object( $screen ) && $screen->base === 'plugins' && ! empty( $_REQUEST['plugin_status'] ) && $_REQUEST['plugin_status'] === 'give' ) {
global $status;
$status = 'give';
}
}

add_action( 'check_admin_referer', 'give_prepare_filter_addons_referer', 10, 2 );

/**
* Make the Give Menu as an default menu and update the Menu Name
*
Expand Down Expand Up @@ -258,7 +279,7 @@ function give_prepare_filter_addons( $plugins ) {
/**
* Display the upgrade notice message.
*
* @param array $data Array of plugin metadata.
* @param array $data Array of plugin metadata.
* @param array $response An array of metadata about the available plugin update.
*
* @since 2.1
Expand Down Expand Up @@ -322,7 +343,7 @@ function give_get_plugin_upgrade_notice( $new_version ) {
*
* @since 2.1
*
* @param string $content Content of the readme.txt file.
* @param string $content Content of the readme.txt file.
* @param string $new_version The version with current version is compared.
*
* @return string
Expand Down

0 comments on commit c7e1c81

Please sign in to comment.