Skip to content

Instantly share code, notes, and snippets.

@krishna19
krishna19 / custom.php
Created Dec 9, 2016
Replaces the default Avada breadcrumbs with the Yoast breadcrumbs included in the WordPress SEO plugin. Usage: Copy this file in your wp-content/mu-plugins/ folder (if that folder doesn't already exist, you will have to manually create it.
View custom.php
<?php
/**
* Replace the default Avada Breadcrumbs with the Yoast SEO Breadcrumbs.
* Overrides the parent theme's themefusion_breadcrumb() function.
*/
function themefusion_breadcrumb() {
// Early exit if the yoast_breadcrumb() function does not exist
if ( ! function_exists( 'yoast_breadcrumb' ) ) {
View gist:11b7c9fa634ec1c5206be73c143fecbd
if(is_multisite()) {
$uploads = wp_upload_dir();
wp_register_style('options', $uploads['baseurl'] . '/options.css', 'style');
} else {
wp_register_style('options', get_template_directory_uri() . '/css/options.css', 'style');
}
@krishna19
krishna19 / filter.thumbnail.functions.php
Created Dec 5, 2016 — forked from wturnerharris/filter.thumbnail.functions.php
Filter function for WordPress: this adds an onload attribute onto the img element for calls that use the post_thumbnail_html filter such as get_the_post_thumbnail() or the_post_thumbnail()
View filter.thumbnail.functions.php
/**
*
* Filter the post thumbnail html adding a javascript onload attribute.
*
* @param html(string)
* @return string
*/
function filter_thumbnail_html($html, $attr = false) {
if (empty($html)) return $html;
@krishna19
krishna19 / gist:81b6142126dc9ed4498e2d988bfa1231
Created Oct 8, 2016 — forked from pippinsplugins/gist:9201867
Simple example of how to use SCRIPT_DEBUG to load non-minified assets
View gist:81b6142126dc9ed4498e2d988bfa1231
<?php
// Use minified libraries if SCRIPT_DEBUG is turned off
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_script( 'my-script-handle', plugin_dir_url( __FILE__ ) . 'assets/my-file' . $suffix . '.js', array( 'jquery' ) );
@krishna19
krishna19 / smooth-scroll.jquery.js
Created Oct 3, 2016 — forked from wpscholar/smooth-scroll.jquery.js
Implement smooth scroll for all internal page links.
View smooth-scroll.jquery.js
// Smooth Scroll
$('a[href*="#"]:not([href="#"])').click(function () {
var target = $(this.hash);
if (target.length) {
var isInternalLink = new RegExp('/' + window.location.host + '/');
if (isInternalLink.test(this.href)) {
$('html, body').animate({scrollTop: target.offset().top}, 1000);
return false;
}
}
@krishna19
krishna19 / functions.php
Created Oct 3, 2016 — forked from wpscholar/functions.php
Enqueueing IE conditional stylesheets in WordPress the right way
View functions.php
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_my_styles' );
/**
* Example callback function that demonstrates how to properly enqueue conditional stylesheets in WordPress for IE.
* IE10 and up does not support conditional comments in standards mode.
*
* @uses wp_style_add_data() WordPress function to add the conditional data.
* @link https://developer.wordpress.org/reference/functions/wp_style_add_data/
@krishna19
krishna19 / gist:050d3c0d05ddc996aa7789046f877a84
Created Oct 3, 2016 — forked from bitfade/gist:4555047
WordPress - Remove empty p tags for custom shortcodes
View gist:050d3c0d05ddc996aa7789046f877a84
<?php
add_filter("the_content", "the_content_filter");
function the_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("col","shortcode2","shortcode3"));
// opening tag
@krishna19
krishna19 / cart-cache-breaker.php
Created Oct 3, 2016 — forked from khromov/cart-cache-breaker.php
Fixing Cart Widget showing the incorrect item when using WPML with WooCommerce, by forcing cart widget to refresh on every page load.
View cart-cache-breaker.php
/** Break html5 cart caching */
add_action('wp_enqueue_scripts', 'cartcache_enqueue_scripts', 100);
function cartcache_enqueue_scripts()
{
wp_deregister_script('wc-cart-fragments');
wp_enqueue_script( 'wc-cart-fragments', get_template_directory_uri() . '/cart-fragments.js', array( 'jquery', 'jquery-cookie' ), '1.0', true );
}
@krishna19
krishna19 / colors.scss
Created Oct 3, 2016 — forked from leemunroe/colors.scss
Social Media Brand Colors
View colors.scss
// Common social media colors
// More at http://brandcolors.net/
$dribbble-color:#ea4c89;
$facebook-color:#3b5998;
$github-color:#171515;
$google-color:#dd4b39;
$linkedin-color:#0e76a8;
$rss-color:#ee802f;
$twitter-color:#00aced;
@krishna19
krishna19 / redux_get_variables.php
Created Oct 3, 2016 — forked from dovy/redux_get_variables.php
Simple method for recovering redux values if you wish to not use the global variable.
View redux_get_variables.php
<?
function redux_get_variables( $name, $key = false ) {
global $MY_VAR_NAME; // Update to your opt_name or global_variable name
$options = $MY_VAR_NAME; // Update to your opt_name or global_variable name
$var = ""; // Set this to your preferred default value
if ( empty( $name ) && !empty( $options ) ) {
$var = $options;
} else {