Skip to content

Instantly share code, notes, and snippets.

View caseymilne's full-sized avatar
🎯
Focusing

Casey Milne caseymilne

🎯
Focusing
View GitHub Profile
@caseymilne
caseymilne / wp_site_object.php
Created July 7, 2021 15:19
WP Site Structure
<?php
/*
* This is the output from a \WP_Site
* WP_Site objects are passed during multisite setup in various hooks including 'wp_insert_site' and 'wp_initialize_site'.
* In a plugin you can use these action hooks to "do stuff when new multisite site is created".
* In Saber Commerce plugin we use 'wp_insert_site' and then take the blog_id and utilize it to setup new directories and database tables for the new site.
*/
C:\Users\Casey\Plugins\sacomA\saber-commerce.php:374:
<?php
// Enqueue Theme CSS.
add_action( 'wp_enqueue_scripts', 'reflex_css' );
function reflex_css() {
wp_enqueue_style(
'reflex-main-style',
get_stylesheet_directory_uri() . '/style.css',
@caseymilne
caseymilne / reflex_config.css
Last active June 23, 2021 17:52
Reflex Theme Config
/*
Theme Name: Reflex
Description: Reflex is a React-powered theme for WordPress.
Author: Casey Milne
Author URI: https://caseymilne.com
Template: reflex
Version: 1.0.0
License: GNU General Public License v3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Text Domain: reflex
@caseymilne
caseymilne / scripts-package-segment.json
Created June 23, 2021 16:01
React package.json WP scripts replacement
"scripts": {
"build": "wp-scripts build",
"check-engines": "wp-scripts check-engines",
"check-licenses": "wp-scripts check-licenses",
"lint:css": "wp-scripts lint-style",
"lint:js": "wp-scripts lint-js",
"lint:pkg-json": "wp-scripts lint-pkg-json",
"start": "wp-scripts start",
"test:e2e": "wp-scripts test-e2e",
"test:unit": "wp-scripts test-unit-js"
@caseymilne
caseymilne / enqueue.php
Last active June 23, 2021 15:46
Enqueue Theme Script with React Dependendy
<?php
// Enqueue Theme JS w React Dependency
add_action( 'wp_enqueue_scripts', 'reflex_js' );
function reflex_js() {
wp_enqueue_script(
'reflex-main-script',
get_stylesheet_directory_uri() . '/build/index.js',
['wp-element'],