Last active
August 29, 2015 14:07
-
-
Save toddhalfpenny/901835ab8f47341a95f8 to your computer and use it in GitHub Desktop.
Rename and replace WordPress Plugin Boilerplate
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
#!/bin/bash | |
def_plugin_name='plugin-name' | |
def_plugin_class='Plugin_Name' | |
def_your_name='Your Name' | |
def_email='[email protected]' | |
echo "Name of you plugin: [$def_plugin_name]" | |
read plugin_name | |
if [ "$plugin_name" = "" ] ; then | |
plugin_name=$def_plugin_name | |
fi | |
echo "Class Name of you plugin: [$def_plugin_class]" | |
read plugin_class | |
if [ "$plugin_class" = "" ] ; then | |
plugin_class=$def_plugin_class | |
fi | |
echo "Your Name: [$def_your_name]" | |
read your_name | |
if [ "$your_name" = "" ] ; then | |
your_name=$def_your_name | |
fi | |
echo "Your Email: [$def_email]" | |
read email | |
if [ "$email" = "" ] ; then | |
email=$def_email | |
fi | |
if [ "$plugin_name" != $def_plugin_name ] ; then | |
mv $def_plugin_name $plugin_name | |
find $plugin_name -exec rename 's/plugin\-name/'$plugin_name'/' '{}' + | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/plugin\-name/'$plugin_name'/g' {} + | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/run_plugin_name/run_'$plugin_name'/g' {} + | |
fi | |
if [ "$plugin_class" != $def_plugin_class ] ; then | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/Plugin\_Name/'$plugin_class'/g' {} + | |
fi | |
if [ "$your_name" != "$def_your_name" ] ; then | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/Your\ Name\ or\ Your\ Company/'"$your_name"'/g' {} + | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/Your\ Name/'"$your_name"'/g' {} + | |
find $plugin_name -type f -name "*.php" -exec sed -i'' -e 's/email\@example\.com/'"$email"'/g' {} + | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment