Skip to content

Instantly share code, notes, and snippets.

Avatar

Gabe Shackle hereswhatidid

View GitHub Profile
View wp-cli-commands.sh
# list all public taxonomies and the number of entries for each of them
wp taxonomy list --fields=name,label,public,count --public=1
# list all public post types and the number of entries for each of them
wp post-type list --fields=name,label,public,count --public=1
@hereswhatidid
hereswhatidid / yoast-woo-crumbs.php
Last active Feb 14, 2020
Integrate Yoast SEO Primary Categories with WooCommerce breadcrumbs
View yoast-woo-crumbs.php
<?php
add_filter( 'woocommerce_breadcrumb_main_term', 'hwid_breadcrumbs_primary_category' );
/**
* Override the default term for WooCommerce cookies if Yoast SEO is installed
*
* @param WP_Term $term
*
* @return WP_Error|WP_Term|null
@hereswhatidid
hereswhatidid / quotation.css
Created Nov 27, 2019
Wrap text with directional quotes, quotation, quote marks
View quotation.css
.quotation {
&:before {
content: '\201C';
}
&:after {
content: '\201D';
}
}
@hereswhatidid
hereswhatidid / acf-block-preview-action.js
Last active Sep 4, 2019
Example ACF block preview action
View acf-block-preview-action.js
if( window.acf ) {
window.acf.addAction( 'render_block_preview/type=accordion', function( $elem, blockDetails ) {
initializeElement( $elem );
} );
}
@hereswhatidid
hereswhatidid / Settings.php
Created Mar 21, 2019
WooCommerce custom settings page
View Settings.php
<?php
namespace RMG\QuoteBuilder;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'RMG\QuoteBuilder\Settings_Quotes', false ) ) {
return new Settings_Quotes();
@hereswhatidid
hereswhatidid / custom-gut-category.php
Last active Mar 8, 2019
Register custom Gutenberg block category
View custom-gut-category.php
<?php
function new_category( $categories, $post ) {
return array_merge(
$categories,
array(
array(
'slug' => 'custom-category',
'title' => __( 'Custom Category', 'language' ),
),
)
@hereswhatidid
hereswhatidid / bashrc.sh
Last active Feb 18, 2019
Run lighthouse from a bashrc function. ex: "lh https://mynewsite.com"
View bashrc.sh
lh() {
lighthouse "$1" --view --chrome-flags="--headless" --config-path="$HOME/lighthouse-config.js"
}
@hereswhatidid
hereswhatidid / acf-gf-dropdown.php
Last active Jul 22, 2019
Populate ACF drop down with Gravity Forms forms
View acf-gf-dropdown.php
<?php
namespace HWID\ACFGravity;
class ACF_GF_DropDown {
public static function init() {
add_filter( 'acf/load_field/key=FIELDKEY', [ 'HWID\ACFGravity\ACF_GF_DropDown', 'populate_gform_dropdown' ] );
@hereswhatidid
hereswhatidid / woo-product-schema.php
Created Sep 11, 2018
Customize the schema for WooCommerce products
View woo-product-schema.php
<?php
/*
* This class will customize the WooCommerce product schema markup
*/
namespace HWID\Woo;
class CustomizeSchema {
static function init() {
add_filter( 'woocommerce_structured_data_product', [ 'HWID\Woo\CustomizeSchema', 'override_schema_markup' ], 10, 2 );
}
@hereswhatidid
hereswhatidid / disable-yoast-cpt.php
Created Aug 16, 2018
Disable Yoast fields on a custom post type
View disable-yoast-cpt.php
<?php
/*
* This class will disable Yoast SEO fields on the edit screen for a particular post type
*/
namespace HWID\CustomPostType;
class DisableYoast {
static function init() {
// The important aspect of this add_action is to make sure it's set to at least 11 in priority
add_action( 'add_meta_boxes', [ 'HWID\CustomPostType\Expertise', 'remove_yoast' ], 11 );
You can’t perform that action at this time.