Skip to content

Instantly share code, notes, and snippets.

@mralaminahamed
Created March 1, 2026 06:20
Show Gist options
  • Select an option

  • Save mralaminahamed/7bd0bd3d1d5d53ff0212a9331e996fba to your computer and use it in GitHub Desktop.

Select an option

Save mralaminahamed/7bd0bd3d1d5d53ff0212a9331e996fba to your computer and use it in GitHub Desktop.
Create a new plugin from codexprt boilerplate
cpb() {
read -r -p 'Type (1: Classic / 2: Basic / 3: Modern): ' type
read -r -p 'Name: ' name
read -r -p 'Slug: ' slug
read -r -p 'Package: ' package
read -r -p 'Prefix: ' prefix
read -r -p 'Constant: ' constant
read -r -p 'Description: ' description
if [ "$type" == 1 ]; then
git clone https://github.com/codexpertio/cx-plugin.git "$slug"; #clone boilerplate
fi
if [ "$type" == 2 ]; then
git clone -b client https://github.com/codexpertio/cx-plugin.git "$slug"; #clone boilerplate
fi
if [ "$type" == 3 ]; then
git clone -b modern https://github.com/codexpertio/cx-plugin.git "$slug"; #clone boilerplate
fi
cd "$slug"; # enter into the dir
mv "cx-plugin.php" "$slug.php";
if [ "$name" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/CX Plugin/$name/g" {} \; # replace name
fi
if [ "$slug" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/cx-plugin/$slug/g" {} \; # replace slug and domain
fi
if [ "$package" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/CX_Plugin/$package/g" {} \; # replace namespace
fi
if [ "$prefix" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/cxp/$prefix/g" {} \; # replace prefix
fi
if [ "$prefix" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/cx_plugin/$prefix/g" {} \; # replace prefix
fi
if [ "$constant" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/CXP/$constant/g" {} \; # replace constant
fi
if [ "$description" != "" ]; then
find ./ -type f -readable -writable -exec sed -i "s/Just another plugin by Codexpert/$description/g" {} \; # replace description
fi
composer install; # update composer element
rm -r .git; # remove .git dir
gi; #init git again
ga;
gc -m "init";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment