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
/* | |
* Since Google Analytics only allows integers as event values, Monster Insights multiplies the value by 100. | |
* This makes it difficult to use sale events for goal tracking and adding their values to other goals. | |
* This function adds a custom event with the sales value rounded, which should be close enough in most cases. | |
* | |
* Requires WooCommerce (version >= 3.0) and Monster Insights (free or premium) to be active. | |
*/ | |
add_filter( 'monsterinsights_mp_api_call', 'gbol_add_rounded_sale_event' ); | |
function gbol_add_rounded_sale_event( $body ) { |
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
/* Allow Easy Testimonials and Visual Composer shortcodes in excerpts */ | |
add_filter( 'strip_shortcodes_tagnames', 'gbol_allow_shortcodes' ); | |
function gbol_allow_shortcodes( $tags_to_remove ) { | |
$allowed_shortcodes = array( 'random_testimonial', 'single_testimonial', 'testimonials', 'testimonials_cycle', 'testimonials_grid', | |
'vc_row', 'vc_column', 'vc_column_text' ); | |
foreach( $allowed_shortcodes as $tag ) { | |
if ( $key = array_search( $tag, $tags_to_remove ) ) { |
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
/* | |
* This code is for WordPress and should be used in functions.php of the active theme. | |
* | |
* Before using it, replace "ADVERTISER ID" with your own advertiser ID and "SLOT ID" with your own slot ID | |
* (you can get both in Google AdSense). For best results, use a reponsive ad unit. | |
* | |
* If your posts contain "pre", "noscript" or some other type of HTML block, add them to $block_tags. | |
* | |
* You can change the insertion point by changing $after_block. | |
* |
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
// Save product_quantity_field.php in your active theme directory, then | |
// add this line to your functions.php file to include it in the theme | |
include( get_stylesheet_directory() . '/product_quantity_field.php' ); |
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_filter( 'wpcf7_validate_text', 'no_urls_allowed', 10, 3 ); | |
add_filter( 'wpcf7_validate_text*', 'no_urls_allowed', 10, 3 ); | |
add_filter( 'wpcf7_validate_textarea', 'no_urls_allowed', 10, 3 ); | |
add_filter( 'wpcf7_validate_textarea*', 'no_urls_allowed', 10, 3 ); | |
function no_urls_allowed( $result, $tag ) { | |
$tag = new WPCF7_Shortcode( $tag ); | |
$type = $tag->type; | |
$name = $tag->name; |
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
The WordPress admin bar can sometimes get in the way of checking what a site looks like | |
while being logged in, so it's convenient to hide it occasionally. | |
To do this, we need a CSS class and some jQuery code, which toggles the admin bar display | |
when pressing Shift-A. | |
The CSS can be added to the theme's normal stylesheet. The PHP/jQuery code can be added | |
into footer.php or included within an action in functions.php. | |
* The code was adapted from the Bottom Admin Bar plugin. |
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 add_rss_video_embed_notice( $html, $url, $attr, $post_id ) { | |
if (!is_feed()) { // No need to change anything | |
return $html; | |
} | |
$permalink = get_permalink( $post_id ); | |
$notice = '<br /><small>If you cannot see a video, <a href="' . $permalink . '">view this post online</a></small>'; | |
return $html . $notice; | |
} |
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 woo_seo_noindex_special_pages () { | |
global $post; | |
$woocommerce_pages = array('cart', 'checkout', 'order-received', 'order-tracking', | |
'my-account', 'logout', 'lost-password', 'mijireh-secure-checkout'); | |
$slug = get_post($post)->post_name; | |
if (in_array($slug, $woocommerce_pages)) { | |
echo '<meta name="robots" content="noindex,follow"/>' . "\n"; | |
} |