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 / 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() ) {
@khoipro
khoipro / functions.php
Created April 23, 2024 07:52
WP Sample function convert Youtube URL (ACF) to post content (for using existing Embeds feature in WordPress)
<?php
// For example, logged in to your WordPress and hit http://sample.com/?action=update_videos once
add_action('wp', function() {
if ( !is_user_logged_in() ) return;
if ( empty( $_GET['action'] ) ) return;
if ($_GET['action'] !== 'update_videos') return;
@khoipro
khoipro / .htaccess
Created April 17, 2024 09:13
Maintenance Web (index.html)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.html
RewriteRule ^ /index.html [R=302]
</IfModule>
@khoipro
khoipro / mixins.css
Last active March 10, 2024 04:40
postCSS Mixins to help you save your CSS time
@define-mixin bottom-line-left $color, $height: 4px, $width: 60px, $padding: 0.25em, $margin: 1em {
position: relative;
margin-bottom: $margin;
padding-bottom: $padding;
&::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
@khoipro
khoipro / .htaccess
Last active January 27, 2024 00:48
Run a WP maintenance task
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]