Skip to content

Instantly share code, notes, and snippets.

@rickgregory
rickgregory / blockerList.json
Last active September 1, 2015 06:42
Testing Safari Content Blocker on iMore.com
[
{
"action": {
"type": "block"
},
"trigger": {
"url-filter": ".*",
"resource-type": ["script"],
"load-type": ["third-party"],
"if-domain": ["*imore.com"]
@rickgregory
rickgregory / 0_reuse_code.js
Created December 23, 2013 05:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php shopp('collection.description'); ?>
<?php if ( shopp( 'collection.hasproducts' ) ) : ?>
<div class="category">
<?php shopp( 'storefront.breadcrumb', array( 'separator' => '&nbsp;&raquo; ' ) ); ?>
<ul class="products">
<?php while( shopp( 'collection.products' ) ) : ?>
<li class="product<?php if ( shopp('collection.row') ) echo ' first'; ?>" itemscope itemtype="http://schema.org/Product">
function the_slug() {
$post_data = get_post($post->ID, ARRAY_A);
$slug = $post_data['post_name'];
return $slug; }
@rickgregory
rickgregory / functions.php
Created February 22, 2018 20:00 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
<?php
wc_dropdown_variation_attribute_options( array(
'options' => $options,
//'attribute' => $attribute_name,
'product' => $product,
) );
/**
* NOTE: code from http://scottnelle.com/756/async-defer-enqueued-wordpress-scripts/
* Add async attributes to enqueued scripts where needed.
* The ability to filter script tags was added in WordPress 4.1 for this purpose.
*/
function my_async_scripts( $tag, $handle, $src ) {
// the handles of the enqueued scripts we want to async
$async_scripts = array( 'some-script', 'another-script' );
if ( in_array( $handle, $async_scripts ) ) {
<div
class="wp-block-group__inner-container block-editor-block-list__layout"
data-is-drop-zone="true"
>
<div
class="block-editor-block-list__block wp-block"
id="block-8daf5358-8d64-4cc4-a89c-66e0f00ffe4d"
tabindex="0"
role="group"
aria-label="Block: Practice Area Card"
//validation for name field in GF to prevent nonsense spam names. Rejects any string with 4 consecutive consonants.
add_filter( 'gform_field_validation', 'validate_name', 10, 4 );
function validate_name( $result, $value, $form, $field ) {
if ( 'name' === $field->type && $field->isRequired ) {
GFCommon::log_debug( __METHOD__ . '(): Name values => ' . print_r( $value, true ) );
$pattern = "/(?=[a-z]{4})[^aeiou]{4}/";
@rickgregory
rickgregory / gist:64cf3ce91b441d2a9ca4408b6e5554e8
Created July 5, 2023 22:39
Code to allow Breakdance Product List widget to show only product in the current category
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term ) {
$product_cat_id = $term->term_id;
$product_cat_name = $term->name;
}
return ['post_type'=>'product','tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'slug',