Skip to content

Instantly share code, notes, and snippets.

@bewho
bewho / functions.php
Created May 14, 2017 10:55 — forked from dipakcg/functions.php
WordPress - Force all scripts to footer
/* ******************
When considering performance speed, you may want to keep JS scripts organized beneath your overall page HTML.
This snippet allows most of the DOM to finish loading before running any dynamic scripts.
****************** */
function dcg_move_scripts_to_footer() {
if( !is_admin() ) {
remove_action('wp_head', 'wp_print_scripts');
remove_action('wp_head', 'wp_print_head_scripts', 9);
remove_action('wp_head', 'wp_enqueue_scripts', 1);
@bewho
bewho / functions.php
Created May 14, 2017 12:07 — forked from lukecav/functions.php
Remove Additional CSS from the WordPress (4.7) Customizer
add_action( 'customize_register', 'prefix_remove_css_section', 15 );
/**
* Remove the additional CSS section, introduced in 4.7, from the Customizer.
* @param $wp_customize WP_Customize_Manager
*/
function prefix_remove_css_section( $wp_customize ) {
$wp_customize->remove_section( 'custom_css' );
}
@bewho
bewho / functions.php
Created May 14, 2017 12:09 — forked from lukecav/functions.php
Remove dashicons from the front-end for non-admins
// remove dashicons
function wpdocs_dequeue_dashicon() {
if (current_user_can( 'update_core' )) {
return;
}
wp_deregister_style('dashicons');
}
add_action( 'wp_enqueue_scripts', 'wpdocs_dequeue_dashicon' );
@bewho
bewho / Compressor.php
Created May 14, 2017 12:10 — forked from lukecav/Compressor.php
W3 Total Cache Fixed - Compressor.php
<?php
/**
* Class Minify_CSS_Compressor
* @package Minify
*/
/**
* Compress CSS
*
* This is a heavy regex-based removal of whitespace, unnecessary
@bewho
bewho / functions.php
Created May 14, 2017 12:13 — forked from lukecav/functions.php
Prevent unnecessary AJAX loading requests in WooCommerce
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
}
@bewho
bewho / functions.php
Created May 14, 2017 12:16 — forked from lukecav/functions.php
Lazyload Converter - WP
// Lazyload Converter
function add_lazyload($content) {
$content = mb_convert_encoding($content, 'HTML-ENTITIES', "UTF-8");
$dom = new DOMDocument();
@$dom->loadHTML($content);
// Convert Images
$images = [];
@bewho
bewho / fbcbfwss.php
Created May 14, 2017 12:24 — forked from lukecav/fbcbfwss.php
WordPress Plugin: Filename-based cache busting for scripts/styles.
<?php
/**
* Plugin Name: Filename-based cache busting
* Version: 0.3
* Description: Filename-based cache busting for WordPress scripts/styles.
* Author: Dominik Schilling
* Author URI: http://wphelper.de/
* Plugin URI: https://dominikschilling.de/880/
*
* License: GPLv2 or later
@bewho
bewho / gist:8d44236d679a07dce6544ed0b97e496f
Created May 15, 2017 00:29 — forked from rajuahmed/gist:830be416b4ad440f9e40
Compress HTML file in wordpress theme to increase loading speed of wordpress site
// Minify HTML codes when page is output.
add_action('wp_loaded','my_minify_html');
function my_minify_html(){
/**
* use html_compress($html) function to minify html codes.
*/
ob_start('html_compress');
}
@bewho
bewho / header_ogp.php
Created May 15, 2017 00:47 — forked from makotokw/header_ogp.php
Open Graph protocol for WordPress
<?php
/**
* Open Graph protocol for WordPress
* @version 0.9.2
* @author makoto_kw
* @link https://gist.github.com/3399585
*/
// key into custom fields for description. Default is for All in One SEO Pack
define('WP_OGP_POST_DESCRIPTION_KEY', '_aioseop_description');
@bewho
bewho / wpcom-open-graph.php
Created May 15, 2017 00:54 — forked from mjangda/wpcom-open-graph.php
Add Open Graph tags to your WordPress site
<?php
/**
* Open Graph Tags
*
* Add Open Graph tags so that Facebook (and any other service that supports them)
* can crawl the site better and we provide a better sharing experience.
*
* @link http://ogp.me/
* @link http://developers.facebook.com/docs/opengraph/
*/