Skip to content

Instantly share code, notes, and snippets.

@neltseng
neltseng / functions.php
Created May 31, 2017 06:38
增加購買商品欄位至訂單列表 for Woo v3
// 增加購買商品欄位至訂單列表 for Woo v3
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('購買商品');
@neltseng
neltseng / cw-woocommerce-rename-shipping-package1.php
Last active July 7, 2017 04:11
WooCommerce v3.0 - 覆蓋運送方式 1 的翻譯
<?php
/*
Plugin Name: Change Shipping Package Name
Plugin URI: https://cloudwp.pro/
Description: 覆蓋運送方式 1 的翻譯
Author: Nel Tseng
Version: 0.1
Author URI: https://cloudwp.pro/
*/
@neltseng
neltseng / order-note.php
Last active June 15, 2020 05:49
Add customer order notes to order list for WooCommerce v3.3
// Add customer order notes for order list with v3.3
add_filter( 'manage_edit-shop_order_columns', 'custom_shop_order_column', 20 );
function custom_shop_order_column( $columns )
{
$ordered_columns = array();
foreach( $columns as $key => $column ){
$ordered_columns[$key] = $column;
if( 'order_date' == $key ){
$ordered_columns['order_notes'] = '訂單備註';
@neltseng
neltseng / server.badbots
Created July 17, 2018 13:19 — forked from hans2103/server.badbots
NGINX to block bad bots. (add Twenga|TwengaBot if you want to exclude them too)
if ($http_user_agent ~* (360Spider|80legs.com|Abonti|AcoonBot|Acunetix|adbeat_bot|AddThis.com|adidxbot|ADmantX|AhrefsBot|AngloINFO|Antelope|Applebot|BaiduSpider|BeetleBot|billigerbot|binlar|bitlybot|BlackWidow|BLP_bbot|BoardReader|Bolt\ 0|BOT\ for\ JCE|Bot\ mailto\:craftbot@yahoo\.com|casper|CazoodleBot|CCBot|checkprivacy|ChinaClaw|chromeframe|Clerkbot|Cliqzbot|clshttp|CommonCrawler|comodo|CPython|crawler4j|Crawlera|CRAZYWEBCRAWLER|Curious|Curl|Custo|CWS_proxy|Default\ Browser\ 0|diavol|DigExt|Digincore|DIIbot|discobot|DISCo|DoCoMo|DotBot|Download\ Demon|DTS.Agent|EasouSpider|eCatch|ecxi|EirGrabber|Elmer|EmailCollector|EmailSiphon|EmailWolf|Exabot|ExaleadCloudView|ExpertSearchSpider|ExpertSearch|Express\ WebPictures|ExtractorPro|extract|EyeNetIE|Ezooms|F2S|FastSeek|feedfinder|FeedlyBot|FHscan|finbot|Flamingo_SearchEngine|FlappyBot|FlashGet|flicky|Flipboard|g00g1e|Genieo|genieo|GetRight|GetWeb\!|GigablastOpenSource|GozaikBot|Go\!Zilla|Go\-Ahead\-Got\-It|GrabNet|grab|Grafula|GrapeshotCrawler|GTB5|GT\:\:WWW|Guzz
@neltseng
neltseng / wp-remove-default-image-sizes.php
Created July 25, 2018 11:31 — forked from iftee/wp-remove-default-image-sizes.php
Custom filter to remove default image sizes (WordPress and WooCommerce) from your theme.
<?php
/*
* Custom filter to remove default image sizes from WordPress.
*/
/* Add the following code in the theme's functions.php and disable any unset function as required */
function remove_default_image_sizes( $sizes ) {
/* Default WordPress */
unset( $sizes[ 'medium' ]); // Remove Thumbnail (150 x 150 hard cropped)
@neltseng
neltseng / delete all orders
Created July 26, 2018 10:03
Delete WooCommerce orders FORM
DELETE FROM wp_woocommerce_order_itemmeta;
DELETE FROM wp_woocommerce_order_items;
DELETE FROM wp_comments WHERE comment_type = 'order_note';
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' );
DELETE FROM wp_posts WHERE post_type = 'shop_order';
DELETE FROM wp_posts WHERE post_type = 'shop_subscription';
// Woo Core
DELETE FROM `wp_postmeta` WHERE meta_key LIKE '%_billing%';