This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is the technique I use to defer Youtube videos, when optimising the performance of WordPress site. | |
(1) Replace Youtube iFrame embed code with the below one: | |
---------------------- | |
<div class="dcg-responsive-container"> | |
<iframe class="dcg-responsive-iframe" src="" data-src="https://www.youtube.com/watch?v=nEFZLFyZNcE?rel=0" frameborder="0" allowfullscreen style="border:0"></iframe> | |
</div> | |
(2) Add the following CSS element (stylesheet element that will make Youtube iFrame Responsive) (style.css?): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( !is_admin() ) { | |
// Deregister the jquery version bundled with WordPress. | |
wp_deregister_script( 'jquery' ); | |
// CDN hosted jQuery placed in the header, as some plugins require that jQuery is loaded in the header. | |
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js', false, '3.4.1' ); | |
wp_enqueue_script( 'jquery' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<locationmatch "/bb-post.php"> | |
SecRuleRemoveById 300013 | |
SecRuleRemoveById 300015 | |
SecRuleRemoveById 300016 | |
SecRuleRemoveById 300017 | |
</locationmatch> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if( | |
strpos( $_SERVER['HTTP_REFERER'], 'wp-admin' ) === false && | |
strpos( $_SERVER['REQUEST_URI'], 'admin-ajax.php' ) !== false | |
) { | |
header( 'Cache-Control: max-age=30000, must-revalidate' ); | |
header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', strtotime( '+5000 minutes' ) ) . ' GMT' ); | |
header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s', strtotime( '-5000 minutes' ) ) . ' GMT' ); | |
header( $_SERVER["SERVER_PROTOCOL"]." 404 Not Found" ); | |
die; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dcg_customise_dashboard() { | |
// remove_menu_page( 'index.php' ); //Dashboard | |
// remove_menu_page( 'jetpack' ); //Jetpack* | |
// remove_menu_page( 'edit.php' ); //Posts | |
// remove_menu_page( 'upload.php' ); //Media | |
// remove_menu_page( 'edit.php?post_type=page' ); //Pages | |
// remove_menu_page( 'edit-comments.php' ); //Comments | |
// remove_menu_page( 'themes.php' ); //Appearance | |
// remove_menu_page( 'plugins.php' ); //Plugins | |
// remove_menu_page( 'users.php' ); //Users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ****************** | |
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display phone number field at checkout | |
* Add more here if you need to | |
*/ | |
function sumobi_edd_display_checkout_fields() { | |
// get user's phone number if they already have one stored | |
if ( is_user_logged_in() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Get browser window size using jQuery (useful for responsive testing)</title> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(window).bind({ | |
load:function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Add this code in theme's search.php file where you want to display search results from Google. */ | |
$query = get_search_query(); | |
$query_new =str_replace(' ','%20',$query); | |
$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=0&rsz=8&q=".$query_new; | |
$body = file_get_contents($url); | |
$json = json_decode($body); |