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
// Add Math CAPTCHA to WooCommerce Checkout | |
add_action('woocommerce_after_order_notes', 'custom_math_captcha_checkout'); | |
function custom_math_captcha_checkout($checkout) { | |
$num1 = rand(1, 10); // Generate first random number | |
$num2 = rand(1, 10); // Generate second random number | |
$sum = $num1 + $num2; // Calculate the sum | |
// Store the sum in a session for later validation | |
WC()->session->set('math_captcha_sum', $sum); |
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 currentYear( $atts ){ | |
return date('Y'); | |
} | |
add_shortcode( 'year', 'currentYear' ); |
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
/wp-admin/admin.php?page=wpcf7&action=validate |
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
selector { | |
display: inline-block; | |
animation: rotate 5s linear infinite; | |
} | |
@keyframes rotate { | |
from { | |
transform: rotate(0deg); | |
} | |
to { |
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
// Add a custom delivery days range field to the product editing page | |
add_action('woocommerce_product_options_general_product_data', 'add_custom_delivery_days_range_field'); | |
function add_custom_delivery_days_range_field() { | |
global $post; | |
// Get the current value, if it exists | |
$custom_delivery_days = get_post_meta($post->ID, '_custom_delivery_days', true); | |
echo '<div class="options_group">'; |
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
<!-- Meta Pixel Code --> | |
<script> | |
!function(f,b,e,v,n,t,s) | |
{if(f.fbq)return;n=f.fbq=function(){n.callMethod? | |
n.callMethod.apply(n,arguments):n.queue.push(arguments)}; | |
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; | |
n.queue=[];t=b.createElement(e);t.async=!0; | |
t.src=v;s=b.getElementsByTagName(e)[0]; | |
s.parentNode.insertBefore(t,s)}(window, document,'script', | |
'https://connect.facebook.net/en_US/fbevents.js'); |
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 wc_billing_field_strings( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Billing details' : | |
$translated_text = __( 'Billing Info', 'woocommerce' ); | |
break; | |
} | |
return $translated_text; | |
} | |
add_filter( 'gettext', 'wc_billing_field_strings', 20, 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
Code Snippet | |
// Automatically shortens WooCommerce product titles on the main shop, category, and tag pages | |
// to a set number of characters | |
function short_woocommerce_product_titles_chars( $title, $id ) { | |
if ( ( is_shop() || is_product_tag() || is_product_category() ) && get_post_type( $id ) === 'product' ) { | |
// Kicks in if the product title is longer than 60 characters | |
if ( strlen( $title ) > 40) { | |
// Shortens it to 60 characters and adds ellipsis at the end | |
return substr( $title, 0, 40 ) . '...'; |
NewerOlder