Skip to content

Instantly share code, notes, and snippets.

@philipjohn
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipjohn/f679418f6ed207caa4e7 to your computer and use it in GitHub Desktop.
Save philipjohn/f679418f6ed207caa4e7 to your computer and use it in GitHub Desktop.
Grabs a list of blogs and runs some tasks on each to set up a new multisite
if [ ! -f menus.wxr ]; then
echo "You need to export the menus for the menu setting to work, export to a menus.wxr file"
echo "remember to export the 'nav_menu_item' post type to a menus.wxr file before running"
exit;
fi
# Get a list of blogs to loop through
blogs=$(wp site list --fields="site_id,blog_id,url" --format="csv" --path="../../repository/htdocs/wp")
for entry in $blogs
do
site_id=$(echo $entry |cut -d ',' -f1 )
blog_id=$(echo $entry |cut -d ',' -f2 )
blog_url=$(echo $entry |cut -d ',' -f3 )
echo "Processing $blog_id: $blog_url in $site_id"
# Activate the new theme
wp theme activate 'theme' --url="$blog_url" --path="../../repository/htdocs/wp"
# Import the sidebar widgets
cat sidebars.tmp | wp sidebars import --url="$blog_url" --path="../../repository/htdocs/wp"
# Make sure we only show 1 post per page
wp option update posts_per_page 1 --url="$blog_url" --path="../../repository/htdocs/wp"
# Set the time format
wp option update time_format "" --url="$blog_url" --path="../../repository/htdocs/wp"
# Get the Analytics UA ID and copy it to the new option
ua_id=$(wp option get ga_mu_uaid --url="$blog_url" --path="../../repository/htdocs/wp")
wp option update bootiful_options '{"local_gat":"'"$ua_id"'","header_meta":"","body_meta":"","footer_meta":""}' --format=json --url="$blog_url" --path="../../repository/htdocs/wp"
# Import the menus and set them
wp import menus.wxr --authors=create --url="$blog_url" --path="../../repository/htdocs/wp"
wp menu location assign 'top right menu' navigation --url="$blog_url" --path="../../repository/htdocs/wp"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment