ASU-KE / UDS-WordPress-Theme

A next-generation WordPress theme for ASU Web Standards 2.0 (2020)
GNU General Public License v2.0
0 stars 0 forks source link
wordpress-theme

ASU Knowledge Enterprise

ASU Web Standards WordPress Theme

A WordPress theme based on ASU's Web Standards 2.0

A WordPress theme that builds on top of ASU's canonical design tokens, and the official ASU Bootstrap theme, to deliver standards-compliant and accessible WordPress websites across ASU.

divider

bootstrap wordpress understrap

Features

divider

Table of Contents

divider

Getting Started

Installation

GitHub Updater

Installing Required Plugins

Using the Theme

Updating the Theme

Customizer Options

Page Heroes

Page Banners

The theme provides a widget area, and corresponding widget, for displaying UDS-compliant banners across the top of every page in your site. These banners will appear below the hero area, and above all other content.

To create a banner, add the provided Notification Banner widget to the Global Banner Area on the WordPress widgets admin screen (or via the Customizer) and configure the banner as desired using the options provided. Make sure to set the Show Banner option to Yes in order to have the banner appear on your site.

To remove a page banner, either delete the widget from the Global Banner widget area, or set the Show Banner option to No.

Social Media Icons

Menus

The UDS-WordPress theme has three assignable menu areas:

Working with the Main Menu

You build the main menu of your site using the built-in WordPress menu builder. The menu-building code behind the scenes, however, will enforce certain ASU Web Standards when it comes to the main navigation menu:

Here is an example of a main menu hierarchy, and how each item would be rendered in this theme.

Example of menu hierarchy

Working with the Footer Menu
Working with the Social Media Icons Menu

Shortcodes

Adding Sidebars

Reporting Issues

divider

For Developers

Introduction

Requirements

You need to set up your development environment before you can do anything.

Install Node.js and NPM

Local WordPress Environment

This is a WordPress theme, and you will need to have access, and administrative rights, to a WordPress site in order to do any development on the theme. It is not recommended to attempt theme development on a live server.

There are several solutions available for hosting local WordPress development sites on your own computer, including:

Setting Up Local or Lando

Local By Flywheel

We are currently using WP Engine to manage our WordPress sites and to connect your Local By Flywheel installation to WP Engine you will need a WP Engine account and API key.

WP Engine Instructions.

Local By FlyWheel Connect Select Example

Local By FlyWheel Connect Area Example

Then you will see a list of hosting providers to choose from.

This will give you access to pull sites locally to work on.

For new project's select: ASU UDS Quickstart

* After you have pulled the site to to your local machine disconnect it from the host to ensure premature development is not deployed in the background. You can do this by clicking the same button used to Pull To Local to Disconnect.

You are now ready to clone the theme within the projects wp-content/themes folder.

Lando

Lando will install all necessary underlying dependencies to run.

Lando constructs a Docker based development environment according to YAML files called recipes that guides the containers it builds, services available and tooling provided.

Within the theme's repository is a .lando.yml file that will be used to start Lando and build the development environment.

The process will look like this.

You are now ready to clone the theme within the projects wp-content/themes folder.

Cloning the Theme

Once you have been able to install and run a local version of WordPress, clone theme repository into the wp-content/themes folder and continue with the installation process below.

Installing Dependencies

Installing Dependencies from the ASU Unity Design System

The ASU-produced packages in this theme are loaded from the ASU Unity Private NPM (Verdaccio) package repository. This requires you to sign-in and create a user account on the NPM server. Doing so, npm will automatically save your authentication token into a local .npmrc file located in your home directory.

Creating a User Account and Saving your NPM Access Token

  1. Visit the ASU Unity NPM Package server and follow directions to add yourself as a user: https://registry.web.asu.edu/
  2. Create your npm user account by executing in a terminal: npm adduser --registry https://registry.web.asu.edu
  3. It is recommended that you use your ASU.edu email address. You can use any password; be sure to save it in LastPass!
  4. Configure npm to use this private registry. Add the following line to the .npmrc file in your home directory (existing lines can be left in-place):
