RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

# ——— PROJECT NAME ———
echo "——${RED} Quel est le nom du client ?${NC} "
read clientName
projectName="Deligraph_${clientName}"


# ——— RECONFIGURATION DE L'URL HOME LOCALE ———
echo "##### ${GREEN}RECONFIGURATION DE L'URL HOME LOCALE${NC} #####  "
# Manually change my db host sur ma machine pour wp-cli fonctionne en local (pour bien préciser le socket)
# define('DB_HOST', 'localhost:/Users/martoni_sato/Library/Application Support/Local/run/nFQk01MlZ/mysql/mysqld.sock');

# ——— PLUGINS ———
echo "##### ${GREEN}INSTALLATION DES PLUGINS ${NC} #####"
wp plugin install ./wp-database-tools-main.zip --activate
wp plugin install duplicator --activate 
wp plugin install advanced-custom-fields-pro --activate 

composer require wpengine/advanced-custom-fields-pro
wp plugin activate  advanced-custom-fields-pro 
wp eval 'acf_pro_update_license("b3JkZXJfaWQ9NTg3Nzd8dHlwZT1kZXZlbG9wZXJ8ZGF0ZT0yMDE1LTA2LTI1IDA4OjE5OjUx");'

# ——— LANGUE ———
wp language core install fr_FR
wp language core activate fr_FR


# ——— THEME ———
echo "##### ${GREEN}INSTALLATION DU THEME ${NC} #####"
git clone https://gitlab.com/deligraph/wp_starter.git
mv wp_starter $projectName
cd $projectName
sed -i "s/Deligraph_theme/$projectName/g" style.css
wp theme activate projectName

# ——— DEFAULT CONTENT ———
wp post create --post_type=page --post_title='Home' --post_status='publish'
wp post create --post_type=page --post_title='News' --post_status='publish'

wp option update show_on_front "page"
wp option update page_on_front "4"
# wp option update page_for_posts "5"


# ——— DESCATIVER LES COMMENTAIREs———

# make all comments disabled
wp option update disable_comments_options --format=json '{"disabled_post_types":["post","page","attachment"],"remove_everywhere":true,"permanent":false,"extra_post_types":false,"db_version":6}'



wp menu create "Main Menu"
wp menu location assign main-menu primary
