Skip to content

Instantly share code, notes, and snippets.

View khoipro's full-sized avatar
💭
#devops #wordpress #vuejs #docker

Nguyễn Minh Khôi khoipro

💭
#devops #wordpress #vuejs #docker
View GitHub Profile
@khoipro
khoipro / functions.php
Created April 13, 2016 09:09
Remove CSS & JS version from default WordPress setting
// remove css js version
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 );
@khoipro
khoipro / functions.php
Last active March 17, 2019 18:40
Remove menu's classes and ids.
// remove menu class and keep class to active item only
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
add_filter('page_css_class', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var) {
return is_array($var) ? array_intersect($var, array('current-menu-item')) : '';
}
@khoipro
khoipro / functions.php
Created April 13, 2016 09:14
Remove short link in WordPress header
// remove short link
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
@khoipro
khoipro / functions.php
Created April 13, 2016 09:17
Remove Emoji on WordPress
// remove EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@khoipro
khoipro / functions.php
Created April 13, 2016 09:19
Remove default stylesheets from frontend WordPress
// remove auto stylesheet from admin + wp
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
function my_deregister_styles() {
wp_deregister_style( 'dashicons' );
wp_deregister_style( 'admin-bar' );
wp_deregister_style( 'open-sans' );
wp_deregister_style( 'boxes' );
}
@khoipro
khoipro / header.php
Created April 13, 2016 09:23
Default stylesheet in WordPress header.
<style type="text/css">
img.wp-smiley,
img.emoji {
display: inline !important;
border: none !important;
box-shadow: none !important;
height: 1em !important;
width: 1em !important;
margin: 0 .07em !important;
vertical-align: -0.1em !important;
@khoipro
khoipro / functions.php
Created April 13, 2016 09:31
Adding thumbnail support for posts in WordPress
if (function_exists('add_theme_support')) {
add_theme_support('post-thumbnails');
}
set_post_thumbnail_size( 70, 70);
add_image_size( 'single-post-thumbnail', 600, 350 );
@khoipro
khoipro / functions.php
Created April 14, 2016 04:17
Clean WordPress Menu's classes
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
'vertical',
@khoipro
khoipro / functions.php
Last active February 15, 2024 16:05
Remove Unnecessary Code in WordPress Header
// Remove Meta Generator: <meta name="generator" content="WordPress x.x" />
// and <meta name="generator" content="WooCommerce x.x.x" />
remove_action('wp_head', 'wp_generator');
// Remove the EditURI/RSD
// Like: <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://localhost/wp/xmlrpc.php?rsd" />
remove_action ('wp_head', 'rsd_link');
// Remove it if you don't know what is Windows Live Writer
// <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://localhost/wp/wp-includes/wlwmanifest.xml" />
@khoipro
khoipro / .htaccess
Created May 12, 2016 05:01
CSS Fonts missing - No Access-Control-Allow-Origin header
# ----------------------------------------------------------------------
# CORS-enabled images (@crossorigin)
# ----------------------------------------------------------------------
# Send CORS headers if browsers request them; enabled by default for images.
# developer.mozilla.org/en/CORS_Enabled_Image
# blog.chromium.org/2011/07/using-cross-domain-images-in-webgl-and.html
# hacks.mozilla.org/2011/11/using-cors-to-load-webgl-textures-from-cross-domain-images/
# wiki.mozilla.org/Security/Reviews/crossoriginAttribute
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>