Skip to content

Instantly share code, notes, and snippets.

View JayWood's full-sized avatar
:octocat:
Levelling up, one commit at a time.

JayWood

:octocat:
Levelling up, one commit at a time.
View GitHub Profile
@JayWood
JayWood / shortcode-scraper.php
Created September 10, 2018 11:00
A tool to provide reports for short-codes created.
<?php
namespace JW\CLI;
use WP_CLI;
use WP_CLI_Command;
/**
* A shortcode scraper class.
*/
@JayWood
JayWood / resource-pool
Created July 15, 2017 14:53
Resource Pool Template
# This sets up a resource pool for the user.
# By setting up a resource pool you are basically separating server reources between users.
# Author: Jay Wood
# http://github.com/JayWood
[%USER%]
prefix = /home/$pool
user = %USER%
@JayWood
JayWood / class-admin.php
Created November 28, 2016 03:22
My Custom Settings API Implementation for those of us who don't need bloated options panel libraries.
<?php
/**
* WooCommerce Order Generator Admin Options Page
*
* @since NEXT
* @package WooCommerce Order Generator
*/
/**
* WooCommerce Order Generator Admin.
@JayWood
JayWood / finding-registered-post-types.php
Created November 23, 2016 18:58
Finds registered post types from their originating location using debug_backtrace()
function my_registered_type( $post_type ) {
if ( 'shop_order' !== $post_type ) {
return;
}
$backtrace = debug_backtrace();
$iterator = count( $backtrace ) - 1;
if ( $iterator <= 0 ) {
return;
@JayWood
JayWood / jays-fix-serialization.php
Last active March 25, 2017 20:05
This script was inspired by the script from Blogestudio located at https://github.com/Blogestudio/Fix-Serialization. For yearsI used this script to fix serialization, however, just recently I needed to fix a 1GB+ file and the methods in use on the original script was not ideal for reading a large file.Therefore this script was built.
<?php
/**
* Jays Fix Serialization
*
* Fixes serialization in SQL files after replacements are done.
* License: GPL version 3 or later - http://www.gnu.org/licenses/gpl.txt
* By: Jay Wood ( [email protected] )
* http://plugish.com
*
* Usage:
@JayWood
JayWood / local-delivery.php
Created October 24, 2016 17:06
Local delivery filter for translated text
<?php
function fb_lp_to_local_delivery( $translated_text ) {
if ( 'Local Pickup' == $translated_text ) {
$translated_text = 'Local Delivery';
}
}
add_filter( 'gettext', 'fb_lp_to_local_delivery' );
@JayWood
JayWood / widget-to-cpt.php
Created October 21, 2016 20:15
Migrating widgets to a custom post type.
<?php
/**
* Plugin Name: Widget to CPT
* Plugin URI: http://plugish.com
* Description: A simple how-to for migrating widgets to a CPT
* Author: JayWood
* Author URI: http://plugish.com
* Version: 0.1.0
*/
@JayWood
JayWood / widget-to-cpt.php
Last active September 16, 2016 05:19
A class to convert the Zerif Light 'Our Focus' widgets to a CPT
<?php
/**
* Plugin Name: Widget to CPT
* Plugin URI: http://webdevstudios.com
* Description: A simple how-to for migrating widgets to a CPT
* Author: JayWood
* Author URI: http://webdevstudios.com
* Version: 0.1.0
*/
function add_custom_classes( $classes, $class, $post_id ) {
if ( 'product' == get_post_type( $post_id ) ) {
$classes[] = "sm-pid-" . $post_id;
// Post Class on Single Product
if ( is_singular( 'product' ) ) {
$classes[] = "sm-product-view";
// Post Clas Product Archives Listing
} else {
@JayWood
JayWood / wcpc.php
Created September 2, 2016 16:48
Woocommerce Product Singular vs Archive classes
<?php
function fb_1398591523488596( $classes, $class, $post_id ) {
if ( 'product' == get_post_type( $post_id ) ) {
if ( is_singular( 'product' ) ) {
$classes[] = "post-class-when-viewing-single-product";
} else {
$classes[] = "non-single-product-page-class"
}
}