- Table of contents
- General information
- Terms
- General structure of a test
- WordPress-specific assertions and test functions
- enqueues
- creating posts
- creating terms
- attaching images
- ?
| <?php | |
| /** | |
| * Enqueue block editor JavaScript and CSS | |
| */ | |
| function jsforwpblocks_editor_scripts() { | |
| // Make paths variables so we don't write em twice ;) | |
| $blockPath = '/assets/js/blocks.js'; | |
| $editorStylePath = '/assets/css/blocks.editor.css'; |
| <?php | |
| /** | |
| * Enqueue block editor CSS | |
| */ | |
| function jsforwpblocks_editor_scripts() { | |
| // Make paths variables so we don't write em twice ;) | |
| $editorStylePath = '/assets/css/blocks.editor.css'; |
| const defaultConfig = require( './node_modules/@wordpress/scripts/config/webpack.config.js' ); | |
| const path = require( 'path' ); | |
| const postcssPresetEnv = require( 'postcss-preset-env' ); | |
| const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); | |
| const IgnoreEmitPlugin = require( 'ignore-emit-webpack-plugin' ); | |
| const production = process.env.NODE_ENV === ''; | |
| module.exports = { | |
| ...defaultConfig, |
| <?php | |
| /** | |
| * Register custom rest fields | |
| */ | |
| add_action( 'rest_api_init', 'register_custom_fields' ); | |
| /** | |
| * Register rest fields and endpoint | |
| * |
| <?php | |
| /** | |
| * Recursive function to generate a unique username. | |
| * | |
| * If the username already exists, will add a numerical suffix which will increase until a unique username is found. | |
| * | |
| * @param string $username | |
| * | |
| * @return string The unique username. | |
| */ |
Update: please note that I have since switched to using a set of bash scripts instead of poluting the Git repository with git svn.
Author: Kaspars Dambis
kaspars.net / @konstruktors
| <?php | |
| if ( ! function_exists( 'lets_clear_cache' ) ) { | |
| function lets_clear_cache() { | |
| // WP Rocket | |
| if ( function_exists( 'rocket_clean_domain' ) ) { | |
| rocket_clean_domain(); | |
| } | |
| // W3 Total Cache : w3tc |
To set up php linting, you’ll want to install this PHP CodeSniffer repo and configure with this WordPress Coding Standards repo: . There are a number of ways to do this, whether direct download, Composer, Homebrew, Pear, etc. The following is what works for me on MacOS using Homebrew:
In a terminal window on your Mac, start by updating your Homebrew.
brew doctor
Then install the Code Sniffer: