This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'body_class', 'custom_body_classes' ); | |
function custom_body_classes( $classes ) { | |
$post = get_post(); | |
if ( ! is_null( $post ) ) { | |
if ( has_blocks( $post->post_content ) ) { | |
$blocks = parse_blocks( $post->post_content ); | |
$first_block_attrs = $blocks[0]['attrs']; | |
$custom_classes = array(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Web Assembler - FPDF Tutorial | |
* Description: A plugin created to demonstrate how to build a PDF document from WordPress posts. | |
* Version: 0.1 | |
* Author: Web Assembler | |
* Author URI: https://www.webassembler.co.uk/ | |
*/ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Here is some custom code for the WordPress Edingburgh Hooks Talk titled | |
* "An introduction to WordPress Hooks". This demo uses the wordpress | |
* twentytwentythree theme. | |
* | |
* To use, drop this functions.php file within the theme. | |
* | |
* @package webassembler |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script is run from Sites folder | |
echo "Ensure project is run from Sites folder." | |
read -p 'New project directory: ' projectName | |
# Create the directory | |
echo "Creating directory" | |
mkdir $projectName | |
# Set up Valet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add private/draft/future/pending pages to parent dropdown when setting | |
* page parent in the Page Attributes/Quick Editor | |
* | |
* @since 3.3.0 | |
* | |
* @see wp_dropdown_pages() | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Theme folder installed at wp-content/themes/mytheme/assets/ | |
// Folder hierarchy as follows: | |
// assets | |
// -- js | |
// ---- admin.js | |
// ---- public.js | |
// -- scss | |
// ---- main.scss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The following snippets allow you to custom-sort the Product Attributes Labels (i.e Attribute Taxonomy) in the table inside Products > Attributes. | |
* WooCommerce allows you to sort the terms of the Attribute but not the order of the Attributes themselves. | |
* Details on this thread: https://wordpress.org/support/topic/sorting-of-product-attributes/ | |
* I have made my own "hack" solution that allows you to do this. You simply add a number followed by an underscore next to the Attribute Label. e.g. 100_My Attribute Name. If you wish to place another value above this you can use any number below 100 e.g. 67_My Other Attribute Name | |
* | |
* The array of values is sorted on this number and removed from displaying on the front end and when editing a product. | |
* Please be aware this is work in progress code and shouldn't be used on a live site without lots of testing. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## WP CLI Project Setup | |
# Options documentation here: | |
# https://codex.wordpress.org/User:HEngel/Option_Reference#Reading | |
############## | |
# Instructions | |
############## | |
# 1. If the CLI returns an error "error establishing a database connection", change `localhost` in wp-config.php to `127.0.0.1` |