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
<?php
/**
* Use redis cache
*
* @package codetot-optimization
* @author codetot
* @since 0.0.1
*/
class Sample_Redis_Cache {
@khoipro
khoipro / sample.html
Last active November 2, 2024 13:43
Using lazysizes to improve image load. - Sample by CODETOT @khoipro
<!doctype html>
<html lang="en">
<head>
<link rel="preconnect" href="https://cdnjs.cloudflare.com" crossorigin>
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.3.2/lazysizes.min.js" as="script" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.3.2/lazysizes.min.js">
</head>
<body>
<div class="in-first-view">
<img src="image-1.jpg" width="640" height="480" alt="">
@khoipro
khoipro / my.cnf
Created November 2, 2024 10:54
Tweak MySQL for better performance
# CPU = 4
# RAM = 8GB
# Website = WordPress, WooCommerce, >1k products
# Cache = W3 Total Cache
[mysql]
port = 3306
[mysqld]
performance_schema = ON
@khoipro
khoipro / regex.md
Created September 30, 2024 04:16
Insert data into wp_options without adding option_id

Sample data

INSERT INTO `qUj_options` (`option_id`, `option_name`, `option_value`, `autoload`) VALUES
('nav_menu_options',	'a:2:{i:0;b:0;s:8:\"auto_add\";a:0:{}}',	'yes'),
('_options_en_US_h_section1_label',	'field_66ac4f4535309',	'off'),
('_options_en_US_h_section1_title',	'field_66ac4f523530a',	'off'),
('_options_en_US_h_section13_preview',	'field_66f15be9ceab9',	'off');
@khoipro
khoipro / free.txt
Last active November 4, 2024 05:01
Free download some leaked keys
https://rankmath.com/download/510590/seo-by-rank-math-pro.zip?username=thachpham&api_key=e5cd5c67cafe7d5e7315558011457319
@khoipro
khoipro / functions.php
Created September 11, 2024 14:46
Sample extends with a plugin Simple Sticky Contacts (v0.0.6+)
<?php
// Sample extends with a plugin Simple Sticky Contacts (v0.0.6+)
add_action('init', 'codetot_theme_ssc_init', 10);
function codetot_theme_ssc_init() {
add_filter('ssc_icons', 'codetot_theme_ssc_icons');
add_filter('ssc_get_fields', 'codetot_theme_ssc_fields');
add_filter('ssc_svg_icon_map', 'codetot_theme_ssc_icon_map');
}
@khoipro
khoipro / .htninja
Last active September 11, 2024 01:32
Ninjafirewall : Whitelist admin actions and keep original IP with CloudFlare
<?php
/**
* Ninjafirewall Custom Rules
*
* @package codetot-maintenance
* @author codetot
* @since 0.0.1
**/
if ( !empty($_POST['_wpnonce']) && strpos($_SERVER['SCRIPT_NAME'], '/wp-admin/post.php') !== FALSE ) {
@khoipro
khoipro / functions.php
Last active September 10, 2024 04:20
Fix image not upload in WordPress
<?php
// Error while uploading image: The server cannot process the image. This can happen if the server is busy or does not have enough resouces to complete the task.
// Error (Vietnamese): Máy chủ không thể xử lý hình ảnh.
function codetot_image_editor_default_to_gd_library( $editors ) {
$gd_editor = 'WP_Image_Editor_GD';
$editors = array_diff( $editors, array( $gd_editor ) );
array_unshift( $editors, $gd_editor );
return $editors;
@khoipro
khoipro / notify-slack.sh
Created August 29, 2024 14:44
Sample Bash script to trigger web hook in Slack
#!/bin/bash
slack_webhook_url="https://hooks.slack.com/services/xxx"
function send_slack_message() {
message="$1"
curl -X POST -H 'Content-type: application/json' --data "{\"text\": \"$message\"}" "$slack_webhook_url"
}
@khoipro
khoipro / functions.php
Last active June 6, 2024 05:20
Display product tabs reviews with count
<?php
/**
* Override WooCommerce Hooks
*
* @package woocommerce-extends
* @author Khoi Pro <[email protected]>
* @since 0.0.1
**/
add_filter('woocommerce_product_tabs', 'chuyendev_woocommerce_product_tabs');