//Làm đẹp code HTML ngay hàng thẳng lối
add_action('get_header', 'gkp_html_minify_start');
function gkp_html_minify_start() {
ob_start( 'gkp_html_minyfy_finish' );
}
function gkp_html_minyfy_finish( $html ) {
// Suppression des commentaires HTML,
// sauf les commentaires conditionnels pour IE
$html = preg_replace('/<!--(?!s*(?:[if [^]]+]|!|>))(?:(?!-->).)*-->/s', '', $html);
// Suppression des espaces vides
$html = str_replace(array("\r", "\r\n", "\n\r", "\n\n", "\t"), '', $html);
while ( stristr($html, ' '))
$html = str_replace(' ', ' ', $html);
return $html;
}
//Loại bỏ một chuyên mục nào đó ra khỏi trang chủ
function exclude_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-62' );
}
return $query;
}
add_filter( 'pre_get_posts', 'exclude_category_home' );
//Loại bỏ phiên bản wordpress trong code.
function wpbeginner_remove_version() {
return '';
}
add_filter('the_generator', 'wpbeginner_remove_version');
//Loại bỏ phiên bản trong đuôi CSS và Script dạng ?ver=4.6.1
function vc_remove_wp_ver_css_js( $src ) {
if ( strpos( $src, 'ver=' ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
add_filter( 'script_loader_src', 'vc_remove_wp_ver_css_js', 9999 );
//Loại bỏ hentry trong class
function isa_remove_hentry_class( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) );
return $classes;
}
add_filter( 'post_class', 'isa_remove_hentry_class' );
Tiếp tục cập nhật….