Skip to content

Instantly share code, notes, and snippets.

@tjhole
tjhole / WORDPRESS: Function - remove version param
Created November 13, 2013 16:31
WORDPRESS: Function - Remove version param
// remove wp version param from any enqueued scripts
function vc_remove_wp_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
@tjhole
tjhole / WORDPRESS: Function - Enqueue JQUERY and JQUERY UI
Created November 13, 2013 16:35
WORDPRESS: Function - Enqueue JQUERY and JQUERY UI
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
wp_register_script('jqueryui', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js", false, null);
wp_enqueue_script('jqueryui');
@tjhole
tjhole / WORDPRESS: Function - Custom Image Size
Created November 14, 2013 17:23
WORDPRESS: Function - Custom Image Size
add_image_size( 'square', 360, 360, true );
@tjhole
tjhole / JQUERY: Smooth Scroll
Created November 26, 2013 22:54
JQUERY: Smooth Scroll
var $s = jQuery.noConflict();
$s(function() {
$s('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $s(this.hash);
target = target.length ? target : $s('[name=' + this.hash.slice(1) +']');
if (target.length) {
@tjhole
tjhole / WORDPRESS: Call Nav Menu
Created November 28, 2013 10:44
WORDPRESS: Call Nav Menu
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'container' => '' ) ); ?>
@tjhole
tjhole / WORDPRESS: Ultra Simple Paypal Cart Parse Shortcode
Created November 29, 2013 13:09
WORDPRESS: Ultra Simple Paypal Cart Parse Shortcode
<?php if( get_field('the_price') ) {
$price = get_field('the_price');
echo '<div id="price">$' . $price . '</div>';
} ?>
<?php if( get_field('the_colors') ) {
$colors = implode('|', get_field('the_colors'));
<?php $title = get_the_title(); ?>
@tjhole
tjhole / ACF: Shipping Repeter to Ultra Simple WP Cart
Created November 29, 2013 14:09
ACF: Shipping Repeter to Ultra Simple WP Cart
<?php $price = get_field('price');
$title = get_the_title();
$shipping_row = get_field('shipping_costs');
$shipping_total = count($shipping_row);
$i = 0;
foreach($shipping_row as $ship){
$i++;
$shipping_output.= $ship['area'] . ',' . $ship['cost'];
if ($i!=$shipping_total) {$shipping_output.= "|";}
};
@tjhole
tjhole / WORDPRESS: Hide ACF by CSS in Admin Area
Created November 29, 2013 15:32
WORDPRESS: Hide ACF via CSS in admin area
// Editing the WordPress Dashboard Header
function wp_admin_dashboard_header_colour() {
echo '<style type="text/css">
#toplevel_page_edit-post_type-acf { display:none; }
</style>';
}
add_action('admin_head', 'wp_admin_dashboard_header_colour');
@tjhole
tjhole / CSS: Cover background
Created December 1, 2013 17:39
CSS: Cover background
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@tjhole
tjhole / WORDPRESS: Dynamic home URL
Created December 3, 2013 08:49
WORDPRESS: Dynamic home URL
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] );
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] );