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 / 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 September 13, 2024 02:53
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');
@khoipro
khoipro / README.md
Last active June 11, 2024 11:48
Hướng dẫn cài đặt và sử dụng plugin Simple Store Maps

Giới thiệu

  • Plugin được phát hành dành cho thành viên của nhóm Tối ưu web ✪.
  • Đây là plugin thử nghiệm nên nếu có lỗi phát sinh, bạn hãy comment trong group nhé.

Demo

Xem demo

Bản quyền

@khoipro
khoipro / sample.php
Last active May 30, 2024 03:12
Sort items in PHP array, define only first and specific index item
<?php
$first_id = 110;
$items = [
[
'id' => 101,
'content' => 'Test 1'
],
[
@khoipro
khoipro / functions.php
Last active May 21, 2024 02:19
[Public] GSC Redirections 404 products to best-selling category
<?php
/**
* Redirect product 404 page to /best-selling/ page
*
* @package chuyendev
* @author codetot
* @since 0.0.1
**/
add_action('template_redirect', function() {
if ( is_404() ) {