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 / gravity-pdf-conditional.php
Created August 8, 2018 18:18
Gravity Forms PDF generator - hide any items that have a CSS class of "exclude."
<?php
foreach ( $form_data['products'] as $id => $prod ):
if ( strpos( $fields[ $id ]['cssClass'], 'exclude' ) & $year !== false ) {
continue;
}
?>
//I need to be able to write it with and & condition something like this...
<?php foreach ( $form_data['products'] as $id => $prod ):
@tradesouthwest
tradesouthwest / wp-select-settings-field.php
Last active June 19, 2018 19:41
WP dropdown select options field for plugin settings fields
<?php
// d.) settings
add_settings_field(
'woonumday_wndtaxbase_field',
esc_attr__('Tax Options', 'woonumday'),
'woonumday_wndtaxbase_field_cb',
'woonumday_options',
'woonumday_options_section',
array(
'type' => 'select',
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8"><style type="text/css">
table tr td{border-bottom: 1px solid #ccc; }</style>
</head>
<body>
<div class="post-entry entry-content">
<h2>Template Hooks</h2>
<h4>Actions</h4>
@tradesouthwest
tradesouthwest / woo-add-checkbox-register-form.php
Created May 22, 2018 18:40
WooCommerce add checkbox to Registration Form
<?php
/***
SETUP
custom fields
@hook woocommerce_register_form_start
@hook woocommerce_edit_account_form
@hook woocommerce_save_account_detail
@altUse woocommerce_after_order_notes to add to checkout
****/
@tradesouthwest
tradesouthwest / wordness-addons.php
Created February 17, 2018 23:15
Replace WordPress Gravatar Upload
<?php
/**
* Replace default Gravatar with branding logo.
*/
function wordness_new_default_gravatar($avatar_defaults)
{
//be safe default
$def = esc_url( plugin_dir_url( dirname(__FILE__) )
. 'css/poplogin-default-logo.png' );
@tradesouthwest
tradesouthwest / wp-search-filter-ajax.php
Created January 7, 2018 20:32
wordpress filter for searching categories with ajax
<form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter">
<?php
if( $terms = get_terms( 'category', 'orderby=name' ) ) :
echo '<select name="categoryfilter"><option>Select category...</option>';
foreach ( $terms as $term ) :
echo '<option value="' . $term->term_id . '">' . $term->name . '</option>';
endforeach;
echo '</select>';
endif;
@tradesouthwest
tradesouthwest / image-list.php
Created November 20, 2017 17:55
Visible file in images folder
<?php
session_start();
if (!isset($_SESSION['user_session']))
{
header('Location: ../login.php');
}
?>
<?php
/**
* TSW Listing Nano Directory
<div id="container">
<?php
// simple but effective for string outputting to html page
function esc($s){
return htmlentities(trim($s), ENT_QUOTES, 'UTF-8');
}
function countFolder($dir) {
$get = (count(scandir($dir)) - 2);
if ($get == -2) {
@tradesouthwest
tradesouthwest / myremoveemjoi_from4_9.php
Created November 17, 2017 18:57
Disable wp 4.9 emojicons function
function my_disable_wp_emojicons() {
// all actions related to emojis
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
This file has been truncated, but you can view the full file.
<IfModule mod_deflate.c>
# Force compression for mangled `Accept-Encoding` request headers
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding