Repository: 10up/theme-scaffold Branch: master Commit: e68ccaa0b963 Files: 72 Total size: 67.5 KB Directory structure: gitextract_0yipqz8n/ ├── .browserslistrc ├── .editorconfig ├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .npmrc ├── .nvmrc ├── .stylelintrc ├── LICENSE.md ├── README.md ├── assets/ │ ├── css/ │ │ ├── admin/ │ │ │ ├── admin-style.css │ │ │ └── example-block-1.css │ │ ├── blocks/ │ │ │ ├── example-block-1.css │ │ │ └── index.css │ │ ├── frontend/ │ │ │ ├── base/ │ │ │ │ ├── index.css │ │ │ │ ├── prefers-reduced-motion.css │ │ │ │ └── wordpress.css │ │ │ ├── components/ │ │ │ │ └── index.css │ │ │ ├── editor-style.css │ │ │ ├── global/ │ │ │ │ ├── colors.css │ │ │ │ ├── index.css │ │ │ │ └── media-queries.css │ │ │ ├── layout/ │ │ │ │ └── index.css │ │ │ ├── style.css │ │ │ └── templates/ │ │ │ └── index.css │ │ ├── shared/ │ │ │ └── shared-style.css │ │ └── styleguide/ │ │ └── styleguide.css │ ├── fonts/ │ │ └── font-name/ │ │ └── .gitkeep │ ├── images/ │ │ └── .gitkeep │ ├── js/ │ │ ├── admin/ │ │ │ └── admin.js │ │ ├── blocks/ │ │ │ ├── blocks.js │ │ │ └── example-block-1.js │ │ ├── frontend/ │ │ │ ├── components/ │ │ │ │ └── .gitkeep │ │ │ └── frontend.js │ │ ├── shared/ │ │ │ └── shared.js │ │ └── styleguide/ │ │ ├── styleguide.js │ │ └── uikitsection.js │ └── svg/ │ └── .gitkeep ├── babel.config.js ├── composer.json ├── config/ │ ├── webpack.config.common.js │ ├── webpack.config.dev.js │ ├── webpack.config.prod.js │ └── webpack.settings.js ├── footer.php ├── functions.php ├── header.php ├── includes/ │ ├── blocks/ │ │ ├── blocks-editor.js │ │ └── example-block-1/ │ │ └── index.js │ ├── blocks.php │ ├── classes/ │ │ └── .gitkeep │ ├── core.php │ ├── overrides.php │ ├── template-tags.php │ └── utility.php ├── index.php ├── languages/ │ └── TenUpScaffold.pot ├── manifest.json ├── package.json ├── partials/ │ └── .gitkeep ├── phpcs.xml ├── postcss.config.js ├── search.php ├── searchform.php ├── style.css ├── templates/ │ └── page-styleguide.php ├── tests/ │ ├── accessibility/ │ │ └── compliance/ │ │ └── pa11y.js │ ├── js/ │ │ └── .gitkeep │ ├── php/ │ │ └── .gitkeep │ └── wpa/ │ ├── FrontendTest.php │ └── StandardTest.php └── wpacceptance.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .browserslistrc ================================================ # Browsers that we support > 1% last 2 versions Firefox ESR IE 11 ================================================ FILE: .editorconfig ================================================ root = true [*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = tab [{*.json,*.yml,.babelrc,.bowerrc,.browserslistrc,.postcssrc}] indent_style = space indent_size = 2 [*.txt,wp-config-sample.php] end_of_line = crlf ================================================ FILE: .eslintignore ================================================ assets/js/vendor assets/js/admin/vendor assets/js/frontend/vendor assets/js/shared/vendor webpack.config.babel.js tests ================================================ FILE: .eslintrc.json ================================================ { "extends": "@10up/eslint-config/wordpress", "rules": {}, "globals": { "module": true, "process": true } } ================================================ FILE: .gitignore ================================================ node_modules bower_components release vendor phpunit.xml .idea # Project Files dist backstop_data # Editors *.esproj *.tmproj *.tmproject tmtags .*.sw[a-z] *.un~ Session.vim *.swp # Mac OSX .DS_Store ._* .Spotlight-V100 .Trashes # Windows Thumbs.db Desktop.ini ================================================ FILE: .npmrc ================================================ engine-strict=true ================================================ FILE: .nvmrc ================================================ 12 ================================================ FILE: .stylelintrc ================================================ { "extends": "@10up/stylelint-config" } ================================================ FILE: LICENSE.md ================================================ MIT License Copyright (c) 2019 10up Inc. (https://10up.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # 10up Scaffold **DEPRECATED.** Use https://github.com/10up/wp-scaffold > At 10up, we strive to provide digital products that yield a top-notch user experience. In order to improve both our efficiency and consistency, we need to standardize what we use and how we use it. This theme scaffold allows us to share initial set up procedures to make sure all projects can get up and running as quickly as possible while closely adhering to 10up's high quality standards. [![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![MIT License](https://img.shields.io/github/license/10up/theme-scaffold.svg)](https://github.com/10up/theme-scaffold/blob/master/LICENSE.md) ## Dependencies 1. [Node@^8.11.0 & NPM](https://www.npmjs.com/get-npm) - Build packages and 3rd party dependencies are managed through NPM, so you will need that installed globally. 2. [Webpack](https://webpack.js.org/) - Webpack is used to process the JavaScript, CSS, and other assets. 3. [Composer](https://getcomposer.org/) - Composer is used to manage PHP. ## Getting Started ### Quick Start Install 10up's command line tool for scaffolding new projects. You can download it from the [Project Scaffold repository](https://github.com/10up/project-scaffold). Setting up a new theme is as easy as running `create-10up theme theme-name-here` in the terminal! Browsersync requires a local development URL. This is currently set in the `config/webpack.settings.js`, as `BrowserSyncConfig.proxy`. ### Direct Install - Clone the repository - Rename folder theme-scaffold -> your project's name - If copying files manually to an existing theme directory instead of cloning directly from the repository, make sure to include the following files which may be hidden: ``` .babelrc .browserslistrc .editorconfig .eslintignore .eslintrc .gitignore ``` The NPM commands will fail without these files present. - Do case-sensitive search/replace for the following: - TenUpScaffold - TENUP_SCAFFOLD - tenup-scaffold - tenup_scaffold - 10up Scaffold - `cd` into the theme folder - run `npm run start` ## Webpack config Webpack config files can be found in `config` folder: - `webpack.config.dev.js` - `webpack.config.common.js` - `webpack.config.prod.js` - `webpack.settings.js` In most cases `webpack.settings.js` is the main file which would change from project to project. For example adding or removing entry points for JS and CSS. ## NPM Commands - `npm run start` (install dependencies) - `npm run watch` (watch) - `npm run build` (build all files) - `npm run build-release` (build all files for release) - `npm run dev` (build all files for development) - `npm run lint-release` (install dependencies and run linting) - `npm run lint-css` (lint CSS) - `npm run lint-js` (lint JS) - `npm run lint-php` (lint PHP) - `npm run lint` (run all lints) - `npm run format-js` (format JS using eslint) - `npm run format` (alias for `npm run format-js`) - `npm run test:a11y` (run accessibility tests) ## Composer Commands - `composer install`* (install packages) - `composer update`* (update packages) - `composer lint` (lint PHP files) - `composer lint-fix` (lint PHP files and automatically correct coding standard violations) _* If your host machine's local version of PHP is <7.2, composer may produce the following, or similar, error message:_ ``` Problem 1 - Installation request for 10up/wpacceptance dev-master -> satisfiable by 10up/wpacceptance[dev-master]. - 10up/wpacceptance dev-master requires php >=7.2 -> your PHP version (7.1.23) does not satisfy that requirement ``` _To suppress this error, add the flag `--ignore-platform-reqs` (ie. `composer install --ignore-platform-reqs`)._ ## Automated Style Guide The Theme Scaffolding ships with a default style guide you can find in `/templates/page-styleguide.php`. This file contains all the basic HTML elements you would find at the very top of the cascade (headings, typography, tables, forms, etc.) These base elements will be styled and displayed as you naturally build out your CSS. The style guide also automatically pulls in the color variables used in the project. Any hex codes added into `/assets/css/frontend/global/variables.css` will be automatically displayed in the style guide. To set up your style guide, you just need to create a new page in WordPress and assign it the "Style Guide" template. If you need to update the core styles that power the style guide they are located in `/assets/css/styleguide` and will naturally process with the rest of the CSS. As your site grows you can add components to the style guide by updating `/templates/page-styleguide.php` as you see fit. All the JS and CSS for the site will already be included in the template, so everything should just work. ## Automated Accessibility Testing Automated accessibility testing in the Theme Scaffolding is done with [Pa11y](https://www.npmjs.com/package/pa11y) and is executed with the command `npm run test-a11y`. You can find any configuration options inside your `package.json` file inside the `testing` object. You will see default URL options (homepage, article, search-results), but you can add as many as you'd like. The default script runs over the `local` URL and any others will run with an argument like `npm run test-a11y production`, over a production URL. You can also add more template URLs for testing like `npm run a11y-test article-template`. Be sure to check with your systems person on a project to make sure accessibility tests are also hooked up through the deploy process. Compliance levels can also be updated through the `testing.accessibility.compliance` object in the `package.json` file. The default is WCAG Level A, but it can be updated to anything listed in the [pa11y documentation](https://github.com/pa11y/pa11y). The test file lives in `/tests/accessibility/compliance/pa11y.js` if any edits are needed (such as staging credentials, if you're running tests in an environment that requires authentication). ## Visual Regression Testing We use [BackstopJS](https://github.com/garris/BackstopJS) to run our visual regression tests. BackstopJS requires just a few settings to work: a `scenarios` array that tells it which URL's to screenshot, a `viewports` array that tells it what breakpoints to use, and a `config` object for global settings. Begin by setting which URL's you'd like to test in the `testing.urls` object in `package.json`. You will see some default URL's (homepage, article, search-results), but you can add as many as you'd like. These URL's are read by `tests/visual/scenarios.js` to automatically produce the `scenarios` array that BackstopJS will use to take screenshots. You can also create custom scenarios in `tests/visual/custom-scenarios.js`. Custom scenarios allow us to add specific options for specific URL's, for situations like hovering over an element to screenshot its hover state, or clicking a modal button and waiting for the modal to become visible. To create a custom scenario, simply set the `urlName` property to match the property name in the `testing.urls` object, and then create an `options` object with your desired settings. A couple examples are provided in `tests/visual/custom-scenarios.js` and you can see a list of all available options in the [advanced scenarios](https://github.com/garris/BackstopJS#advanced-scenarios) section on GitHub. BackstopJS can take screenshots at various screen widths, so make sure to match the breakpoints in `tests/visual/viewports.js` with those in your theme. Though generally not necessary, you can customize the BackstopJS configuration by changing the settings in `tests/visual/config.js`. To begin running BackstopJS visual regression tests, initialize its required files. This only needs to be done once on your local machine: `npm run test:visual-init` Then create a set of screenshots that will become the base reference images to run future tests against: `npm run test:visual-reference` After you've made changes and want to test for visual regressions: `npm run test:visual` Finally, if the new screenshots fail but contain desired changes, approve them for use as the new base reference images: `npm run test:visual-approve` ## Automated Acceptance Testing Automated acceptance testing in the Theme Scaffolding leverages [WP Acceptance](https://github.com/10up/wpacceptance) and is included in the project via Composer as a dev required package. Run the command `composer update` (see [Composer Commands](https://github.com/10up/theme-scaffold/tree/feature/docs-composer#composer-commands) above) to install the required packages. Refer to the [documentation](https://wpacceptance.readthedocs.io/en/latest/#wp-acceptance) to ensure your host machine has the necessary [requirements](https://wpacceptance.readthedocs.io/en/latest/#requirements). The Theme Scaffolding is already setup to work with WP Acceptance and a few example tests have been created to serve as examples. To run the test suite, from the root of the repository, run `./vendor/bin/wpacceptance run`. WP Acceptance will automatically run the test suite in isolated docker containers. To write your own acceptance tests, refer to the [documentation](https://wpacceptance.readthedocs.io/en/latest/#writing-tests) and [cookbook](https://wpacceptance.readthedocs.io/en/latest/cookbook/). ## Contributing We don't know everything! We welcome pull requests and spirited, but respectful, debates. Please contribute via [pull requests on GitHub](https://github.com/10up/theme-scaffold/compare). 1. Fork it! 2. Create your feature branch: `git checkout -b feature/my-new-feature` 3. Commit your changes: `git commit -am 'Added some great feature!'` 4. Push to the branch: `git push origin feature/my-new-feature` 5. Submit a pull request ## Learn more about the default packages used with this project - [10up Eslint config](https://www.npmjs.com/package/@10up/eslint-config) - [10up Stylelint config](https://www.npmjs.com/package/@10up/stylelint-config) - [Babel core](https://www.npmjs.com/package/@babel/core) - [Babel Eslint](https://www.npmjs.com/package/babel-eslint) - [Babel loader](https://www.npmjs.com/package/babel-loader) - [Babel preset env](https://www.npmjs.com/package/@babel/preset-env) - [Babel register](https://www.npmjs.com/package/@babel/register) - [Browsersync](https://browsersync.io/) - [BackstopJS](https://github.com/garris/BackstopJS) - [Can I Use DB](https://www.npmjs.com/package/caniuse-db) - [Clean Webpack plugin](https://www.npmjs.com/package/clean-webpack-plugin) - [Copy Webpack plugin](https://www.npmjs.com/package/copy-webpack-plugin) - [CSS loader](https://www.npmjs.com/package/css-loader) - [CSS nano](https://www.npmjs.com/package/cssnano) - [Eslint](https://www.npmjs.com/package/eslint) - [Eslint loader](https://www.npmjs.com/package/eslint-loader) - [Husky@next](https://www.npmjs.com/package/husky) - [Imagemin plugin for Webpack](https://github.com/Klathmon/imagemin-webpack-plugin) - [Lint Staged](https://www.npmjs.com/package/lint-staged) - [Mini CSS extract plugin](https://www.npmjs.com/package/mini-css-extract-plugin) - [Pa11y](https://www.npmjs.com/package/pa11y) - [PostCSS Import](https://www.npmjs.com/package/postcss-import) - [PostCSS loader](https://www.npmjs.com/package/postcss-loader) - [PostCSS preset-env](https://www.npmjs.com/package/postcss-preset-env) - [Stylelint](https://www.npmjs.com/package/stylelint) - [Stylelint config WordPress](https://www.npmjs.com/package/stylelint-config-wordpress) - [Stylelint declaration use variable](https://www.npmjs.com/package/stylelint-declaration-use-variable) - [Stylelint order](https://www.npmjs.com/package/stylelint-order) - [Stylelint Webpack plugin](https://www.npmjs.com/package/stylelint-webpack-plugin) - [Terser](https://www.npmjs.com/package/terser) - [Webpack](https://www.npmjs.com/package/webpack) - [Webpack CLI](https://www.npmjs.com/package/webpack-cli) - [Webpack fix style only entries](https://www.npmjs.com/package/webpack-fix-style-only-entries) - [Webpack merge](https://www.npmjs.com/package/webpack-merge) - [Webpackbar](https://www.npmjs.com/package/webpackbar) - [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) ## Support Level **Active:** 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome. ## Like what you see? Work with 10up, we create amazing websites and tools that make content management simple and fun using open source tools and platforms ================================================ FILE: assets/css/admin/admin-style.css ================================================ /** * TenUpScaffold - Admin Styles * https://project-website.tld * */ /** * Gutenberg blocks admin styles: * if block editor styles differ from front-end block styles, * create new partials here as needed */ @import url("example-block-1.css"); /* @import url("example-block-2.css"); */ /* @import url("example-block-3.css"); */ ================================================ FILE: assets/css/admin/example-block-1.css ================================================ /* empty file */ ================================================ FILE: assets/css/blocks/example-block-1.css ================================================ /** * TenUpScaffold: Gutenberg Blocks Styles * https://project-website.tld * */ /** * Example block 1 front end styles */ ================================================ FILE: assets/css/blocks/index.css ================================================ /** * TenUpScaffold: Gutenberg Blocks Styles * https://project-website.tld * */ /** * Gutenberg blocks front-end styles: * create new partials here as needed */ /* @import url("example-block-1.css"); */ /* @import url("example-block-2.css"); */ /* @import url("example-block-3.css"); */ ================================================ FILE: assets/css/frontend/base/index.css ================================================ @import url("prefers-reduced-motion.css"); @import url("wordpress.css"); ================================================ FILE: assets/css/frontend/base/prefers-reduced-motion.css ================================================ /* * Resources on prefers-reduced-motion: * https://webkit.org/blog-files/prefers-reduced-motion/prm.htm * https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion */ @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; } } ================================================ FILE: assets/css/frontend/base/wordpress.css ================================================ /* WordPress generated classes */ .alignleft { float: left; margin-right: 1rem; text-align: left; } .alignright { float: right; margin-left: 1rem; text-align: right; } .aligncenter { clear: both; display: block; margin-left: auto; margin-right: auto; text-align: center; } .wp-caption { max-width: 100%; &.aligncenter { text-align: center; } &.alignright { text-align: right; } } .wp-caption-text { margin: 0; } ================================================ FILE: assets/css/frontend/components/index.css ================================================ /* Components */ ================================================ FILE: assets/css/frontend/editor-style.css ================================================ /** * TenUpScaffold - Editor Styles * https://project-website.tld * * Copyright (c) 2017 10up * Licensed under the MIT license. */ /* Gutenberg blocks */ /* @import url("../blocks/index.css"); */ ================================================ FILE: assets/css/frontend/global/colors.css ================================================ /* * Colors */ :root { --c-black: #000; --c-white: #fff; } ================================================ FILE: assets/css/frontend/global/index.css ================================================ @import url("colors.css"); @import url("media-queries.css"); ================================================ FILE: assets/css/frontend/global/media-queries.css ================================================ /* * Media Queries */ @custom-media --bp-tiny ( min-width: 25em ); /* 400px */ @custom-media --bp-small ( min-width: 30em ); /* 480px */ @custom-media --bp-medium ( min-width: 48em ); /* 768px */ @custom-media --bp-large ( min-width: 64em ); /* 1024px */ @custom-media --bp-xlarge ( min-width: 80em ); /* 1280px */ @custom-media --bp-xxlarge ( min-width: 90em ); /* 1440px */ /* WP Core Breakpoints (used for the admin bar for example) */ @custom-media --wp-small ( min-width: 600px ); @custom-media --wp-medium-max (max-width: 782px); ================================================ FILE: assets/css/frontend/layout/index.css ================================================ /* Layout */ ================================================ FILE: assets/css/frontend/style.css ================================================ /** * TenUpScaffold * https://project-website.tld * */ /* Resets - installed via NPM */ @import url("normalize.css"); /* Global - global pieces like media queries, mixins and placholders */ @import url("global/index.css"); /* Base - base styles such as fonts, typography, and wordpress overrides */ @import url("base/index.css"); /* Layout - styles specific to layout */ /* @import url("layout/index.css"); */ /* Templates */ /* @import url("templates/index.css"); */ /* Components */ /* @import url("components/index.css"); */ /* Gutenberg blocks */ /* @import url("../blocks/index.css"); */ ================================================ FILE: assets/css/frontend/templates/index.css ================================================ /* Templates */ ================================================ FILE: assets/css/shared/shared-style.css ================================================ /** * TenUpScaffold: Shared Styles * https://project-website.tld * */ ================================================ FILE: assets/css/styleguide/styleguide.css ================================================ :root { --c-uikit-base: #fff; --c-uikit-accent: #767676; --c-uikit-hightlight: #f6f6f6; --c-uikit-border: #ccc; --c-uikit-primary: #000; @custom-media --bp-uikit-small (min-width: 40.625em); } .uikit__container { padding-left: 20px; padding-right: 20px; } .uikit__heading { border-bottom: 1px solid var(--c-uikit-border); font-size: 56px; font-weight: 400; letter-spacing: 0.055em; margin: 100px auto 130px; max-width: 720px; padding: 0; text-align: center; text-transform: uppercase; } .uikit__heading span { background: var(--c-uikit-base); display: inline-block; padding: 0 40px; } .uikit__content { margin: auto; max-width: 960px; } .uikit__block { margin-bottom: -33px; } .uikit__colors { font-family: "Courier New", monospace; list-style: none; margin: 0; overflow: hidden; padding: 0; text-align: center; } .uikit__color { align-items: center; border: 1px solid var(--c-uikit-border); display: flex; float: left; font-size: 0.85em; height: 90px; justify-content: center; margin-bottom: 32px; margin-right: 32px; width: 90px; } .uikit__color--label { color: var(--c-primary); left: -999em; margin: 0; padding: 0; position: absolute; } .uikit__color--label.light { color: var(--c-uikit-base); } .uikit__icons { text-align: center; } .uikit__icon { align-items: center; background: var(--c-uikit-hightlight); display: flex; float: left; height: 62px; justify-content: center; margin-bottom: 32px; margin-right: 32px; width: 62px; } .uikit__icon--label { left: -999em; position: absolute; } .uikit__section > .heading { box-sizing: border-box; color: var(--c-uikit-accent); display: inline-block; font-size: 14px; font-weight: 400; margin: 0; padding: 0 40px 20px 0; vertical-align: top; width: 100%; } .uikit__section > .heading > .toggle { background-color: transparent; border: 0; color: inherit; cursor: pointer; font-size: inherit; font-weight: inherit; overflow: hidden; padding: 0 18px 0 0; position: relative; } .uikit__chevron-up, .uikit__chevron-down { fill: currentColor; position: absolute; right: 0; top: 50%; transform: translate(0, -50%); } .uikit__chevron-up { display: none; } .uikit__section > .heading > .toggle[aria-expanded="true"] .uikit__chevron-up, .uikit__chevron-down { display: block; } .uikit__section > .heading > .toggle[aria-expanded="true"] .uikit__chevron-down { display: none; } .uikit__section > .content { box-sizing: border-box; display: inline-block; margin-bottom: 100px; vertical-align: top; width: 100%; } .uikit__section > .content[hidden] { display: none; } .uikit-mb-1 { margin-bottom: 1em; } @media (--bp-uikit-small) { .uikit__section > .heading { width: 145px; } .uikit__section.-secondary > .heading { width: 100%; } .uikit__section > .content { width: calc(100% - 150px); } .uikit__section.-secondary > .content { width: 100%; } } ================================================ FILE: assets/fonts/font-name/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: assets/images/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: assets/js/admin/admin.js ================================================ // import foo from './bar' ================================================ FILE: assets/js/blocks/blocks.js ================================================ /** * Gutenberg block-specific JavaScript: * used on front-end and/or in editor */ // import example-block-1 from './example-block-1'; ================================================ FILE: assets/js/blocks/example-block-1.js ================================================ /** * Gutenberg block-specific JavaScript: * used on front-end and/or in editor */ /** * Block 1 JavaScript */ ================================================ FILE: assets/js/frontend/components/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: assets/js/frontend/frontend.js ================================================ // import foo from './components/bar'; ================================================ FILE: assets/js/shared/shared.js ================================================ // import foo from './bar' ================================================ FILE: assets/js/styleguide/styleguide.js ================================================ import UIKitSection from './uikitsection'; const uiKitSection = new UIKitSection(document.querySelectorAll('.uikit__section h2.heading')); uiKitSection.init(); ================================================ FILE: assets/js/styleguide/uikitsection.js ================================================ /** * @module UIKitSection * * @description * * Collapsible UI kit sections * */ export default class UIKitSection { /** * Initialize everything * * @param {Element[]} elements Section Heading elements. */ constructor(elements) { // Grab all the UI kit section headings this.sectionHeadings = elements; } /** * Inits UI Kit Section */ init() { // Stop if there's no section heading if (!this.sectionHeadings) { console.error( 'Styleguide: No sections detected.' ); // eslint-disable-line return; } this.sectionHeadings.forEach((sectionHeading) => { this.setupCollapsible(sectionHeading); }); } /** * Create a button, add chevron SVG and inject in heading * Hide section content, set ARIA attributes * * @param {Element} sectionHeading The UI Kit section heading * */ setupCollapsible(sectionHeading) { // Get section ID const sectionID = sectionHeading.parentNode.id; // Default state let expanded = true; // Check localStorage to see if we want to expand some sections by default if (localStorage) { // Override expanded state expanded = localStorage.getItem(`section-${sectionID}`) !== 'true' || false; } // Build the button, add the SVG chevron icons // eslint-disable-next-line no-param-reassign sectionHeading.innerHTML = ` `; // Get the section content and hide it const wrapper = sectionHeading.parentNode.querySelector('.content'); wrapper.hidden = expanded; wrapper.setAttribute('aria-hidden', expanded); wrapper.setAttribute('aria-labelledby', `toggle-${sectionID}`); // Assign click event to the button const button = sectionHeading.querySelector('button'); button.onclick = (e) => this.toggleCollapsible(e, wrapper, button); } /** * Toggles a section * * @param {Object} e The click event * @param {Element} wrapper The UI Kit section content * @param {Element} button The UI Kit section toggle button * */ toggleCollapsible(e, wrapper, button) { // Expanded state as bool const expanded = button.getAttribute('aria-expanded') === 'true' || false; // Toggle expanded state and visibility button.setAttribute('aria-expanded', !expanded); // eslint-disable-next-line no-param-reassign wrapper.hidden = expanded; wrapper.setAttribute('aria-hidden', expanded); // Store expanded state in localStorage const sectionID = wrapper.parentNode.id; if (localStorage) { localStorage.setItem(`section-${sectionID}`, !expanded); } } } ================================================ FILE: assets/svg/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: babel.config.js ================================================ /** * Babel Config, .babelrc equivalent. * * @package * @type {{presets: [[]|string|Object]}} */ module.exports = { presets: [ [ '@10up/babel-preset-default', { wordpress: true, }, ], ], }; ================================================ FILE: composer.json ================================================ { "name": "10up/tenup-scaffold", "type": "wordpress-theme", "authors": [ { "name": "10up", "email": "info@10up.com" } ], "require": { "php": ">=7.0" }, "autoload": { "psr-4": { "TenUpScaffold\\": "includes/classes/" } }, "minimum-stability": "dev", "prefer-stable": true, "require-dev": { "10up/wpacceptance": "dev-master", "10up/phpcs-composer": "dev-master" }, "scripts": { "lint": "phpcs .", "lint-fix": "phpcbf ." } } ================================================ FILE: config/webpack.config.common.js ================================================ const path = require('path'); const { CleanWebpackPlugin } = require('clean-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const StyleLintPlugin = require('stylelint-webpack-plugin'); const WebpackBar = require('webpackbar'); const ImageminPlugin = require('imagemin-webpack-plugin').default; const isProduction = process.env.NODE_ENV === 'production'; // Config files. const settings = require('./webpack.settings.js'); /** * Configure entries. * * @return {Object[]} Array of webpack settings. */ const configureEntries = () => { const entries = {}; for (const [key, value] of Object.entries(settings.entries)) { entries[key] = path.resolve(process.cwd(), value); } return entries; }; module.exports = { entry: configureEntries(), output: { path: path.resolve(process.cwd(), settings.paths.dist.base), filename: settings.filename.js, /** * If multiple webpack runtimes (from different compilations) are used on the same webpage, * there is a risk of conflicts of on-demand chunks in the global namespace. * * @see (@link https://webpack.js.org/configuration/output/#outputjsonpfunction) */ jsonpFunction: '__TenUpScaffold_webpackJsonp', }, // Console stats output. // @link https://webpack.js.org/configuration/stats/#stats stats: settings.stats, // External objects. externals: { jquery: 'jQuery', lodash: 'lodash', }, // Performance settings. performance: { maxAssetSize: settings.performance.maxAssetSize, }, // Build rules to handle asset files. module: { rules: [ // Lint JS. { test: /\.js$/, enforce: 'pre', loader: 'eslint-loader', options: { fix: true, }, }, // Scripts. { test: /\.js$/, exclude: /node_modules(?!\/@10up)/, use: [ { loader: 'babel-loader', options: { cacheDirectory: true, sourceMap: !isProduction, }, }, ], }, // Styles. { test: /\.css$/, include: path.resolve(process.cwd(), settings.paths.src.css), use: [ { loader: MiniCssExtractPlugin.loader, }, { loader: 'css-loader', options: { sourceMap: !isProduction, // We copy fonts etc. using CopyWebpackPlugin. url: false, }, }, { loader: 'postcss-loader', options: { sourceMap: !isProduction, }, }, ], }, ], }, plugins: [ // Remove the extra JS files Webpack creates for CSS entries. // This should be fixed in Webpack 5. new FixStyleOnlyEntriesPlugin({ silent: true, }), // Clean the `dist` folder on build. new CleanWebpackPlugin({ cleanStaleWebpackAssets: false, }), // Extract CSS into individual files. new MiniCssExtractPlugin({ filename: settings.filename.css, chunkFilename: '[id].css', }), // Copy static assets to the `dist` folder. new CopyWebpackPlugin([ { from: settings.copyWebpackConfig.from, to: settings.copyWebpackConfig.to, context: path.resolve(process.cwd(), settings.paths.src.base), }, ]), // Compress images // Must happen after CopyWebpackPlugin new ImageminPlugin({ disable: !isProduction, test: settings.ImageminPlugin.test, }), // Lint CSS. new StyleLintPlugin({ context: path.resolve(process.cwd(), settings.paths.src.css), files: '**/*.css', }), // Fancy WebpackBar. new WebpackBar(), ], }; ================================================ FILE: config/webpack.config.dev.js ================================================ const merge = require('webpack-merge'); const BrowserSyncPlugin = require('browser-sync-webpack-plugin'); const common = require('./webpack.config.common.js'); // Config files. const settings = require('./webpack.settings.js'); module.exports = merge(common, { mode: 'development', devtool: 'inline-cheap-module-source-map', plugins: [ // Run BrowserSync. new BrowserSyncPlugin( { host: settings.BrowserSyncConfig.host, port: settings.BrowserSyncConfig.port, proxy: settings.BrowserSyncConfig.proxy, open: settings.BrowserSyncConfig.open, files: settings.BrowserSyncConfig.files, }, { injectCss: true, reload: false, }, ), ], }); ================================================ FILE: config/webpack.config.prod.js ================================================ const merge = require('webpack-merge'); const TerserPlugin = require('terser-webpack-plugin'); // eslint-disable-line import/no-extraneous-dependencies const common = require('./webpack.config.common.js'); module.exports = merge(common, { mode: 'production', optimization: { minimizer: [ new TerserPlugin({ cache: true, parallel: true, sourceMap: false, terserOptions: { parse: { // We want terser to parse ecma 8 code. However, we don't want it // to apply any minfication steps that turns valid ecma 5 code // into invalid ecma 5 code. This is why the 'compress' and 'output' // sections only apply transformations that are ecma 5 safe // https://github.com/facebook/create-react-app/pull/4234 ecma: 8, }, compress: { ecma: 5, warnings: false, // Disabled because of an issue with Uglify breaking seemingly valid code: // https://github.com/facebook/create-react-app/issues/2376 // Pending further investigation: // https://github.com/mishoo/UglifyJS2/issues/2011 comparisons: false, // Disabled because of an issue with Terser breaking valid code: // https://github.com/facebook/create-react-app/issues/5250 // Pending futher investigation: // https://github.com/terser-js/terser/issues/120 inline: 2, }, output: { ecma: 5, comments: false, }, ie8: false, }, }), ], }, }); ================================================ FILE: config/webpack.settings.js ================================================ // Webpack settings exports. module.exports = { entries: { // JS files. admin: './assets/js/admin/admin.js', blocks: './assets/js/blocks/blocks.js', frontend: './assets/js/frontend/frontend.js', shared: './assets/js/shared/shared.js', styleguide: './assets/js/styleguide/styleguide.js', 'blocks-editor': './includes/blocks/blocks-editor.js', // CSS files. 'admin-style': './assets/css/admin/admin-style.css', 'editor-style': './assets/css/frontend/editor-style.css', 'shared-style': './assets/css/shared/shared-style.css', style: './assets/css/frontend/style.css', 'styleguide-style': './assets/css/styleguide/styleguide.css', }, filename: { js: 'js/[name].js', css: 'css/[name].css', }, paths: { src: { base: './assets/', css: './assets/css/', js: './assets/js/', }, dist: { base: './dist/', clean: ['./images', './css', './js'], }, }, stats: { // Copied from `'minimal'`. all: false, errors: true, maxModules: 0, modules: true, warnings: true, // Our additional options. assets: true, errorDetails: true, excludeAssets: /\.(jpe?g|png|gif|svg|woff|woff2)$/i, moduleTrace: true, performance: true, }, copyWebpackConfig: { from: '**/*.{jpg,jpeg,png,gif,svg,eot,ttf,woff,woff2}', to: '[path][name].[ext]', }, ImageminPlugin: { test: /\.(jpe?g|png|gif|svg)$/i, }, BrowserSyncConfig: { host: 'localhost', port: 3000, proxy: 'http://tenup-scaffold.test', open: false, files: [ '**/*.php', 'dist/js/**/*.js', 'dist/css/**/*.css', 'dist/svg/**/*.svg', 'dist/images/**/*.{jpg,jpeg,png,gif}', 'dist/fonts/**/*.{eot,ttf,woff,woff2,svg}', ], }, performance: { maxAssetSize: 100000, }, manifestConfig: { basePath: '', }, }; ================================================ FILE: footer.php ================================================ ================================================ FILE: functions.php ================================================ class="no-js"> >

