I need to get specific URL vars from the string of the plugin activate link when in plugins list view.


add_action('admin_init', function() 
  if( $_GET['action'] == 'activate' && $_GET['plugin'] == 'move-blocks/move-blocks.php' ) {
    copy($src, $dest);

When I run $_GET I do not see the query string as shown in the activate link. Apparently it's being processed by an AJAX function.

How can I get the literal activate URL?

1 Answer 1


It turns out getting the URL on activation is not likely through the standard $_GET so WP has hooks for that.

Plugin Activation

I need to check for back up files stored in wp-content root, if they were created previously during de-activation or update, and copy to the plugin's folder.

register_activation_hook(__FILE__, function() 

  if( file_exists(WP_CONTENT_DIR.'/moveblocktmp/override.ini') ) {
    copy(WP_CONTENT_DIR.'/moveblocktmp/override.ini', MYPLGPATH.'/msg/override.ini');

Plugin De-Activation

Action when the plugin Deactivate link is processed. This works during plugin update to store user created files while the plugin is deleted and replaced.

register_deactivation_hook(__FILE__, function() 
  // create backup directory
  if( !file_exists(WP_CONTENT_DIR.'/moveblocktmp') ) {

  // copy files for backup
  if( file_exists(MYPLGPATH.'/msg/override.ini') ) {
    copy(MYPLGPATH.'/msg/override.ini', WP_CONTENT_DIR.'/moveblocktmp/override.ini');

Action After Previous Processes

add_action('admin_init', function() 
  // delete the previously created DB option row
  if( !is_null(get_option('move_blocks_activated')) ) {
  if( !is_null(get_option('move_blocks_deactivated')) ) {

On Plugin Delete

Using the uninstall.php method in the plugin's root.


if( !defined('WP_UNINSTALL_PLUGIN') ) {

// delete the backup directory
if( file_exists(WP_CONTENT_DIR.'/moveblocktmp') )
  // rmdir() will not delete a directory with files. I use a recursive function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.