Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / functions.php
Created December 13, 2017 16:24 — forked from lukecav/functions.php
Disable zoom-on-hover effect on product images in WooCommerce 3.0
add_action( 'wp_enqueue_scripts', 'jk_disable_magnification' );
function jk_disable_magnification() {
wp_dequeue_script( 'zoom' );
}
@bewho
bewho / functions.php
Created December 13, 2017 16:28 — forked from lukecav/functions.php
Remove footer generated by W3 Total Cache
function remove_footer(){
// Disable W3TC footer comment for everyone but Admins (single site & network mode)
if(!current_user_can('activate_plugins')){
add_filter('w3tc_can_print_comment','__return_false',10,1);
}
// Disable W3TC footer comment for all users
//add_filter('w3tc_can_print_comment','__return_false',10,1);
}
add_action('plugins_loaded','remove_footer');
@bewho
bewho / cache-nav-menu.php
Created December 13, 2017 16:32 — forked from lukecav/cache-nav-menu.php
Cache Nav Menus
<?php
/*
* Plugin Name: Cache Nav Menus
* Description: Allows Core Nav Menus to be cached using WP.com's Advanced Post Cache.
* Author: Automattic
*/
function cache_nav_menu_parse_query( &$query ) {
if ( !isset( $query->query_vars['post_type'] ) || 'nav_menu_item' !== $query->query_vars['post_type'] ) {
@bewho
bewho / woocommerce-optimize-scripts.php
Created December 13, 2017 16:46 — forked from lukecav/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@bewho
bewho / functions.php
Created December 14, 2017 02:53 — forked from worduoso/functions.php
How to add custom author's bio to WordPress single post page
/*
* Add custom contacts for WordPress user as we want user to have links to their Twitter, LinkedIn, etc accounts
*/
function worduoso_contactmethods( $contactmethods ) {
$contactmethods['linkedin'] = 'Linked In'; // Add LinkedIn
$contactmethods['twitter'] = 'Twitter'; // Add Twitter
$contactmethods['facebook'] = 'Facebook'; // Add Facebook
return $contactmethods;
}
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
@bewho
bewho / favicons.html
Created December 15, 2017 08:46 — forked from paulburgess/favicons.html
Favicon markup for all sorts of scenarios and devices
<link rel="shortcut icon" href="/favicon/favicon.ico">
<link rel="apple-touch-icon" sizes="57x57" href="/favicon/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="114x114" href="/favicon/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="72x72" href="/favicon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="144x144" href="/favicon/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="60x60" href="/favicon/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="120x120" href="/favicon/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="76x76" href="/favicon/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="152x152" href="/favicon/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon-180x180.png">
@bewho
bewho / all-in-one-og.php
Created December 15, 2017 09:33 — forked from jallen9674/all-in-one-og.php
functions.php
<?php
if( !function_exists( 'add_opengraph_doctype' )):
////////////////////////////////////////////////////////////////////
//Adding the Open Graph in the Language Attributes
////////////////////////////////////////////////////////////////////
function add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
@bewho
bewho / functions.php
Created December 17, 2017 08:01 — forked from blainerobison/functions.php
Add Featured Image Description in WordPress
<?php
/**
* Add Featured Image Description
*
* @param string $content Admin post thumbnail HTML markup.
* @param integer $content Post ID.
* @return string
*/
function prefix_featured_image_description( $content, $post_id ) {
@bewho
bewho / setup.php
Created December 17, 2017 08:01 — forked from blainerobison/setup.php
WordPress X-UA-Compatible Headers for IE
/**
* Set X-UA-Compatible for IE
*
* Sends headers to browser in an attempt to have IE render the website using
* their latest rendering engine (i.e. IE=edge). Additionally, attempts to
* activate Chrome Frame add-on if it exists.
*
* IE browser may show compatibility icon in address bar when using HTML5 Boilerplate's
* heading markup which contains conditional comments on HTML tag.
*