Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / defer-wp-scripts.php
Created December 20, 2017 07:24 — forked from Antoinebr/defer-wp-scripts.php
defer-wp-scripts.php
<?php
/*
function to add async and defer attributes
Will only work if the scripts are enqueued with wp_enqueue_script()
*/
function defer_js_async($tag){
## 1: list of scripts to defer.
$scripts_to_defer = array(
'owl-carousel.min.js',
@bewho
bewho / tags-in-head.md
Created December 19, 2017 14:49 — forked from varundevpro/tags-in-head.md
A list of everything that could go in the <head> of your document

HEAD

CC0 Contributors

A list of everything that *could* go in the <head> of your document

Table of Contents

<?php
/*-----------------------------------------------------------------------------------*/
/* Do not remove these lines, sky will fall on your head.
/*-----------------------------------------------------------------------------------*/
define( 'MTS_THEME_NAME', 'schema' );
define( 'MTS_THEME_VERSION', '3.1.2' );
require_once( dirname( __FILE__ ) . '/theme-options.php' );
if ( ! isset( $content_width ) ) {
$content_width = 680;
@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.
*
@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 / 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 / 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">
<?php
/*
Plugin Name: UTF8mb4-convert
Version: 1.0
*/
function update_db_to_utf8mb4() {
if ( ! isset( $_GET['update-utf8bm4'] ) ) {
return;
}
@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;
}
@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' ) );