Created
September 1, 2015 12:36
-
-
Save ideag/6139c9cdcb97644a244f to your computer and use it in GitHub Desktop.
WordPress rename plugin main PHP file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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