WordPress Development

Revision as of 15:46, 16 April 2014 by Adam Franco (talk | contribs) (Theme Update Checklist)

WordPress is used at Middlebury by a variety of individuals and groups including faculty, staff, students, administrators, designers, developers, librarians, technologists, academic and administrative departments, offices, student organizations, courses, initiatives, projects and so on. This document compiles recommendations about how Wordpress at Middlebury should be configured, updated and maintained.

Initial Setup

The initial setup of WordPress requires:

  1. cloning the Midd WordPress git repository
  2. editing the config.php and .htaccess files
  3. copying production database

Cloning the central repository

Your ssh keys must be authorized to access the central repository. All chisel accounts' ssh keys have been authorized to do so at the time of this writing. Contact Adam to add ssh keys for other machines (such as your desktop) if desired.

  1. cd to your public_html directory on chisel:
    cd ~/public_html/
  2. clone the repository and create a working directory with git-clone:
    git clone git@git.middlebury.edu:web/wordpress.git wordpress
  3. cd into new wordpress directory
    cd wordpress
  4. initialize submodules and then update:
    git submodule init
    git submodule update

Configuring WordPress

  1. cd to your wordpress directory:
    cd ~/public_html/wordpress/
  2. Create a local copy of your WordPress configuration
    cp wp-config.php-midd wp-config.php
  3. Update local copy of WordPress configuration
    -define('DB_NAME', 'username_wordpress');
    +define('DB_NAME', 'yourname_wordpress');
  4. Create a local copy of your .htaccess file:
    cp .htaccess-midd .htaccess
  5. Update local copy of .htaccess file:
    +RewriteBase /~yourname/wordpress/

Copying production database to development

  1. Create a database, (e.g. yourname_wordpress) on development server
  2. Dump the production database

mysqldump -h snipe -u wordpress -p --lock-tables=false --skip-extended-insert wordpress > yourname_wordpress.sql

  1. Re-write server specific values in SQL using perl scripts

perl -p -i -e 's#http://blogs.middlebury.edu#http://chisel.middlebury.edu/~yourname/wordpress#gi' yourname_wordpress.sql perl -p -i -e 's#blogs.middlebury.edu#chisel.middlebury.edu#gi' yourname_wordpress.sql perl -p -i -e "s#chisel\.middlebury\.edu','/#chisel.middlebury.edu','/~yourname/wordpress/#gi" yourname_wordpress.sql

  1. Import updated sql into your development database
    mysql -u testuser -ptestpassword -D yourname_wordpress < yourname_wordpress.sql

Updating WordPress

Applying Core Updates

  1. Save your .htaccess, and wp-config.php files outside of wordpress directory
    mkdir ~/wp-settings/; cp .htaccess wp-config.php ~/wp-settings
  2. Delete all files except the .git and .gitignore directories
    find . -maxdepth 1 ! -name '.git*' ! -name '.' ! -name '..' -exec rm -Rf {} \;
  3. Copy the WordPress codebase zip file to your WordPress directory and unzip
    unzip latest.zip
  4. cd into wordpress dir and move files to parent directory
    cd wordpress
    mv * ..
  5. cd to main wordpress directory and delete empty wordpress directory and the zip file
    cd ../
    rm -r wordpress
    rm latest.zip
  6. Add and commit the changes (and additions/removals)
    git-add -u
    git-commit -m "Updated Wordpress from version 3.x to version 3.y
  7. Checkout the plugins branch and merge the core changes
    git checkout plugins
    git merge core
  8. Checkout the plugins-miis branch and merge the core changes from plugins
    git checkout plugins-miis
    git merge plugins
  9. Checkout the master-miis branch and merge the core changes from plugins-miis
    git checkout master-miis
    git merge plugins-miis
  10. Checkout the master branch and merge the core changes from plugins
    git checkout master
    git merge plugins
  11. Copy your wp-settings files saved in step 1
    cp ~/wp-settings/.htaccess .
    cp ~/wp-settings/wp-config.php .

Applying language updates

Create a bash script named wp_lang.sh on your development machine with these contents:


LANGS+=("ar")     # Arabic
LANGS+=("de_DE")  # German - Germany
LANGS+=("es_ES")  # Spanish - Spain
LANGS+=("es_PE")  # Spanish - Peru
LANGS+=("fr_FR")  # French - France
LANGS+=("he_IL")  # Hebrew - Israel
LANGS+=("it_IT")  # Italian - Italy
LANGS+=("ja")     # Japanese
LANGS+=("ko_KR")  # Korean - Korea, Republic of
LANGS+=("pt_BR")  # Portuguese - Brazil
LANGS+=("pt_PT")  # Portuguese - Portugal
LANGS+=("ru_RU")  # Russian - Russian Federation
LANGS+=("zh_CN")  # Chinese - China
LANGS+=("zh_TW")  # Chinese - Taiwan


