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 | |
if( !function_exists('id_fix_shortcodes') ) { | |
function id_fix_shortcodes($content){ | |
$array = array ( | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']' | |
); | |
$content = strtr($content, $array); |
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 | |
/* Add responsive container to embeds | |
/* ------------------------------------ */ | |
function id_embed_html( $html ) { | |
return '<div class="video-container">' . $html . '</div>'; | |
} | |
add_filter( 'embed_oembed_html', 'id_embed_html', 10, 3 ); | |
add_filter( 'video_embed_html', 'id_embed_html' ); // Jetpack |
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 | |
// Display product video instead of image/slider | |
function woocommerce_show_product_images() { | |
// Get video and display | |
if ( $video = get_post_meta( get_the_ID(), 'product_post_video', true ) ) { | |
// Sanitize video URL | |
$video = esc_url( $video ); |
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_action('save_post', 'custom_check_thumbnail'); | |
add_action('admin_notices', 'custom_thumbnail_error'); | |
function custom_check_thumbnail($post_id) { | |
// change to any custom post type | |
if(get_post_type($post_id) != 'post') | |
return; | |
if ( !has_post_thumbnail( $post_id ) ) { | |
// set a transient to show the users an admin message |
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_action( 'woocommerce_cart_calculate_fees','woocommerce_surcharge' ); | |
function woocommerce_surcharge() { | |
global $woocommerce; | |
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) | |
return; | |
$percentage = 0.01; | |
$surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage; | |
$woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' ); | |
} |
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
/** | |
* Gets Variation ID if available otherwise it will get the Product ID | |
* @param $product Product | |
* @param bool $check_variations Whether or not to check for variation IDs | |
* @return mixed | |
*/ | |
function get_id_from_product( $product, $check_variations = false ) { | |
if( $check_variations ) { | |
return ( isset( $product['variation_id'] ) | |
&& ! empty( $product['variation_id']) |
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 | |
function switch_homepage() { | |
if ( is_user_logged_in() ) { | |
$page = 2516; // for logged in users | |
update_option( 'page_on_front', $page ); | |
update_option( 'show_on_front', 'page' ); | |
} else { | |
$page = 2; // for logged out users | |
update_option( 'page_on_front', $page ); |
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 | |
header('Content-type: text/css'); | |
ob_start("compress"); | |
function compress( $minify ) | |
{ | |
/* remove comments */ | |
$minify = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $minify ); |
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 | |
function defer_js_async($tag){ | |
// scripts to defer. | |
$scripts_to_defer = array('script-name1.js', 'script-name2.js', 'script-name3.js'); | |
// scripts to async. | |
$scripts_to_async = array('script-name1.js', 'script-name2.js', 'script-name3.js'); | |
foreach($scripts_to_defer as $defer_script){ |
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 | |
function remove_cssjs_querystring( $src ) { | |
if( strpos( $src, '?rev=' ) ) // copy/paste this line and the next one to take away what you want from the end of your css/js | |
$src = remove_query_arg( 'rev', $src ); | |
if( strpos( $src, '?ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} | |
add_filter( 'style_loader_src', 'remove_cssjs_querystring', 10, 2 ); |