Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / woocommerce-permalink-silos.php
Last active July 27, 2023 14:47
Create hierarchical permalink SEO silos for WooCommerce shop/products, product categories, and single product urls.
View woocommerce-permalink-silos.php
@JiveDig
JiveDig / on-demand-block-assets.php
Last active August 31, 2022 20:47
Testing loading block assets (scripts and styles) on demand, before the block markup.
View on-demand-block-assets.php
<?php
add_action( 'enqueue_block_editor_assets', 'mai_enqueue_block_editor_assets' );
/**
* Enqueues block assets for the editor,
* since front-end assets are loaded on-demand.
*
* @since TBD
*
* @return void
@JiveDig
JiveDig / functions.php
Last active August 19, 2022 16:25
Gets a formatted array of block data from post content for use in the `template` parameter of `register_post_type()` function. This is used for a predefined block template for a post type.
View functions.php
<?php
/**
* Dump the data.
*/
add_action( 'wp_footer', function() {
// Get the data.
$parsed = jivedig_get_parsed_blocks_for_template();
// Dump however you'd like.
View mai-exclusive-freelance-homepage.html
<!-- wp:acf/mai-columns {"name":"acf/mai-columns","data":{"columns":"custom","_columns":"mai_columns_columns","arrangement_0_columns":"1/2","_arrangement_0_columns":"mai_columns_arrangement_columns","arrangement":1,"_arrangement":"mai_columns_arrangement","arrangement_md_0_columns":"full","_arrangement_md_0_columns":"mai_columns_md_arrangement_columns","arrangement_md":1,"_arrangement_md":"mai_columns_md_arrangement","arrangement_sm_0_columns":"full","_arrangement_sm_0_columns":"mai_columns_sm_arrangement_columns","arrangement_sm":1,"_arrangement_sm":"mai_columns_sm_arrangement","arrangement_xs_0_columns":"full","_arrangement_xs_0_columns":"mai_columns_xs_arrangement_columns","arrangement_xs":1,"_arrangement_xs":"mai_columns_xs_arrangement","align_columns":"start","_align_columns":"mai_columns_align_columns","align_columns_vertical":"","_align_columns_vertical":"mai_columns_align_columns_vertical","column_gap":"","_column_gap":"mai_columns_column_gap","row_gap":"","_row_gap":"mai_columns_row_gap","margin_top"
@JiveDig
JiveDig / mai-banner-to-page-header.php
Last active January 27, 2022 20:14
Convert Mai Theme v1 banner images to v2 page header images.
View mai-banner-to-page-header.php
<?php
/**
* Migrates post and term meta keys from Mai Theme v1 to v2.
*
* 1. Add this code to functions.php
* 2. Visit the front end of the website ONE time.
* 3. This code will run just by visiting the page.
* 4. Each page view or refresh will make it run again so don't do it more than once.
* 5. Immediate remove this code.
@JiveDig
JiveDig / woocommerce-remove-scripts-styles.php
Last active March 22, 2021 11:15
Remove WooCommerce scripts and styles.
View woocommerce-remove-scripts-styles.php
<?php
/**
* Remove WooCommerce scripts and styles.
*
* Cart fragments are used for things like ajax cart menu icons,
* but it's really slow, so let's only keep them where necessary.
*
* @version 1.3.0
* @author Mike Hemberger @JiveDig
@JiveDig
JiveDig / functions.php
Created August 8, 2019 19:14
Automatically add facet label as a heading before any facets with available options to filter by.
View functions.php
<?php
/**
* Adds facet label as a heading before any facets with available options.
*
* @author Mike Hemberger @JiveDig.
*
* @param string $output The facet HTML.
* @param array $params The shortcode/function parameters.
*
@JiveDig
JiveDig / functions.php
Last active May 20, 2019 17:52
Remove taxonomies that you probably won't need, and take forever to load all the terms in ACF taxonomy field.
View functions.php
<?php
/**
* Remove taxonomies that you probably won't need, and take forever to load all the terms in ACF taxonomy field.
*
* @version 1.0.0
* @author @JiveDig
* @uses Advanced Custom Fields
*
* @param array $taxonomies The existing taxonomies.
@JiveDig
JiveDig / functions.php
Last active May 15, 2019 13:31
Create a direct to cart/checkout/page add to cart button in WooCommerce.
View functions.php
<?php
/**
* Create a direct to cart/checkout/page add to cart button.
*
* Example: [buy_now id="1234" redirect="checkout"]
*
* @version 1.0.0
* @author @JiveDig
* @link https://gist.github.com/JiveDig/6adde04666c189b6089fcfeca4988c47
@JiveDig
JiveDig / functions.php
Created March 28, 2019 14:24
Autocomplete WooCommerce orders that contain only virtual products.
View functions.php
<?php
/**
* Autocomplete orders that contain only virtual products.
* If the order contains a non-virtual product the order will not be completed by this function.
*
* @author Mike Hemberger @JiveDig
*
* @version 1.0.0
*