Skip to content

Instantly share code, notes, and snippets.

@ideag
Created September 1, 2015 12:36
Show Gist options
  • Save ideag/6139c9cdcb97644a244f to your computer and use it in GitHub Desktop.
Save ideag/6139c9cdcb97644a244f to your computer and use it in GitHub Desktop.
WordPress rename plugin main PHP file
<?php
/*
Plugin Name: Old Plugin main file
Description: Rename Old plugin main file (i.e. index.php) to `plugin-slug.php`
Version: 0.1.0
Author: Arūnas Liuiza
Author URI: http://arunas.co
License: GPL2
*/
add_action( 'admin_init', 'arunas_rename_plugin' );
function arunas_rename_plugin() {
$old_plugin = plugin_basename( __FILE__ );
$new_plugin = explode( '/', $old_plugin );
$new_plugin = $new_plugin[0];
$new_plugin = "{$new_plugin}/{$new_plugin}.php";
deactivate_plugins( $old_plugin );
activate_plugin( $new_plugin );
unlink(__FILE__);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment