Skip to content

Instantly share code, notes, and snippets.

View JiveDig's full-sized avatar

Mike Hemberger JiveDig

View GitHub Profile
@JiveDig
JiveDig / class-woocommerce-account-tab.php
Last active April 23, 2024 14:24
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-user-role-base.php
Last active April 18, 2024 20:08
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.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 / acf_front_end_edit.php
Last active September 14, 2023 16:19
ACF front end post editing
<?php
/**
* Check if user is logged in and is post author
* Setup functions for front end post editing
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-post-editing-with-acf-pro/
* @uses Advanced Custom Fields Pro
* @uses Sidr
*/
@JiveDig
JiveDig / login_form_redirect_errors.php
Last active August 3, 2023 15:59
Login form for template. Redirects back to login page with errors on fail
//* Put these in functions.php
/**
* Description: This redirects the failed login to the custom login page instead of default login page with a modified url
* @link ttp://wordpress.stackexchange.com/questions/110094/custom-login-redirects-to-wp-admin-on-wrong-password
**/
add_action( 'wp_login_failed', 'prefix_front_end_login_fail' );
function prefix_front_end_login_fail( $username ) {
// Getting URL of the login page
@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 / acf_create_posts_acf_form.php
Last active February 28, 2023 06:29
Page template to create posts on the front end via Advanced Custom Fields Pro
<?php
/**
* Template Name: Create Post
*
* @author Mike Hemberger
* @link http://thestizmedia.com/front-end-posting-with-acf-pro/
* @uses Advanced Custom Fields Pro
*/
/**
@JiveDig
JiveDig / remove-tinymce-editor-buttons.php
Last active February 24, 2023 06:00
Remove buttons/items from the WordPress TinyMCE editor
<?php
/**
* Removes buttons from the first row of the tiny mce editor
*
* @link http://thestizmedia.com/remove-buttons-items-wordpress-tinymce-editor/
*
* @param array $buttons The default array of buttons
* @return array The updated array of buttons that exludes some items
*/
add_filter( 'mce_buttons', 'jivedig_remove_tiny_mce_buttons_from_editor');
@JiveDig
JiveDig / functions.php
Last active December 1, 2022 21:24
Get the primary term of a post, by taxonomy. If Yoast Primary Term is used, return it, otherwise fallback to the first term.
<?php
/**
* Gets the primary term of a post, by taxonomy.
* If Yoast Primary Term is used, return it,
* otherwise fallback to the first term.
*
* @version 1.3.0
*
* @link https://gist.github.com/JiveDig/5d1518f370b1605ae9c753f564b20b7f
@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