This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php/** | |
* Get county name by zip code | |
* | |
* @param string|int $zip Zip code to lookup. | |
* @return string $countyname Formatted county name. | |
*/ | |
function get_county_by_zip( $zip ) { | |
// google maps api. | |
$url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' . $zip . '&key=AIzaSyC3TG7THSJjHbzDpYyQagJvWP-Inu6i33s'; | |
$response = json_decode( file_get_contents( $url ), true ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get contents of remote url | |
* | |
* @see https://knowledgecornor.blogspot.com/2013/10/filegetcontents-vs-curl.html | |
* @author Travis Aaron Wagner | |
* | |
* @param string $url URL to get. | |
* @return string $output Remote url contents. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Return array with only keys containing a string | |
* | |
* @param string $str String to filter keys by. | |
* @param array $arr Source array. | |
* @return array Filtered array. | |
*/ | |
function keys_containing( $str, $arr ) { | |
return array_filter( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_head', function() { | |
global $product; | |
wp_localize_script('main-js-script-name', 'product', $product->get_data() ); | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rm -rf .git/ | |
git init | |
rm .gitignore | |
mv .gitignore-deploy .gitignore | |
cd wp-content/themes/moonfab/ | |
npm install | |
npm run dev | |
git config --global user.name "CodeShip deployment" | |
git config --global user.email "[email protected]" | |
git remote add dev [email protected]:production/moonfabdev.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( '[data-linked]' ).on( 'change keyup', function() { | |
let $this = $( this ), | |
name = $this.data( 'linked' ), | |
type = $this.attr( 'type' ), | |
val = $this.val(), | |
checkboxOrRadio = ( 'radio' === type || 'checkbox' === type ), | |
$linked = $( `[name="${name}"]` ); | |
if ( checkboxOrRadio ) { | |
$linked = $( `[name="${name}"][value="${val}"]` ); | |
if ( $this.prop( 'checked' ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Filter keys in multidimensional array. | |
* | |
* @param mixed $arr The array to filter. | |
* @param mixed ...$keys Keys to remove. Accepts multiple strings or an array of strings. | |
* @return array $new Array without specified keys. | |
*/ | |
function recursive_filter_keys( &$arr, ...$keys ) { | |
if ( isset( $keys[0] ) && is_array( $keys[0] ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Must-use plugin | |
* | |
* @package taw | |
*/ | |
add_action( | |
'admin_head', | |
function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get free shipping minimum | |
* | |
* @param string $zone_name Zone name. | |
* @return int $min_amount Minimum for free shipping. | |
*/ | |
function get_free_shipping_minimum( $zone_name = '' ) { | |
if ( empty( $zone_name ) ) { | |
return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display price in variation options dropdown for products that have only one attribute. | |
* | |
* @author Travis Aaron Wagner <[email protected]> | |
* @param string $term Existing option term value. | |
* @return string $term Existing option term value or updated term value with price. | |
*/ | |
function display_price_in_variation_options( $term ) { | |
$product = wc_get_product(); |