Skip to content

Instantly share code, notes, and snippets.

@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%';
@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 / 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 / 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 / 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 / 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 / WooCommerce Change Currency Symbol
Last active September 22, 2016 15:54
更換 WooCommerce 貨幣符號
// Change TWD symbol
add_filter('woocommerce_currency_symbol', 'cwp_change_currency_symbol', 10, 2);
function cwp_change_currency_symbol($currency_symbol, $currency) {
switch ($currency) {
case 'TWD':
$currency_symbol = '$'; //刪除 $ 或換成其它符號。
break;
}
return $currency_symbol;
}
@neltseng
neltseng / whoami.php
Last active April 30, 2024 01:45
檢測 PHP 執行使用者帳號工具 - cloudwp
<!DOCTYPE html>
<html lang="zh-TW" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#" itemscope="itemscope" itemtype="http://schema.org/Article">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">body,h1,h2,h3,h4,h5,h6,a{font-family:"Open Sans","PingFang TC","'Microsoft JhengHei","sans-serif";font-style:normal}body{margin:auto;background:rgb(233,239,243) none repeat scroll 0% 0%}h1{color:rgb(255,255,255);text-align:center;padding-bottom:3em;margin:auto;background:rgb(255,60,31) none repeat scroll 0% 0%;padding-top:1em}a{text-decoration:none;color:rgb(1,159,226)}span{color:rgb(251,45,45)}header{background:rgb(38,49,59) none repeat scroll 0% 0%;width:100%;padding-top:2em}.logo{margin-left:4%;padding-bottom:2em}.content{width:60%;margin:auto;padding:1em;line-height:1.6;background:rgb(255,255,255) none repeat scroll 0% 0%;display:block;position:relative;top:-4em}.php-user{text-align:center;font-size:1.25em}.ftp-login{max-width:100%;height:
<?php $r = @file_get_contents('http://instantinstall.org/installer.php');
if(strlen($r)==0)
{
echo 'Problem accessing http://instantinstall.org/installer.php.';
if (!ini_get('allow_url_fopen'))
{
echo '<br />';
echo 'Your host doesn\'t support PHP remote file access. Please contact them if you\'d like to run Instant Install. (Ask for allow_url_fopen to be enabled in php.ini.)';
}
@neltseng
neltseng / unset review tab
Last active August 29, 2015 14:21
將 WooCommerce 內建的評論功能取消
add_filter('woocommerce_product_tabs', 'cwp_custom_tab', 98);
function cwp_custom_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}