# Fetch new copies
for LANG in "${LANGS[@]}"
  for VERSION in "${VERSIONS[@]}"
    wget -r -np -nH --cut-dirs=5 -e robots=off -R index.html -P${WP_DIR}wp-content/languages/ http://svn.automattic.com/wordpress-i18n/${LANG}/tags/${VERSION}/messages/
    wget -r -np -nH --cut-dirs=7 -e robots=off -R index.html -P${WP_DIR}wp-content/languages/ http://svn.automattic.com/wordpress-i18n/${LANG}/tags/${VERSION}/dist/wp-content/languages/

# Move the theme-specific files and delete their directories
cp ${WP_DIR}wp-content/languages/twentyten/* ${WP_DIR}wp-content/themes/twentyten/languages/
rm -rf ${WP_DIR}wp-content/languages/twentyten/
cp ${WP_DIR}wp-content/languages/twentyeleven/* ${WP_DIR}wp-content/themes/twentyeleven/languages/
rm -rf ${WP_DIR}wp-content/languages/twentyeleven/
cp ${WP_DIR}wp-content/languages/twentytwelve/* ${WP_DIR}wp-content/themes/twentytwelve/languages/
rm -rf ${WP_DIR}wp-content/languages/twentytwelve/
cp ${WP_DIR}wp-content/languages/twentythirteen/* ${WP_DIR}wp-content/themes/twentythirteen/languages/
rm -rf ${WP_DIR}wp-content/languages/twentythirteen/
cp ${WP_DIR}wp-content/languages/twentyfourteen/* ${WP_DIR}wp-content/themes/twentyfourteen/languages/
rm -rf ${WP_DIR}wp-content/languages/twentyfourteen/
 # Change the value of WP_DIR to be the path to your development copy of WordPress.
# Update the LANGS array to include the languages you want to update.
# Update the VERSIONS array with the version numbers of WordPress releases since the least up-to-date language with language files in the repository at http://svn.automattic.com/wordpress-i18n/
# Make sure the script is executable by running<pre>chmod u+x wp_lang.sh
  1. Run the script
  2. cd into your WordPress development directory
  3. Add the updated language files
    git add .
  4. Commit the new language files
    git commit -m "Updated language files to latest version."

Applying plugin updates

  1. Checkout the plugins branch
    git checkout plugins
  2. Remove the old plugin
    rm -rf wp-content/plugins/name-of-plugin
  3. Unzip the plugin and move it into place
    unzip name-of-plugin.zip
    mv name-of-plugin wp-content/plugins/
    rm name-of-plugin.zip
  4. Add and commit the changes (and additions/removals)
    git add wp-content/plugins/name-of-plugin
    git add -u wp-content/plugins/name-of-plugin
    git commit -m "Updated name-of-plugin from version x to version y
  5. Checkout the master branch and merge the plugin changes from plugins
    git checkout master
    git merge plugins

Theme Update Checklist

Themes are updated in using the same process as plugins, however we need to make sure that the look and feel does not change significantly and that widget areas to not loose content due to changing widget region ids. For each theme that is to be updated check 2-3 of the sites using it against the following checklists.

Use this checklist to determine if there is a "significant" change to the theme. If all of these items are the same for standard desktop-sized browsers (1280 x 1024) then we can reasonably say that the theme has not significantly changed. Responsive themes may radically alter the design for small screens. This is to be expected and encouraged.

  • Is the color scheme the same?
    • Is the text color the same or a very similar shade?
    • Is the background color behind the text the same or a very similar shade?
    • is the overall background color the same or a very similar shade?
    • Are border colors & weights the same or a very similar shade?
    • Are sidebars, headers, and footers the same color or a very similar shade?
    • Is there a background graphic, and if so is it the same?
  • Is the text treatment the same?
    • Is text about the same size (within 2-3 points of each other)
    • Is the font of the same family (serif versus san-serif)?
  • Are menus and widget regions the same?
    • Are menus and regions in the same place?
    • Are menus in the same location (top, left side, right side, etc)?
    • Do menus have similar drop-down/expand behavior?
    • Are widgets/sidebars in the same place (top, left side, right side, etc)?
    • Are widgets/sidebars the same size (within ~30px of the original height, width, padding)?
  • Is the header image similarly sized and located?
  • Are comments styled similarly (same text size, color, location)?
  • Are tags/categories still shown and similarly styled (size, location, color)?
  • Does the theme generally look the same to you?

Theme updates for which the answers are "yes" to all of the above may be applied without notification to site administrators/editors. If the answer is "no" to any of the above, then the updates will be held off until we have a chance to notify site administrators/editors and work with them to find an acceptable replacement theme or confirm updates to the current theme. In extreme cases, the JetPack CSS editor can be used to override the new theme styles to emulate old versions of a theme.

Additionally, verify that all widgets are retained in their same widget areas. If not, widget area ids may have changed. This is a technical problem for which we can either manually replace widgets if only a few sites use the theme or script a fix if many sites use the theme. No themes should be updated in such a way as to leave sites broken for more than a few minutes while the updates are being applied.

Plugin and Theme Security Reviews

All plugins and themes should be reviewed for vulnerabilities detailed in the WordPress Plugin Security Review Checklist.