@asu-design-system:registry=https://registry.web.asu.edu/

This config tells npm that all packages from ‘@asu-design-system’ should be requested from the ASU private registry. If it says you are not authorized, sign in using:

npm login --registry https://registry.web.asu.edu/

Once you have successfully signed-in, npm will automatically save a new line to your .npmrc, saving your login token for the future.

Contributing to the Theme

Welcoming paragraph here with general contribution notes

PHP Coding Standards

The theme is set up with tools to help you write PHP that conforms to the WordPress Coding Standards. After initially cloning the theme repo, run composer install to install these tools in the /vendor directory.

Composer Scripts

The theme contains two composer scripts to help you write code that conforms to the WordPress standards:

It is important to run the composer check:cs command and fix any issues before pushing your code to Github, as these commands will run on every single .php file in the theme. If you don't check your work, any issues with your code will surface when another developer checks their code, making it more difficult for any developer to know if it is their code causing the errors.

If needed, you can manually run these commands and target a specific file, or files. From the root folder of the theme:

NPM and Gulp Scripts

We use Gulp as our task runner. While can run Gulp tasks directly from the command line, we have created some NPM aliases for common tasks.

Working with Styles

To work with and compile your Sass files on the fly start:$ gulp watch

BroswerSync

Or, to run with Browser-Sync:

{
    "browserSyncOptions" : {
        "proxy": "localhost/theme_test/", // <----- CHANGE HERE
        "notify": false
    },
    ...
};

Travis CI

Extending the Theme

The UDS-WordPress theme is a complete theme which includes all of the required WordPress template files and assets for the theme to work.

It can also function as the parent for a customized child theme. A child theme allows developers to make modifications to any part of the existing theme and to keep their customizations separate from the parent theme functions.

The UDS-WordPress theme also includes several action hooks that can be used either by a child theme or a plugin to add or alter functionality of the parent theme.

UDS-WordPress-Child-Theme theme template

A "starter" child theme template has been made available for use in creating your custom solution for WordPress. That theme template is located here:

Out of the box, the child theme template:

Further instructions on how to best use the child theme template can be found the GitHub repository.

Action Hooks and Filters

The UDS-WordPress-Theme includes hooks in the following places. Hook Location
uds_wp_after_global_header header.php
uds_wp_before_global_footer footer.php
uds_wp_before_global_footer_columns footer.php

uds_wp_after_global_header - fires immediately after the closing </header><!-- end #asu-header --> statement in header.php. Serves as an ideal place for a small banner or other alert mechanism to be added before a potential hero image across multiple pages on the site.

uds_wp_before_global_footer - fires immediately before the closing global <footer> tag in footer.php. Allows for a persistent block of code to appear across multiple pages of the site, just above the point at which the global footer begins.

uds_wp_before_global_footer_columns - fires immediately before the <div id="wrapper-footer-columns"> landmark within footer.php. In conjunction with the theme option to turn off the native footer column feature, this would be a handy way to replace the native functionality for the footer columns with your own solution.

You can take advantage of these hooks within a child theme or plugin using a function like the following:

/**
 * Adds a section of content immediately above the global footer.
 * Looks for a template called '/templates/content-prefooter.php'
 */
function your_project_add_prefooter_content() {
    get_template_part( 'templates/content', 'prefooter' );
}
add_action( 'uds_wp_before_global_footer', 'your_project_add_prefooter_content' );

divider

Project Structure

[is this needed?]

This theme is built on top of Understrap, with minor adjustments specific to the needs of the theme. Most traditional WordPress theme files are where you would expect them. Files and folders of interest include:

Name Description
functions.php A lean file that loads code from multiple files in the /inc directory
/inc WordPress hooks and callbacks, organized by their purpose in the theme and loaded into functions.php at runtime
/templates-loop Partial templates for displaying content from posts and pages (the WordPress 'loop')
/templates-page Multiple full-page layout templates
/templates-sidebar Templates for the various widget areas in the theme (aka 'sidebars')
/sass/theme/_theme An SCSS file for styling rules that are not covered by the Bootstrap theme, or other SCSS files in the /sass directory. The first place to put your custom styles