Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / class-msn-news.php
Created July 30, 2024 20:02
Custom WP feed for MSN News
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
/**
* Add MSN News feed.
* Flush permalinks after adding this feed.
*
* @return void
@JiveDig
JiveDig / shared-counts-custom-services.php
Last active May 28, 2024 14:07
Adds Reddit, Threads, and WhatsApp as available options for Shared Counts plugin. Uses https://wordpress.org/plugins/shared-counts/.
<?php
/**
* Add Shared Count services.
*
* @uses https://wordpress.org/plugins/shared-counts/
* @link https://sharedcountsplugin.com/documentation/filters/
* @link https://gist.github.com/JiveDig/dd2bc4a8285136884733d584e91ba7e3
*
* @param array $services Available services.
@JiveDig
JiveDig / class-woocommerce-product-taxonomy-import-export.php
Last active October 5, 2024 13:55
WooCommerce Product Taxonomy Import/Export. Makes it easy to add custom taxonomies to built in WooCommerce import/export feature.
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
/**
* The main plugin class.
*
* @version 0.1.0
*
@JiveDig
JiveDig / class-woocommerce-account-tab.php
Last active July 4, 2024 03:15
A PHP class to create new WooCommerce account tabs.
<?php
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'Mai_WooCommerce_Account_Tab' ) ):
/**
* A class to create new WooCommerce account tabs.
*
* @version 0.1.0
@JiveDig
JiveDig / class-cli-sitemap-importer.php
Created April 18, 2024 15:35
A PHP class for WordPress to import posts (or pages, cpt) as basic HTML, including importing images from content.
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
/**
* WP-CLI to delete all content.
*
wp post delete $(wp post list --post_type=post --format=ids) --force
wp post delete $(wp post list --post_type=page --format=ids) --force
@JiveDig
JiveDig / class-user-role-base.php
Last active May 30, 2024 14:06
A PHP class for WordPress that allows you to change the author base by user role.
<?php
// Prevent direct file access.
defined( 'ABSPATH' ) || die;
if ( ! class_exists( 'Mai_User_Role_Base' ) ):
/**
* The User Role Base class.
*
* @version 0.2.0
@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.
@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.
<?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.
<?php
/**
* Dump the data.
*/
add_action( 'wp_footer', function() {
// Get the data.
$parsed = jivedig_get_parsed_blocks_for_template();
// Dump however you'd like.
<!-- 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"