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 / htaccess-for-wp-with-SSL-directives
Created May 9, 2020 00:40
secure wordpress ssl url directive for SSL confidence
# Begin GzipofBreezeWPCache
SetEnv BREEZE_GZIP_ON 1
<IfModule mod_deflate.c>
AddType x-font/woff .woff
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
@tradesouthwest
tradesouthwest / woocommerce-category-limit.php
Last active September 20, 2021 05:28
allow only one category in woocommerce cart plus hide price in a cat
// only allow one category to be purchased at a time
add_filter( 'woocommerce_add_to_cart_validation', 'dietweek_only_one_product_category_allowed', 20, 3 );
function dietweek_only_one_product_category_allowed( $passed, $product_id, $quantity) {
// Getting the product categories term slugs in an array for the current product
$term_slugs = wp_get_post_terms( $product_id, 'product_cat', array('fields' => 'slugs') );
// Loop through cart items
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item ){
@tradesouthwest
tradesouthwest / woocommerce-sql-removeproduct-data.sql
Created March 13, 2020 21:20
woocommerce sql to remove all product data
DELETE relations.*, taxes.*, terms.*
FROM wp_term_relationships AS relations
INNER JOIN wp_term_taxonomy AS taxes
ON relations.term_taxonomy_id=taxes.term_taxonomy_id
INNER JOIN wp_terms AS terms
ON taxes.term_id=terms.term_id
WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type='product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
<?php // push delivery date forward if it is a friday, saturday or sunday.
<section id="sect-1" class="block" style="display:table;">
<article id="artc-2" style="width:48%;min-height:230px;display:block;float:right;background:#f1f7f5">
<h4>Results</h4>
<div><?php print( display_results() ); ?></div>
<?php function display_results()
{
/**
* procedural
<?php
/**
* The header for child-them custom full width page template
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Blossom_Spa
* ********************************************
<?php
/**
* OnePress Child Theme Functions
* And basic parent/child enqueues
*
*/
/**
* Enqueue child theme style
*/
add_action( 'wp_enqueue_scripts', 'onepress_child_enqueue_styles', 15 );
@tradesouthwest
tradesouthwest / gforms-field-validation-date.php
Created November 16, 2019 19:14
Gravity Forms date field validation filters by cutoff date.
<?php // Gravity Forms date field validation
add_filter( 'gform_field_validation_2_10', 'shopguide_gform_validation_2_10', 10, 4 );
function shopguide_gform_validation_2_10( $result, $value, $form, $field )
{
$valid = false;
$day_select = date( 'D', $value );
$date_selected = strtotime( $value );
$now = strtotime( 'now' );
$wed_next = strtotime( 'next Wednesday' );
$this_fri = strtotime( 'next Friday');
@tradesouthwest
tradesouthwest / generate-formatted-url-link.php
Last active October 30, 2019 17:46
Generate a formatted url link from form fields. For WordPress as a shortcode
<?php
/**
* Prevent direct access to the file.
* @subpackage vendors_tmplt/inc/vendors-tmplt-archive-content
* @since 1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
<?php
/**
* Parse HTML for 'checkbox' field
* @input type checkbox
*/
function unitizr_removestyles_field_cb($args)
{
$checked = '';
$options = get_option($args['option_name']);
$value = ( !isset( $options[$args['name']] ) )