Skip to content

Instantly share code, notes, and snippets.

View ajmaurya99's full-sized avatar
🎯
Focusing

Ajay Maurya ajmaurya99

🎯
Focusing
View GitHub Profile
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 13:49
Remove Jquery from front side of WordPress.
<?php
wp_deregister_script('jquery');
wp_register_script('jquery', false);
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 13:47
Increase Autoptimize cache size from default 512 MB to 2 GB
<?php
add_filter('autoptimize_filter_cachecheck_maxsize', function () {
return 2 * 1024 * 1024 * 1024; // 2 GB
}, 10, 1);
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 13:39
Disable autoptimize toolbar in Wordpress
<?php
add_filter('autoptimize_filter_toolbar_show', '__return_false');
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 13:23
Disable Emojis in WordPress With Code
<?php
/**
* Disable the emoji's
*/
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 13:19
WordPress Disable Emojis DNS Prefetch
<?php
/**
* Disable Emojis DNS Prefetch
* @return string
*/
add_filter( 'wp_resource_hints', 'disable_emojis_dns_prefetch', 10, 2);
function disable_emojis_dns_prefetch( $urls, $relation_type ) {
if ( 'dns-prefetch' == $relation_type ) {
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' );
$urls = array_diff( $urls, array( $emoji_svg_url ) );
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 12:57
Disable Autoptimize toolbar from frontend pages.
add_action('admin_bar_menu', function() {
if (!is_admin()) {
global $wp_admin_bar;
$wp_admin_bar->remove_node( 'autoptimize' );
}
}, 101, 1);
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 12:55
Hide Autoptimize clear cache button for users in WordPress Dashboard.
// This style hides the autoptimize clear cache button for users in WordPress Dashboard.
add_action('admin_head', function() { ?>
<style>
#wp-admin-bar-autoptimize-delete-cache,
.wp-core-ui .button-primary[name="autoptimize_cache_clean"] {
display: none;
}
</style>
<?php }, 10, 1);
@ajmaurya99
ajmaurya99 / utils.php
Created October 12, 2020 12:36
WordPress add class to body tag for all the pages.
add_filter('body_class', 'wp_body_class');
function wp_body_class($class)
{
$class[] = 'my-custom-class'; // Add your class name here. Multiple class names can be added 'classname1 classname2'.
return $class;
}
@ajmaurya99
ajmaurya99 / meta-tags.md
Last active September 25, 2020 06:24 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>