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.
- ASU Web Standards 2.0
- Based on ASU's official design token libray for consistent adherence to Web Standards 2.0
- Utilizes the official ASU Bootstrap theme built on top of the design token library
- Accessibilty built-in: all Bootstrap markup and styling is approved by the ASU Accessibility community before release
- WordPress
- Utilizes standard WordPress features, such as page templates, widgets, and shortcodes, for easy and rapid development of standards-compliant WordPress sites
- Getting Started
- For Developers
- npm i @asu/asu-unity-stack
- npm i bootstrap
- node_modules update @import path to
../../node_modules/bootstrap
in errored files - gulp task copy node module to /css folder
- gulp task minify css for prod (rename module is throwing
(node:26735) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
may need update soon )
- npm i @asu/component-header
- gulp task copy node module to /js folder
- npm i @asu/cookie-consent
- gulp task copy node module to /js folder
- npm i @asu/asu-unity-stack
- gulp task copy node module to /img folder
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.
The UDS-WordPress theme has three assignable menu areas:
- The main navigation menu, at the top of every page
- The main footer menu, at the bottom of every page
- The social media icons menu, shown above the main footer area
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:
- menu items can be nested no more than three levels deep. Any menu you item to drag to the fourth level (or any level beyond that) will not appear in the menu.
- First level menu items will appear as entries in the main navigation menu
- Second level menu items will form dropdown menus beneath their parent item, unless there are also third-level items beneath them. In that case:
- the second level item will become a non-clickable column header, and all third-level items below it will form links in a single column
- any sub-menu with more than two columns will be rendered as a full-width 'mega-menu'
Here is an example of a main menu hierarchy, and how each item would be rendered in this theme.
ServiceNow - KE Web Services Portal
- Volta is used to manage node versions.
package.json
volta section references the minimum requirements. - Lando + Docker or Local by Flywheel is used to run a local dev server.
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:
- Local by Flywheel
- Lando
- wp-local-docker by 10up
- VVV
- Visit v and click the
Download
button. - Choose your platform and enter some information (only the email field is mandatory), the download should start and you’ll be taken to a start-up screen, where you will select the
Let’s Go!
button. After installation, you’ll be taken to the dashboard. - Proceed to create a new local WordPress install or connect to a remote service like WP Engine.
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.
- To connect select the
Connect
icon on the left hand side of your Local dashboard.
- After you have connected to WP Engine you will see all of the site available to your account listed within the
Connect
area.
- In order to connect to WP Engine you must click the
My Hosts
button in the upper right corner of theConnect
area.
Then you will see a list of hosting providers to choose from.
- Select
WP Engine
and sign in.
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.
- Review Lando Requirements to check your system against the hardware requirements.
- Install 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.
- Change directory to project folder or make one.
- Start Lando:
$ lando start
- Install WordPress core:
$ lando wp download core
- Create wp-config:
$ wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database
- Download and import the database:
$ lando db-import site-database-export-file.sql
You are now ready to clone the theme within the projects wp-content/themes
folder.
- Make sure you have installed Node.js and Browser-Sync (optional) on your computer globally
- Then open your terminal and browse to the location of the theme
- Run:
$ composer install
- Run:
$ npm install
- Install PHP intelephenese
- Add default wordpress stub
- To get intelephese to recognize acf functions, add to VS code
settings.json
:"intelephense.environment.includePaths": ["/local/path/to/acf-pro-stubs"]
,- https://github.com/php-stubs/acf-pro-stubs
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.
Welcoming paragraph here with general contribution notes
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.
The theme contains two composer scripts to help you write code that conforms to the WordPress standards:
composer check:cs
will process all.php
files in the theme and check them for compliance with the WordPress standards. Any code that does not meet the standard will be indicated, and you can fix most of them with another script...composer fix:cs
will fix errors marked with an[x]
in the output ofcomposer check:cs
. You will need to correct any other issues manually.
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:
- To check files:
./vendor/bin/phpcs {path-to-the-php-file}
- To fix errors:
./vendor/bin/phpcbf {path-to-the-php-file}
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.
npm run build
will compile theme assets from the files in the/src
directories and copy them to/css
,/js
, and/img
directories. This includes minifying CSS, uglifying and concating JS files, and running all images throughimageoptim
. If you are not using thewatch
option, this is the command to run after you have made any changes to Javascript or CSS files. This step also cleans out and replaces all files in the\dist
directory. This is equivalent to directly runninggulp compile
.npm run images
does only the image optimization step of the build process. It will optimize all images in/src/img
and copying the optimized images to/img
. This is equivalent to directly runninggulp imagemin
.npm run sync
starts BrowserSync and watches SCSS and JS files for changes, automatically processing those files when they are saved (using a subset of the tasks that would run withnpm run build
). This is equivalent to directly runninggulp watch-bs
or justgulp
, as it is the default Gulp task. See the BrowserSync section below to help you set up BrowserSync before running any of these commands.npm run assets
will delete the files in the/src/image
,/src/js
,/src/sass
and/src/fontawesome
directories and replace them with the current files in the appropriate/node-modules
sub-directories. This is equivalent to directly runninggulp reset-assets
. This command was formerly known aspostinstall
.npm run scripts
will rebundle javascript files in/src/js
based on the gulp file settings. Currently there is an admin js build, and a production js build file.
To work with and compile your Sass files on the fly start:$ gulp watch
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.
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:
- Compiles its own set of CSS rules so that styles from the parent can be overwritten by the child theme's CSS.
- Includes a reference to the UDS-Boostrap-4 design token library, so that you can include these standardized references in your child theme's codebase.
- Includes both the child and the parent's
functions.php
(and related) files. This follows the best practices of the WordPress project.
Further instructions on how to best use the child theme template can be found the GitHub repository.
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' );