Skip to content

Instantly share code, notes, and snippets.

View tradesouthwest's full-sized avatar
Working remotely

Larry tradesouthwest

Working remotely
View GitHub Profile
@tradesouthwest
tradesouthwest / wp-plugin-enqueue-dequeue.php
Last active July 2, 2020 23:24
Remove styles via wp_enqueue and wp_dequeue. Bonus at bottom of file to select children of parent category
<?php
/** PB-1
* Remove woo specific styles that are added by this plugin if option checked
* Then re-enqueue when option is not isset (default)
*/
add_action( 'wp_enqueue_scripts', 'unitizr_products_enqueue_woospecific' );
function unitizr_products_enqueue_woospecific()
{
@tradesouthwest
tradesouthwest / dot-htacess
Created July 11, 2019 21:57
htaccess compression best settings
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
$(document).ready(function(){
var maxField = 10; //Input fields increment limitation
var addButton = $('.add_button'); //Add button selector
var wrapper = $('.field_wrapper'); //Input field wrapper
var fieldHTML = '<div><input type="text" name="field_name[]" value=""/><a href="javascript:void(0);" class="remove_button"><img src="remove-icon.png"/></a></div>'; //New input field html
var x = 1; //Initial field counter is 1
//Once add button is clicked
$(addButton).click(function(){
@tradesouthwest
tradesouthwest / user-meta-list.php
Created May 6, 2019 20:12
Shortcode to print all user meta on a wordpress page.
<?php
/**
* Get list of all user meta
* @package WordPress
* @uses shortcode [bnsw_userprint="user_id"] Or whatever name you register
*/
function bnswfields_user_list_meta($atts)
{
if ( !isset( $atts['user_id'] ) ){
<?php
/**
* This code retrieves course data from an external API and displays it in the user's
* My Account area. A merchant has noticed that there's a delay when loading the page.
*
* 1) What changes would you suggest to reduce or remove that delay?
* 2) Is there any other code changes that you would make?
*/
//improvements
/**
@tradesouthwest
tradesouthwest / php-version-stop.php
Created April 1, 2019 16:47
prevents theme activation on a server that's PHP version is below 5.6.
<?php
/**
* Set a constant that holds the theme's minimum supported PHP version.
*/
define( 'THEMESLUG_MIN_PHP_VERSION', '5.6' );
/**
* Immediately after theme switch is fired we we want to check php version and
* revert to previously active theme if version is below our minimum.
@tradesouthwest
tradesouthwest / meta-box-select-dropdown.php
Last active April 1, 2019 00:43
wp select options dropdown for meta box
<?php
/**
* Add meta box to editor
*
* @strings $id, $title, $callback, $screen, $context, $priority, $args
* function's action_added in register cpt
*/
function vertycal_date_time_meta_box()
{
add_meta_box(
@tradesouthwest
tradesouthwest / wp_selected-dropdown.php
Last active April 1, 2019 00:47
wordpress use selected in a dropdown list for custom post type
<?php
/**
* Demonstration uses all cpt posts in a dropdown field to select
* a featured listings to callback in a function
* @param $wpselected_ string References a plugin option Setting.
*/
function wpselected_featured_listing_cb()
{
$post_type = 'wpselected_post';
@tradesouthwest
tradesouthwest / wcmp-remove-qvon-vacation.php
Last active March 26, 2019 21:29
Woocommerce remove quick view button if vendor on vacation.
<?php
/**
* Footer script to remove quick view button if vendor on vacation.
* @param script
* @author Larry Judd | Tradesouthwest
* The first one works the best across all browsers. The other two are for testing against other plugins.
*/
/*
* If you use the .css combinator method add this to CSS stylesheet:
******************************************************************