Chris Thank you for your contribution to the community.
I followed the instructions and reached grade 99/100.
When I withdrew the contents of functions.php I collapsed vps server. :(.
What is the procedure when you work with functions.php?
I noticed that the laoding time grew from 2.2 sec to 2.4 sec.
Does anyone have useful advice for mobile devices out there but I have 50. I use WP-rocket.
i put this in end of my file ( i use newspaper 6.3.2 ):
/*CHRISTOPHER’s CUSTOM MODS – 1.10.15 rev15A – (c) 2010-2015 Chris Simmons */
remove_action( ‘wp_head’, ‘wp_generator’ ) ;
remove_action( ‘wp_head’, ‘wlwmanifest_link’ ) ;
remove_action( ‘wp_head’, ‘rsd_link’ ) ;
remove_action( ‘wp_head’, ‘feed_links’, 2 );
remove_action( ‘wp_head’, ‘feed_links_extra’, 3 );
add_filter( ‘pre_comment_content’, ‘wp_specialchars’ );
function no_errors_please(){
return ‘You appear to be up to no good. Please stop now!’;
}
add_filter( ‘login_errors’, ‘no_errors_please’ );
/* Disable YOAST SEO Admin Bar. */
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(‘wpseo-menu’);
}
// and we hook our function via
add_action( ‘wp_before_admin_bar_render’, ‘mytheme_admin_bar_render’ );
function delete_enclosure(){
return ”;
}
add_filter( ‘get_enclosed’, ‘delete_enclosure’ );
add_filter( ‘rss_enclosure’, ‘delete_enclosure’ );
add_filter( ‘atom_enclosure’, ‘delete_enclosure’ );
function remove_cssjs_ver( $src ) {
if( strpos( $src, ‘?ver=’ ) )
$src = remove_query_arg( ‘ver’, $src );
return $src;
}
add_filter( ‘style_loader_src’, ‘remove_cssjs_ver’, 10, 2 );
add_filter( ‘script_loader_src’, ‘remove_cssjs_ver’, 10, 2 );
add_filter( ‘jpeg_quality’, create_function( ”, ‘return 50;’ ) );
function remove_pingback_url( $output, $show ) {
if ( $show == ‘pingback_url’ ) $output = ”;
return $output;
}
add_filter( ‘bloginfo_url’, ‘remove_pingback_url’, 10, 2 );
add_action(‘init’, ‘myoverride’, 100);
function myoverride() {
remove_action(‘wp_head’, array(visual_composer(), ‘addMetaData’));
}
function dequeue_visual_composer_css() {
if (is_single()) {
wp_dequeue_style(‘js_composer_front’);
}
}
add_action(‘wp_enqueue_scripts’, ‘dequeue_visual_composer_css’, 1003);
Note that some of the stuff in my functions.php list may not apply to you, for example if not using YOAST SEO plugin, you’d not need the code there. If you’re using Visual Composer for anything other than home page, you would likely not use the visual composer stuff at bottom.
Basic issues with editing functions.php are
a) edit with a true text editor, like textpad, BBEdit, or other programmer tool, *NOT* a word processor; and make sure if using Unix, you save with unix line breaks; with Windows server, you may need to save with Windows line breaks
b) make sure you don’t break end of the file — meaning, some functions.php files have a closing ?> bracket, some don’t — obviously you should put code INSIDE the closing php bracket if there is one, but *NOT* inside another query bracket — so good to make sure you’re putting it in the right place at the end of the file, but not outside a closing bracket for the file, but not inside closing bracket for another function.
c) make sure you don’t have a “service” which is trying to do the exact same things, through a dynamic re-write — meaning, if you have some kind of aggressive service re-writing your pages to remove the version numbers on end of files, my list might conflict.
My lineup of optimizations work perfectly with mod_pagespeed (e.g., comment removal and indent removal, etc.), Apache/Linux servers, current version of WP, tagdiv booster framework, YOAST SEO, and mod_SPDY.
Like anything — always keep backup, and revert back if any change to ANYTHING you do does not work as expected.
And use common sense — if you have “allow pingbacks” turned *on* in your WP admin panel — you shouldn’t use my function to turn that off on the backend π
Hi Cris I really thank you ;). The easiest way is to use copy-paste :).
This was my first encounter with functions.php. Thanks for the helpful tips.
To protect the site I uses Wordfence. Do you have any advice.
My main problem is the slow background. I welcome any suggestion.
My plugins:
AdRotate by Arnan de Gans of AJdG Solutions β 3.11.7
Advanced Access Manager by Vasyl Martyniuk β 2.8.6
Calendarize it! for WordPress by Alberto Lau (RightHere LLC) β 3.4.2.60206
Web 2.0 Directory plugin by Mihail Chepovskiy β 1.9.5
Contact Form 7 by Takayuki Miyoshi β 4.2.2
Cookie Law Info by Richard Ashby β 1.5.3
Custom Sidebars by WPMU DEV β 2.1.0.2
Easy Social Share Buttons for WordPress by CreoApps β 3.1
CM Tooltip Glossary by CreativeMindsSolutions β 3.1.9
EWWW Image Optimizer by Shane Bishop β 2.5.0
WPBakery Visual Composer by Michael M – WPBakery.com β 4.6.2
Layered Popups by Halfdata, Inc. β 4.74
Magic Answers by Nicola Franchini β 1.3
MS Custom Login by Mignon Style β 0.8
Post Duplicator by Metaphor Creations β 2.5
Regenerate Thumbnails by Viper007Bond β 2.2.4
Simple Local Avatars by Jake Goldman, 10up β 2.0
Testimonials Showcase by Carlos Moreira β 1.2.3
Video Blogster Pro by Super Blog Me β 2.4.0
Wordfence Security by Wordfence β 6.0.15
Yoast SEO by Team Yoast β 2.3.4
WP Author Box Pro by phpbits β 2.0.4
WP Retina 2x by Jordy Meow β 3.4.6
WP Rocket by WP Rocket β 2.6.7
MailPoet Newsletters Premium by MailPoet β 2.6.15
MailPoet Newsletters by MailPoet β 2.6.16
btw, you can turn “off” plugins you’re not using until you need them, like regenerate thumbnails. If you’re using the optimization code in the functions.php file you might not need the EWWW plugin. You may not need retina 2x if you start with 640xXX images to begin with, since on mobile they are reduced, but denser, and so make “new version for retina” redundant. If you can live with built-in author box, consider not using the author box pro plugin and modify the file for built-in function.
You can streamline a bit more, probably. But good choices on the line-up π
Hi one more PLS;) Wher to put code in functions.php this is edn of file. Shoud i put after </div> or totaly on end. Sorry BEGINNER QUESTIONS
………
if (TD_DEBUG_LIVE_THEME_STYLE) {
add_action(‘wp_footer’, ‘td_theme_style_footer’);
function td_theme_style_footer() {
?>
<div id=”td-theme-settings” class=”td-theme-settings-small”>
<div class=”td-skin-header”>One click demos</div>
<div class=”td-skin-content”>
<div class=”td-set-theme-style”>DEFAULT</div>
<div class=”td-set-theme-style”>FASHION</div>
<div class=”td-set-theme-style”>TECH</div>
<div class=”td-set-theme-style”>VIDEO</div>
<div class=”td-set-theme-style”>SPORT</div>
<div class=”td-set-theme-style”>CLASSIC BLOG</div>
</div>
<div class=”clearfix”></div>
<div class=”td-set-hide-show”>HIDE</div>
</div>
<?php
}
}
