Skip to content

Instantly share code, notes, and snippets.

View ko31's full-sized avatar
I want to play catch!

Ko Takagi ko31

I want to play catch!
View GitHub Profile
@ko31
ko31 / debug_future_post.php
Created August 1, 2019 02:47
WooCommerce サイトで予約投稿が実行されているかログを取った時に使ったプラグイン
<?php
/*
Plugin Name: デバッグ用
Description: WooCommerce サイトで予約投稿が実行されているかログを取った時に使ったプラグイン
Author: ko31
Author URI: https://go-sign.info
*/
add_action( 'publish_future_post', function( $post_id ) {
if ( function_exists( 'wc_get_logger' ) ) {
$logger = wc_get_logger();
@ko31
ko31 / sample.sh
Created July 13, 2019 12:14
IBM Translation API check command
curl --user apikey:[REPLACE YOUR API KEY] --request POST --header "Content-Type: application/json" --data '{"text":"this is a pen","source":"en","target":"zh-TW"}' "https://gateway.watsonplatform.net/language-translator/api/v3/translate?version=2018-05-01"
@ko31
ko31 / functions.php
Last active June 28, 2019 12:41
WP Show Posts のデータ表示条件を PHP から変更するサンプル
<?php
/**
* WP Show Posts のデータ表示条件を PHP から変更するサンプル
*/
add_filter( 'wpsp_settings', function( $settings ) {
// 検索対象をカテゴリーにする
$settings['taxonomy'] = 'category';
@ko31
ko31 / prefecture.txt
Created June 26, 2019 02:41
Contact Form 7 セレクトボックス選択項目用の都道府県データ
"北海道" "青森県" "岩手県" "宮城県" "秋田県" "山形県" "福島県" "茨城県" "栃木県" "群馬県" "埼玉県" "千葉県" "東京都" "神奈川県" "新潟県" "富山県" "石川県" "福井県" "山梨県" "長野県" "岐阜県" "静岡県" "愛知県" "三重県" "滋賀県" "京都府" "大阪府" "兵庫県" "奈良県" "和歌山県" "鳥取県" "島根県" "岡山県" "広島県" "山口県" "徳島県" "香川県" "愛媛県" "高知県" "福岡県" "佐賀県" "長崎県" "熊本県" "大分県" "宮崎県" "鹿児島県" "沖縄県"
@ko31
ko31 / wp_create_term_50on.sh
Last active June 24, 2019 23:28
WordPressでタクソノミーに50音タームを追加
#!/bin/sh
wp term create initial "あ" --slug="a"
wp term create initial "い" --slug="i"
wp term create initial "う" --slug="u"
wp term create initial "え" --slug="e"
wp term create initial "お" --slug="o"
wp term create initial "か" --slug="ka"
wp term create initial "き" --slug="ki"
wp term create initial "く" --slug="ku"
wp term create initial "け" --slug="ke"
@ko31
ko31 / 50on.tsv
Created June 24, 2019 23:12
五十音とローマ字データ
a
i
u
e
o
ka
ki
ku
ke
ko
@ko31
ko31 / wp_create_term_prefecture.sh
Created June 24, 2019 23:00
WordPressでタクソノミーに都道府県タームを登録
#!/bin/sh
wp term create prefecture "北海道" --slug="hokkaido"
wp term create prefecture "青森" --slug="aomori"
wp term create prefecture "岩手" --slug="iwate"
wp term create prefecture "宮城" --slug="miyagi"
wp term create prefecture "秋田" --slug="akita"
wp term create prefecture "山形" --slug="yamagata"
wp term create prefecture "福島" --slug="fukushima"
wp term create prefecture "茨城" --slug="ibaraki"
wp term create prefecture "栃木" --slug="tochigi"
@ko31
ko31 / bulk-delete-posts.sh
Created April 19, 2019 09:09
Shell for bulk delete posts in WordPress
#!/bin/sh
# Delete post type 'your-post-type'
for i in `seq 1 10`
do
wp post delete $(wp post list --post_type='your-post-type' --format=ids --posts_per_page=10000) --force
done
echo "done"
@ko31
ko31 / bulk-delete-posts.sql
Last active April 19, 2019 08:52
SQL for bulk delete posts, attachments, and meta in WordPress
DELETE
POST,
POST_META,
ATT,
ATT_META
FROM wp_posts POST
LEFT JOIN wp_postmeta POST_META
ON POST.ID = POST_META.post_id
LEFT JOIN wp_posts ATT
ON POST.ID = ATT.post_parent
@ko31
ko31 / set_extentions.sh
Created March 2, 2019 09:07
Set extension from file format to image file
#/bin/sh
SOURCE=images/*
for file in ${SOURCE}; do
mime=$( file -b --mime "${file}" | grep -o '.*;' )
case $mime in
"image/bmp;" ) ext=bmp ;;