How Do I Make The Recently Active Plugins Not Expire

Hello,

QUESTION
In the admin panel when a plugin is deactivated it will remain in the "Recently Active" status column for 7 days.

I would like to know what to edit to change the time frame from 7 days to forever. I.E. Deactivated plugins will remain identified forever.

This minimal hack would allow me to deactivate all "admin~maintenance" plugins that only need to be used by the admin and next time they are needed, then clicking on the "Recently Active" status and selecting all, they could be turned back on in a single action.

I would also like to have the ability to deactivate the group of them with a "single action" rather than having to individually select each one, but I realize adding that feature will require some development.

SO THE CONCEPT IS
Develop a plugin that allows user to create multiple identifying statuses that can be assigned by users to each plugin with new statuses displaying above the plugin page as column headers like like "Recently Active" does.

Clicking a plugin status column will toggle all plugins with that status OFF~DEACTIVATE and clicking the status column again will toggle all the plugins with that status ON~ACTIVATE.

A drop down select of available plugin statuses might appear in each plugin description row so the user can go through their plugins and assign one or more statuses to each plugin. The same plugin might be assigned multiple statuses.

For example a Network Super Admin might have several plugins that only he/she uses and would like to Activate when they log into the dashboard and turn off when they log out of the dashboard so they could assign those plugins a status X and then turning all of them ON/OFF would be a single click operation. TIME SAVED!

A site Admin might have several plugins that he/she uses and one of their plugins might also be the same as the Network Super Admin uses and the site admin could assign status Y to all plugins in their group.

Any plugin might have several statuses assigned to it with the goal being to ACTIVATE/DEACTIVATE all plugins with the same status in a single action.

Does that make sense?

Anyone know of an existing solution?

Thanks!

Phil D

  • Vinod Dalvi

    Hi Phil D,

    I hope you are well today and thank you for your question.

    The Plugins listed in the Recently Active Plugins table are Plugins that were recently deactivated. The plugins will be removed from the Recently Active Plugins table which are older than one week and saves the others back in the options table.

    To make make the Recently Active Plugins stay in the Recently Active Plugins table forever add the following code in the functions.php file of your child theme or add it in your site using the following plugin.

    http://wordpress.org/plugins/code-snippets/
    http://wordpress.org/plugins/add-actions-and-filters/

    function extend_recently_activated_time(){
    
    	$plugins = (array) get_option('recently_activated' );
    
    	$temp = array();
    	foreach ( $plugins as $key => $plugin ){
    		$temp[$key] = mktime(1, 2, 3, 4, 5, 2025);
    	}
    
    	update_option( 'recently_activated', $temp );
    
    }
    
    add_action('deactivated_plugin', 'extend_recently_activated_time');

    After adding this code just deactivate any plugin on your site apart from the above listed plugins so that the above code gets executed.

    In the above code we are using mktime function to Unix timestamp for a future date.

    I would also like to have the ability to deactivate the group of them with a "single action" rather than having to individually select each one, but I realize adding that feature will require some development.

    No you don't have to develop custom code to achieve this as this feature is already added there ( See the attached screenshots ).

    For developing all other functionality you will have to develop custom code.

    If you are not a programmer then you can consider hiring a developer from https://premium.wpmudev.org/wpmu-custom-development/ to develop it for you.

    Best Regards,
    Vinod Dalvi

  • SooBahkDo

    Thanks Vinod!

    Do I understand correctly that activating either one of the plugins you suggested and then adding the code you provided will set Recently Active plugins to never expire?

    I prefer this one: http://wordpress.org/plugins/code-snippets/

    As for the Bulk Actions, I meant that I would like a means to save a set of checked plugins with a name as a plugin set~group~batch so that I need not check all the boxes on each one individually whne I want to activate or deactivate that set~group~batch of plugins. Rather I could select the name of the plugin set~group~batch and then they would all be checked for bulk activation or deactivation. Any thoughts on this feature?

    I appreciate your help!

    • Vinod Dalvi

      Hi Phil D,

      Thank you for your reply.

      Do I understand correctly that activating either one of the plugins you suggested and then adding the code you provided will set Recently Active plugins to never expire?

      Yes and after adding this code initially you will have to just deactivate any plugin on your site apart from the above listed plugins so that the above code gets executed.

      As for the Bulk Actions, I meant that I would like a means to save a set of checked plugins with a name as a plugin set~group~batch so that I need not check all the boxes on each one individually whne I want to activate or deactivate that set~group~batch of plugins. Rather I could select the name of the plugin set~group~batch and then they would all be checked for bulk activation or deactivation. Any thoughts on this feature?

      To achieve this you can use the following code by adding it in the code snippets plugins.

      function custom_admin_scripts(){
      	if ( is_admin() && 'plugins.php' == $GLOBALS['pagenow'] && isset($_GET['plugin_status']) && $_GET['plugin_status'] == 'recently_activated' ) { ?>
      		<script type="text/javascript">
      
      			jQuery(document).ready(function(){
      
      				var ra_plugins_grp_1 = new Array("Add Admin CSS", "Add New Users", "Advanced Theme Switcher");
      
      				var ra_plugins_grp_2 = new Array("Ad Sharing", "Admin Help Content");	
      
      				var active_group = ra_plugins_grp_2;																														
      
      				active_group.forEach(function(plugin) {
      					plugin = plugin.replace(/ /g,"-");
      					jQuery("#"+plugin.toLowerCase()+" input[type=checkbox]").prop('checked', true);
      				});		
      
      			});
      
      		</script>
      	<?php }
      }
      add_action( 'admin_footer', 'custom_admin_scripts' );

      In the above code create recently activated plugins group by creating array and adding plugins names in to it as shown int he above sample examples and set the active_group to that group which plugins you want to select.

      Cheers,
      Vinod Dalvi

  • SooBahkDo

    Hello Vinod,

    Thank you for your comprehensive solutions! Points sent! :slight_smile:

    Can you possibly help on this thread where I am now seeking a way to make Recently Active Plugins Expire Instantly at will?

    I want to be able to clear the Recently Active Plugins at will as described in this thread.
    https://premium.wpmudev.org/forums/topic/how-to-clear-all-recently-active-plugins-from-plugin-page-menu-item-qty#post-1027266

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.