Skip to content

Instantly share code, notes, and snippets.

@tdtgit
tdtgit / functions.php
Last active February 4, 2022 19:35
HTTP/2 Push CSS/JS with Autoptimize WordPress's plugin
<?php
add_filter('autoptimize_filter_cache_getname', 'pushAOFiles');
function pushAOFiles($in) {
$pushType = substr($in, strrpos($in, ".") + 1) === "js" ? "script" : "style";
// Do not push CSS files if it is already inline.
if ($pushType == "style" && ((bool)get_option("autoptimize_css_inline", true))) return;
/**
* Disable zxcvbn.min.js on WordPress loading
*/
function deregister_or_dequeue_scripts() {
wp_dequeue_script('wc-password-strength-meter');
}
add_action('wp_print_scripts', 'deregister_or_dequeue_scripts', 20);
function td_mobile_menu_toogle() {
jQuery('#td-top-mobile-toggle a, .td-mobile-close a').click(function(e) {
if (jQuery('body').hasClass('td-menu-mob-open-menu')) {
jQuery('body').removeClass('td-menu-mob-open-menu');
} else {
jQuery('body').addClass('td-menu-mob-open-menu');
}
e.preventDefault();
});
jQuery(document).find('#td-mobile-nav .menu-item-has-children').each(function(i) {
<?php
/* Developed by Juno_okyo */
/* Edited by tdtgit */
// EDIT HERE
define('ACCESS_TOKEN', 'YOUR_ACCESS_TOKEN');
// EDIT HERE
// ID thành viên sẽ bị bỏ qua khi quét
@tdtgit
tdtgit / rclone_backup.sh
Last active July 30, 2021 00:05
Rclone Backup Script
#!/bin/bash
#v=1.0
SERVER_NAME=
TIMESTAMP=$(date +"%F-%H-%M")
SECONDS=0
BACKUP_DIR="/root/backup/$TIMESTAMP"
MYSQL=/usr/bin/mysql
MYSQL_USER=root
MYSQL_PASSWORD=
@tdtgit
tdtgit / functions.php
Last active July 26, 2017 15:18
Disable WordPress comment URL field
// Above code...
function wp_disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields', 'wp_disable_comment_url');
@tdtgit
tdtgit / mysql_backup.sh
Created June 15, 2017 14:59
Backup nhanh toàn bộ CSDL MySQL
#!/bin/bash
TIMESTAMP=$(date +"%F-%H-%M")
BACKUP_DIR="/root/backup/$TIMESTAMP"
MYSQL_USER="root"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD=<MYSQL_PASSWORD_GO_HERE>
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/sql"
<?php
// Allow logged-in user see private posts in
add_action('pre_get_posts','filter_search');
function filter_Search($query){
if( is_admin() || ! $query->is_main_query() ) return;
if( current_user_can('edit_private_posts') ) {
$query->set('post_status',array('private','publish'));
}
<link rel="manifest" href="/manifest.json">
{
"short_name": "Đ.A.T",
"name": "Website của Tuấn",
"icons": [
{
"src": "launcher96.png",
"sizes": "96x96",
"type": "image/png"
},
{