Skip to content

Instantly share code, notes, and snippets.

View vietrick's full-sized avatar

Vietrick vietrick

View GitHub Profile
@vietrick
vietrick / wordpress-emojis-header.html
Created November 13, 2022 14:43
Wordpress Emoji code
<script>
window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/14.0.0\/svg\/","svgExt":".svg","source":{"concatemoji":"https:\/\/test.vietrick.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=6.1"}};
/*! This file is auto-generated */
!function(e,a,t){var n,r,o,i=a.createElement("canvas"),p=i.getContext&&i.getContext("2d");function s(e,t){var a=String.fromCharCode,e=(p.clearRect(0,0,i.width,i.height),p.fillText(a.apply(this,e),0,0),i.toDataURL());return p.clearRect(0,0,i.width,i.height),p.fillText(a.apply(this,t),0,0),e===i.toDataURL()}function c(e){var t=a.createElement("script");t.src=e,t.defer=t.type="text/javascript",a.getElementsByTagName("head")[0].appendChild(t)}for(o=Array("flag","emoji"),t.supports={everything:!0,everythingExceptFlag:!0},r=0;r<o.length;r++)t.supports[o[r]]=function(e){if(p&&p.fillText)switch(p.textBaseline="top",p.font="600 32px Arial",e){case"flag":return s([127987,65039,8205,989
@vietrick
vietrick / remove-wordpress-emoji.php
Created November 13, 2022 09:37
Tắt Emoji Wordpress
/**
@ Vietrick: Tắt Emoji Wordpress
*
*/
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' );
@vietrick
vietrick / functions.php
Created September 30, 2022 15:36
Remove child category in permalinks Wordpress
/*
*
* Remove child categories from permalink in Wordpress
* https://www.vietrick.com/remove-child-category-in-permalink/
*
*/
function remove_child_categories_from_permalinks( $category ) {
while ( $category->parent ) {
$category = get_term( $category->parent, 'category' );
@vietrick
vietrick / functions.php
Created June 25, 2022 07:42
Switch to WP_Image_Editor_GD
/**
@@ Sửa lỗi Post-Processing of Image Failed WordPress
@@ Sử dụng module GD Library để xử lý hình ảnh Wordpress
**/
function wpb_image_editor_default_to_gd( $editors ) {
$gd_editor = 'WP_Image_Editor_GD';
$editors = array_diff( $editors, array( $gd_editor ) );
array_unshift( $editors, $gd_editor );
return $editors;
}
@vietrick
vietrick / wp-custom-css.php
Last active February 19, 2022 10:55
Chèn CSS vào Wordpress
/**
@ VIETRICK: Chèn CSS vào theme
@ sử dụng hook wp_enqueue_scripts() để hiển thị nó ra ngoài front-end
**/
function vietrick_styles() {
/*
* Hàm get_stylesheet_uri() sẽ trả về giá trị dẫn đến file style.css của theme
* Nếu sử dụng child theme, thì file custom-style.css này vẫn load ra từ theme chính
*/
wp_register_style( 'custom-style', get_template_directory_uri() . '/custom-style.css', 'all' );
@vietrick
vietrick / vietrick-toc-style.css
Created February 19, 2022 08:49
Trang trí CSS cho Vietrick TOC
.vietrick-auto-toc{
padding:2rem 2rem 0.5rem 3rem;
margin-bottom:2rem;
background:#f5f7fa;
border-radius: 16px;
max-height:440px;
overflow:auto;
}
.vietrick-auto-toc .toc-list {
margin-left: 1.1rem;
@vietrick
vietrick / preview-vietrick-toc.html
Created February 19, 2022 08:47
Preview: tạo mục lục wordpress không dùng plugin
<h3 class="toc-title">Xem nhanh</h3>
<ul class="toc-list">
<li><a href="#giới-thiệu" class="heading-h2 toc-link smooth-scroll">Giới thiệu</a></li>
<li><a href="#tạo-mục-lục-wordpress-thủ-cong" class="heading-h2 toc-link smooth-scroll">Tạo mục lục WordPress thủ công</a>
<ul>
<li><a href="#tạo-bảng-mục-lục-wordpress" class="heading-h3 toc-link smooth-scroll">Tạo bảng mục lục wordpress</a></li>
<li><a href="#cap-nhat-anchor-link" class="heading-h3 toc-link smooth-scroll">Cập nhật anchor link</a></li>
</ul>
</li>
<li><a href="#tạo-mục-lục-wordpress-tự-dộng" class="heading-h2 toc-link smooth-scroll">Tạo mục lục WordPress tự động</a>
@vietrick
vietrick / toc-func.php
Last active September 29, 2023 14:34
Tạo và chèn bảng mục lục Wordpress tự động
<?php
/**
*
* Vietrick Custom Functions
*
* @package Vietrick
*/
@vietrick
vietrick / wp-fully-disable-gutenberg-editor.php
Created February 17, 2022 16:21
Fully disable Gutenberg
// Fully Disable Gutenberg editor.
add_filter('use_block_editor_for_post_type', '__return_false', 10);
// Don't load Gutenberg-related stylesheets.
add_action( 'wp_enqueue_scripts', 'vietrick_remove_block_css', 100 );
function vietrick_remove_block_css() {
wp_dequeue_style( 'wp-block-library' ); // Wordpress core
wp_dequeue_style( 'wp-block-library-theme' ); // Wordpress core
wp_dequeue_style( 'wc-block-style' ); // WooCommerce Block
wp_dequeue_style( 'storefront-gutenberg-blocks' ); // Storefront theme
}
<?php
//Xoa Gutenberg Block Library CSS khỏi Wordpress
function vietrick_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-blocks-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'vietrick_remove_wp_block_library_css', 100 );