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 / codetot-maintenance.php
Last active March 31, 2026 02:55
WOW - The Maintenance contains a few snippets to help you easy to stay with a website
<?php
/**
* Maintenance Hooks for WordPress
* @author CODE TOT <khoi@codetot.com>
* @link https://baotriweb.codetot.vn
**/
// Reject comments containing URLs in the comment text or website field
function codetot_maintenance_reject_comments_with_urls($commentdata) {
// Check the comment content for URLs
@khoipro
khoipro / https-performance-enhancer.php
Created March 28, 2026 05:34
Malware Sample - HTTPS performance enhancer - Don't use it!
<?php
// Malware plugin keep redirection to other site - WP Hack Exploit
/**
* Plugin Name: Performance Enhancer
* Plugin URI:
* Description: Enhances website performance through optimized resource loading
* Version: 1.0.0
* Author:
* License: GPL2
*/
@khoipro
khoipro / content.php
Created March 5, 2026 10:28
Optimize content: first image no lazyload
<?php
$counter = 0;
$content = preg_replace_callback(
'/<img([^>]+)>/i',
function ($matches) use (&$counter) {
$counter++;
$imgTag = $matches[0];
<?php
/**
* Bulk Image Resizer for PHP & MySQL Applications
* Automatically detects Imagick or GD.
*
* @package codetot-optimization
* @author codetot, khoipro, gemini
* @since 0.0.1
*
* Usage: copy to your project, and run 'php php-bulk-resize-image.php'
@khoipro
khoipro / functions.php
Created June 21, 2025 02:45
Reject any comment contain URLs, disable comment field URL
<?php
// Sử dụng: paste đoạn code vào trong file theme functions.php
// Không cần nếu bạn đã tắt comment trên web
function codetot_prevent_urls_in_comment_content( $commentdata ) {
$comment_content = $commentdata['comment_content'];
$url_pattern = '/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/i';
if ( preg_match( $url_pattern, $comment_content ) ) {
wp_die(
<?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
Last active January 21, 2025 01:51
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