Skip to content

Instantly share code, notes, and snippets.

@KevinBatdorf
KevinBatdorf / gutenberg-helpers.js
Last active July 13, 2025 09:43
WordPress check Gutenberg editor is ready
import { select, subscribe } from '@wordpress/data'
export function whenEditorIsReady() {
return new Promise((resolve) => {
const unsubscribe = subscribe(() => {
// This will trigger after the initial render blocking, before the window load event
// This seems currently more reliable than using __unstableIsEditorReady
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) {
unsubscribe()
resolve()
@manchumahara
manchumahara / gist:388e64886fe34c280e909346c763bc03
Created December 30, 2019 12:38
display order status list in my orders in woocommerce https://codeboxr/.com
add_action( 'woocommerce_before_account_orders', 'woo_my_orders_display_status' );
function woo_my_orders_display_status( $has_orders = false ) {
//if($has_orders){
$post_status = isset( $_REQUEST['post_status'] ) ? sanitize_text_field( $_REQUEST['post_status'] ) : 'all';
$order_page_url = get_permalink( wc_get_page_id( 'orders' ) );
echo '<div class="clear clearfix"></div>';
@maddisondesigns
maddisondesigns / functions.php
Last active August 5, 2025 09:32
WooCommerce Custom Fields for Simple & Variable Products
/*
* Add our Custom Fields to simple products
*/
function mytheme_woo_add_custom_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Text Field
@AlexGStapleton
AlexGStapleton / example.php
Last active October 23, 2017 17:18
SiteOrigin Page Builder - Process Tablet Padding (read: unuseable as it requires the settings to be added)
<?php
function process_tablet_padding ( $css, $panels_data, $post_id, $layout_data ) {
$settings = siteorigin_panels_setting();
// Check if Tablet Layouts are enabled, and if the tablet width and Mobile Width are correctly setup
if ( $settings[ 'tablet-layout' ] && $settings[ 'tablet-width' ] > $settings[ 'mobile-width' ] ) {
foreach ( $layout_data as $ri => $row ) {
if( empty( $row['cells'] ) ) continue; // Nothing here, move on
// Check if there's tablet padding applied
<?php
$args = array(
'label' => '', // Text in Label
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post meta where id is the meta_key
'id' => '', // required
'name' => '', //name will set from id if empty
@yunusga
yunusga / gist:33cf0ba9e311e12df4046722e93d4123
Created April 5, 2017 11:55
Debug WordPress 404 issues (permalinks, rewrite rules, etc.)
/* Produces a dump on the state of WordPress when a not found error occurs */
/* useful when debugging permalink issues, rewrite rule trouble, place inside functions.php */
ini_set( 'error_reporting', -1 );
ini_set( 'display_errors', 'On' );
echo '<pre>';
add_action( 'parse_request', 'debug_404_rewrite_dump' );
function debug_404_rewrite_dump( &$wp ) {
@igorbenic
igorbenic / add.php
Last active July 7, 2025 10:26
How to Add Custom Fields to WordPress Taxonomies | http://www.ibenic.com/custom-fields-wordpress-taxonomies
<?php
do_action( "{$taxonomy}_add_form_fields", string $taxonomy );
@slfrsn
slfrsn / WordPressUpdatesfromGitHub.md
Last active August 24, 2025 16:00
Automatic WordPress theme updates from a GitHub repository using the native WordPress update system.

WordPress Theme Updates from GitHub

Adding automatic theme updates from a GitHub repository is actually pretty simple. The following function will hook into WordPress's native update system and grab the latest release from the repo of your choosing (if the version number has increased).

Place the following in your functions.php

// Automatic theme updates from the GitHub repository
add_filter('pre_set_site_transient_update_themes', 'automatic_GitHub_updates', 100, 1);
function automatic_GitHub_updates($data) {
@paulallies
paulallies / gist:0052fab554b14bbfa3ef
Last active August 3, 2024 16:45
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin <branch-name>
@DevinWalker
DevinWalker / remove-rev-slider-metabox.php
Created May 14, 2014 20:32
This code removed the Revolution Slider metabox on pages, posts and CTPs
/**
* Remove Rev Slider Metabox
*/
if ( is_admin() ) {
function remove_revolution_slider_meta_boxes() {
remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' );
remove_meta_box( 'mymetabox_revslider_0', 'YOUR_CUSTOM_POST_TYPE', 'normal' );
}