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 / 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
****/
<!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 / 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',
@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 ):
/**
* print custom post type category list
* @cpt name= hordes
* @taxonomy name= hordes-category
*/
if ( ! function_exists( 'theme_entry_footer_cat_list' ) ) :
function theme_entry_footer_cat_list() {
// Get custom taxonomy project_category for each specific CPT
if ( 'hordes' === get_post_type() ) {
<?php
/**
* Get all blog ids of blogs in the current network that are:
* - not archived
* - not spam
* - not deleted
*
*
* @return array|false The blog ids, false if no matches.
*/
@tradesouthwest
tradesouthwest / wp-gettext-example.php
Created October 28, 2018 01:45
gettext example for wordpress to replace translated text
add_filter( 'gettext', 'misha_change_text_with_gettext', 20, 3 );
function misha_change_text_with_gettext( $translated_text, $text, $domain ) {
if ( is_admin()
&& isset($_GET['post'])
&& get_post_type( $_GET['post'] ) == 'shop_order'
&& $domain == 'woocommerce' ) {
if( $translated_text == 'Shipping' ) {
@tradesouthwest
tradesouthwest / retrieve-id-of-post-from-any-meta.php
Last active November 12, 2018 17:52
Retrieve post id from any meta field
<?php
//From: https://github.com/oyina/Note-Taker/blob/master/note.php
//Retreives Post Id from Meta Key
function get_post_id_by_meta_key_and_value($key, $value) {
global $wpdb;
$meta = $wpdb->get_results("SELECT * FROM `".$wpdb->postmeta."` WHERE meta_key='".$wpdb->escape($key)."'
AND meta_value='".$wpdb->escape($value)."'");
if (is_array($meta) && !empty($meta) && isset($meta[0])) {
$meta = $meta[0];
}
@tradesouthwest
tradesouthwest / learndash-code-in-answer.php
Created November 18, 2018 04:02
LearnDash cloze answer accept case sensitive
<?php
/**
* LearnDash filter to prevent converting answer values to lowercase
*
* @possibly use ld_adv_quiz_pro_ajax()
* @uses stripslashes( strtolower( trim( $userResponse ) ) ) Default
* @since 1.0
* @from WpProQuiz_View_FrontQuiz.php
* post_type=sfwd-quiz
*/
@tradesouthwest
tradesouthwest / memberpress-subscr-dropdown.php
Created November 29, 2018 18:35
Memberpress gets all products to put in dropdown in admin settings page
<?php
//gets all products to put in dropdown in admin settings page
function meprprorata_products_dropdown_cb($args, $access= array())
{
//$available = new MeprCouponsHelper::products_dropdown();
$access = is_array($access) ? $access : array();
$contents = array();
$posts = MeprCptModel::all('MeprProduct');