This file contains 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 | |
/* Assumes Woocommerce Bookings is used to create and manage bookable products. Note that this does not account for mixed product types and assumes all products are bookable products. Adjust $args if you have a mix of product types */ | |
$args = array('post_type' => 'product'); | |
$products = get_posts($args); | |
foreach($products as $product){ | |
$product_id = $product->ID; | |
echo "ID is $product_id<br />"; | |
$period = 13; | |
update_post_meta($product_id,'_wc_booking_buffer_period',$period); |
This file contains 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 | |
/* Changes the word Shipping to Delivery in the Woocommerce cart. Credit to Loictheaztec https://stackoverflow.com/a/53016991 */ | |
add_filter('woocommerce_shipping_package_name', 'change_shipping_text_to_delivery', 20, 3 ); | |
function change_shipping_text_to_delivery( $sprintf, $i, $package ) { | |
$sprintf = sprintf( _nx( 'Delivery', 'Delivery %d', ( $i + 1 ), 'delivery packages', 'woocommerce' ), ( $i + 1 ) ); | |
return $sprintf; | |
} | |
?> |
This file contains 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
function my_coupon_strings( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Coupon code' : | |
$translated_text = __( 'My New Coupon Code Text', 'woocommerce' ); // Change text here | |
break; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'my_coupon_strings', 10, 3 ); |
This file contains 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
$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', |
This file contains 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
//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}/"; |
This file contains 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
<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" |
This file contains 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
/** | |
* 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 ) ) { |
This file contains 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 | |
wc_dropdown_variation_attribute_options( array( | |
'options' => $options, | |
//'attribute' => $attribute_name, | |
'product' => $product, | |
) ); |
This file contains 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 | |
/* 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 |
This file contains 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
function the_slug() { | |
$post_data = get_post($post->ID, ARRAY_A); | |
$slug = $post_data['post_name']; | |
return $slug; } |
NewerOlder