================================================ FILE: includes/blocks/blocks-editor.js ================================================ /** * Gutenberg block-specific JavaScript: * used in editor only */ // import './example-block-1'; ================================================ FILE: includes/blocks/example-block-1/index.js ================================================ /** * Example-block-1 * Custom title block -- feel free to delete */ const { __ } = wp.i18n; const { registerBlockType } = wp.blocks; const { TextControl } = wp.components; /** * Register block */ export default registerBlockType( 'tenup/example-block', { title: __( 'My first block', 'tenup-scaffold' ), description: __( 'My first block description', 'tenup-scaffold' ), icon: 'smiley', category: 'tenup-scaffold-blocks', keywords: [ __( 'example', 'tenup-scaffold' ), ], attributes: { customTitle: { type: 'string' }, }, /** * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit */ edit: props => { const { attributes: { customTitle }, className, setAttributes, isSelected } = props; if ( isSelected ) { return (
setAttributes( { customTitle } ) } />
); } else { return (

{ customTitle }

); } }, /** * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save */ save: props => { const { customTitle } = props.attributes; return (

{ customTitle }

); }, }, ); ================================================ FILE: includes/blocks.php ================================================ post_type, array( 'post', 'page' ), true ) ) { return $categories; } return array_merge( $categories, array( array( 'slug' => 'tenup-scaffold-blocks', 'title' => __( 'Custom Blocks', 'tenup-scaffold' ), ), ) ); } ================================================ FILE: includes/classes/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: includes/core.php ================================================ esc_html__( 'Primary Menu', 'tenup-scaffold' ), ) ); } /** * Enqueue scripts for front-end. * * @return void */ function scripts() { wp_enqueue_script( 'frontend', TENUP_SCAFFOLD_TEMPLATE_URL . '/dist/js/frontend.js', [], TENUP_SCAFFOLD_VERSION, true ); if ( is_page_template( 'templates/page-styleguide.php' ) ) { wp_enqueue_script( 'styleguide', TENUP_SCAFFOLD_TEMPLATE_URL . '/dist/js/styleguide.js', [], TENUP_SCAFFOLD_VERSION, true ); } } /** * Enqueue styles for front-end. * * @return void */ function styles() { wp_enqueue_style( 'styles', TENUP_SCAFFOLD_TEMPLATE_URL . '/dist/css/style.css', [], TENUP_SCAFFOLD_VERSION ); if ( is_page_template( 'templates/page-styleguide.php' ) ) { wp_enqueue_style( 'styleguide', TENUP_SCAFFOLD_TEMPLATE_URL . '/dist/css/styleguide-style.css', [], TENUP_SCAFFOLD_VERSION ); } } /** * Handles JavaScript detection. * * Adds a `js` class to the root `` element when JavaScript is detected. * * @return void */ function js_detection() { echo "\n"; } /** * Add async/defer attributes to enqueued scripts that have the specified script_execution flag. * * @link https://core.trac.wordpress.org/ticket/12009 * @param string $tag The script tag. * @param string $handle The script handle. * @return string */ function script_loader_tag( $tag, $handle ) { $script_execution = wp_scripts()->get_data( $handle, 'script_execution' ); if ( ! $script_execution ) { return $tag; } if ( 'async' !== $script_execution && 'defer' !== $script_execution ) { return $tag; } // Abort adding async/defer for scripts that have this script as a dependency. _doing_it_wrong()? foreach ( wp_scripts()->registered as $script ) { if ( in_array( $handle, $script->deps, true ) ) { return $tag; } } // Add the attribute if it hasn't already been added. if ( ! preg_match( ":\s$script_execution(=|>|\s):", $tag ) ) { $tag = preg_replace( ':(?=>):', " $script_execution", $tag, 1 ); } return $tag; } /** * Asynchronous stylesheet definitions * * Determines which stylesheets should behave * asynchronously on the page by storing their * unique handle in an array. * * @return array */ function get_known_handles() { return array( 'admin-bar', 'dashicons', 'styles', 'styleguide', 'wp-block-library' ); } /** * Add async/defer attributes to enqueued scripts that have the specified script_execution flag. * * @link https://developer.wordpress.org/reference/hooks/style_loader_tag/ * @param string $html The style html output. * @param string $handle The style handle. * @return string */ function style_loader_tag( $html, $handle ) { // Get previously defined stylesheets. $known_handles = get_known_handles(); // Loop over stylesheets and replace media attribute foreach ( $known_handles as $known_style ) { if ( $known_style === $handle ) { $print_html = str_replace( "media='all'", "media='print' onload=\"this.media='all'\"", $html ); } } if ( ! empty( $print_html ) ) { $html = $print_html . ''; } return $html; } /** * Appends a link tag used to add a manifest.json to the head * * @return void */ function add_manifest() { echo ""; } ================================================ FILE: includes/overrides.php ================================================

\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" "_n_noop:1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;" "esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" "X-Poedit-Basepath: .\n" "X-Poedit-SearchPath-0: ..\n" ================================================ FILE: manifest.json ================================================ { "name": "10up Scaffold", "short_name": "10up Scaffold", "description": "Project description for 10up Scaffold", "display": "standalone", "start_url": "/?utm_source=app", "background_color": "#232323", "orientation": "any", "theme_color": "#d23226", "icons": [ { "src": "dist/images/icon-512.png", "sizes": "512x512", "type": "image/png" }, { "src": "dist/images/icon-192.png", "sizes": "192x192", "type": "image/png" }, { "src": "dist/images/icon-128.png", "sizes": "128x128", "type": "image/png" } ] } ================================================ FILE: package.json ================================================ { "name": "tenup-scaffold", "version": "1.0.0", "description": "Project Description", "homepage": "https://project-domain.tld", "repository": { "type": "git", "url": "https://project-git-repo.tld" }, "author": { "name": "10up", "email": "info@10up.com", "url": "https://10up.com", "role": "developer" }, "scripts": { "start": "composer install --ignore-platform-reqs && npm install && npm run build", "build": "cross-env NODE_ENV=production webpack --config config/webpack.config.prod.js", "dev": "cross-env NODE_ENV=development webpack --config config/webpack.config.dev.js", "watch": "cross-env NODE_ENV=development webpack --watch --config config/webpack.config.dev.js", "build-release": "npm install && composer install --no-dev -o && npm run build", "lint-release": "npm install && composer install && npm run lint", "lint-css": "stylelint assets/css", "lint-js": "eslint assets/js", "lint-php": "composer run lint", "format-js": "eslint --fix assets/js", "lint": "npm run lint-css && npm run lint-js && npm run lint-php", "format": "npm run format-js", "test:a11y": "node tests/accessibility/compliance/pa11y.js" }, "husky": { "hooks": { "pre-commit": "lint-staged" } }, "lint-staged": { "*.css": [ "stylelint" ], "*.js": [ "eslint" ], "*.php": [ "./vendor/bin/phpcs --extensions=php --warning-severity=8 -s" ] }, "license": "MIT", "devDependencies": { "@10up/babel-preset-default": "^1.0.0", "@10up/eslint-config": "^2.0.0", "@10up/stylelint-config": "^1.0.9", "@babel/core": "^7.9.0", "@wordpress/eslint-plugin": "^5.0.1", "babel-eslint": "^10.0.3", "babel-loader": "^8.0.6", "backstopjs": "^4.4", "browser-sync": "^2.26.7", "browser-sync-webpack-plugin": "^2.2.2", "browserslist": "^4.8.2", "caniuse-db": "^1.0.30001016", "clean-webpack-plugin": "^3.0.0", "copy-webpack-plugin": "^5.1.1", "core-js": "^3.6.0", "cross-env": "^5.2.0", "css-loader": "^3.4.0", "cssnano": "^4.1.10", "eslint": "^6.8.0", "eslint-config-airbnb": "^18.1.0", "eslint-config-airbnb-base": "^14.1.0", "eslint-config-prettier": "^6.10.1", "eslint-loader": "^3.0.3", "eslint-plugin-import": "^2.20.2", "eslint-plugin-jsdoc": "^22.1.0", "eslint-plugin-jsx-a11y": "^6.2.3", "eslint-plugin-prettier": "^3.1.2", "eslint-plugin-react": "^7.19.0", "eslint-plugin-react-hooks": "^2.5.0", "husky": "^3.1.0", "imagemin-webpack-plugin": "^2.4.2", "lint-staged": "^9.5.0", "mini-css-extract-plugin": "^0.9.0", "pa11y": "^5.3.0", "postcss-editor-styles": "^0.3.0", "postcss-import": "^12.0.1", "postcss-loader": "^3.0.0", "postcss-preset-env": "^6.7.0", "prettier": "^2.0.4", "stylelint": "^9.10.1", "stylelint-config-wordpress": "^14.0.0", "stylelint-declaration-use-variable": "^1.7.2", "stylelint-order": "^2.2.1", "stylelint-webpack-plugin": "^1.1.2", "terser": "^4.4.3", "webpack": "^4.41.4", "webpack-cli": "^3.3.10", "webpack-fix-style-only-entries": "^0.4.0", "webpack-merge": "^4.2.2", "webpackbar": "^4.0.0" }, "testing": { "urls": { "homepage": "http://tenup-scaffold.test", "article": "http://tenup-scaffold.test/hello-world", "search-results": "http://tenup-scaffold.test/?s=hello", "local": "http://tenup-scaffold.test" }, "accessibility": { "compliance": "WCAG2AA" } }, "engines": { "node": ">=12.0.0" }, "dependencies": { "normalize.css": "^8.0.1" } } ================================================ FILE: partials/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: phpcs.xml ================================================ 10up PHPCS extended. ================================================ FILE: postcss.config.js ================================================ /** * Exports the PostCSS configuration. * * @return {string} PostCSS options. */ module.exports = ( { file, options, env } ) => ( { /* eslint-disable-line */ plugins: { 'postcss-import': {}, 'postcss-preset-env': { stage: 0, autoprefixer: { grid: true, }, }, // Prefix editor styles with class `editor-styles-wrapper`. 'postcss-editor-styles': file.basename === 'editor-style.css' ? { scopeTo: '.editor-styles-wrapper', ignore: [ ':root', '.edit-post-visual-editor.editor-styles-wrapper', '.wp-toolbar', ], remove: ['html', ':disabled', '[readonly]', '[disabled]'], tags: ['button', 'input', 'label', 'select', 'textarea', 'form'], } : false, // Minify style on production using cssano. cssnano: env === 'production' ? { preset: [ 'default', { autoprefixer: false, calc: { precision: 8, }, convertValues: true, discardComments: { removeAll: true, }, mergeLonghand: false, zindex: false, }, ], } : false, }, }); ================================================ FILE: search.php ================================================

' . esc_html( get_search_query() ) . '' ); ?>

================================================ FILE: style.css ================================================ /** * Theme Name: 10up Scaffold * Theme URI: https://10up.com * Description: Project description. * Author: 10up * Author URI: https://10up.com * Version: 0.1.0 * Tags: * Text Domain: tenup-scaffold */ ================================================ FILE: templates/page-styleguide.php ================================================

Primary Palette

Headings

H1, Heading 1 {64px}

H2, Heading 2 {48px}

H3, Heading 3 {38px}

H4, Heading 4 {30px}

H5, Heading 5 {26px}

Body

22pt, Acta Book, line 36 ( 1.5rem ). Lorem ipsum dolor sit amet, consectetur adipiscing elit. Multa sunt dicta ab antiquis de contemnendis ac despiciendis rebus humanis; Hoc mihi cum tuo fratre convenit. Fortasse id optimum, sed ubi illud: Plus semper voluptatis? Haec quo modo conveniant, non sane intellego. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Multa sunt dicta ab antiquis de contemnendis ac despiciendis rebus humanis; Hoc mihi cum tuo fratre convenit. Fortasse id optimum, sed ubi illud: Plus semper voluptatis? Haec quo modo conveniant, non sane intellego.

This is an inline link text example and hover link example.

Buttons

Inputs

Checkbox Field Grouping
Radio Button Field Grouping

Lists

  • Morbi natoque habitasse
  • Magnis ullamcorper risus taciti
    • Justo metus turpis habitant nisl
    • Platea primis semper
  • Nibh id natoque elementum
  1. Morbi natoque habitasse
  2. Magnis ullamcorper risus taciti
    1. Justo metus turpis habitant nisl
    2. Platea primis semper
  3. Nibh id natoque elementum

Tables

Egestas duis tincidunt cum
ID Item Purchase Date Price
Sum $15.55
1 Stick of gum 02/13/15 $0.19
2 Toothbrush 11/03/14 $2.37
3 Umbrella 05/12/17 $12.99
================================================ FILE: tests/accessibility/compliance/pa11y.js ================================================ /* global require, process */ 'use strict'; const pa11y = require( 'pa11y' ); const chalk = require( 'chalk' ); const packageJson = require( '../../../package.json' ); const testingUrls = packageJson.testing.urls; // Initialize variables let url; let key; // Loop through all the URLs and set the test destination if ( process.argv[2] ) { for ( key in testingUrls ) { if ( key === process.argv[2] ) { // Set the testing URL if ( packageJson.testing.urls[key] !== '' ) { url = packageJson.testing.urls[key]; } else { // If the URL object exists, but is empty console.log( chalk.red.bold( '✘ Error: Please add a URL for ' + key ) ); console.log( '' ); process.exit( 1 ); } } } // for() } else { url = packageJson.testing.urls.local; } // Set up the pa11y config options const config = { standard: packageJson.testing.accessibility.compliance, hideElements: '#wpadminbar', includeWarnings: true, rootElement: 'body', threshold: 2, timeout: 20000, userAgent: 'pa11y', width: 1280, ignore: [ 'notice' ], log: { debug: console.log.bind( console ), error: console.error.bind( console ), info: console.log.bind( console ) }, chromeLaunchConfig: { ignoreHTTPSErrors: true } }; /** * Run Accessibility Test * @param {string} url test URL * @param {object} config test configuration option * @param {Function} [cb] Callback * @returns {object} test results */ pa11y( url, config, ( error, results ) => { if( error ) { return console.error( error ); } else if ( results.issues.length ) { console.log( results ); } else { console.log( chalk.green.bold( '✔ All accessibility tests have passed.' ) ); } } ); ================================================ FILE: tests/js/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: tests/php/.gitkeep ================================================ # Basically just want to ignore the directory contents ================================================ FILE: tests/wpa/FrontendTest.php ================================================ openBrowserPage(); $I->moveTo( '/' ); // Test stylesheet is enqueued. try { $element = $I->getElement( 'link#styles-css[rel="stylesheet"]' ); } catch ( ElementNotFound $e ) { // If the stylesheet doesn't exist, we catch the exception and fail the test. $this->assertTrue( false ); } $this->assertNotEmpty( $element ); } /** * @testdox The frontend javascript file is properly enqueued. */ public function testJavascriptEnqueued() { $I = $this->openBrowserPage(); $I->moveTo( '/' ); // Test frontend.js is enqueued. try { $element = $I->getElement( 'script[src*="frontend.js"' ); } catch ( ElementNotFound $e ) { // If the script doesn't exist, we catch the exception and fail the test. $this->assertTrue( false ); } $this->assertNotEmpty( $element ); } /** * @testdox Feed links are present. */ public function testAutomaticFeedLinks() { $I = $this->openBrowserPage(); $I->moveTo( '/' ); // Test feed link is present. try { $element = $I->getElement( 'link[type="application/rss+xml"' ); } catch ( ElementNotFound $e ) { // If the feed doesn't exist, we catch the exception and fail the test. $this->assertTrue( false ); } $this->assertNotEmpty( $element ); } /** * @testdox The body class is dynamic. */ public function testBodyClass() { $I = $this->openBrowserPage(); $I->moveTo( '/' ); $this->assertEquals( 'home blog', $I->getElementAttribute( 'body', 'class' ) ); } } ================================================ FILE: tests/wpa/StandardTest.php ================================================