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 / backup.sh
Created July 15, 2023 00:40
Shell script to export the backup file using the WP-CLI command of All-in-One WP Migration
#!/usr/local/bin/bash
# Set backup directory
BACKUP_DIR=/path/to/wordpress/wp-content/ai1wm-backups/
# Change directory to the WordPress
cd $BACKUP_DIR
# Run the wp-cli command to export the backup file
wp ai1wm backup
@ko31
ko31 / memo.md
Created March 3, 2023 06:05
さくらレンタルサーバでマルチドメイン、サブディレクトリ毎にPHPバージョンを切り替える方法

さくらレンタルサーバのコントロールパネルではマルチドメイン毎に PHP バージョンを設定できないので、以下の方法で設定する。 (同じ方法でサブディレクトリ毎に設定することも可能。)

対象ディレクトリに、以下の内容で php.cgi ファイルを設置する。

#!/bin/sh
exec /usr/local/php/7.4/bin/php-cgi
<?php
/**
* Imports files and images( except cover and profile photo )
* @since UM 2.0
*
* Sample Usage:
* - Fields should be created first in the UM Form Builder.
* - Files should be added to /wp-content/uploads/ultimatemember/<user_id>/ before running the import function.
*
* add_action('init', function(){
@ko31
ko31 / 2022sensyuken.geojson
Created August 7, 2022 06:35
第104回全国高等学校野球選手権大会出場校マップ
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ko31
ko31 / 2022_sensyuken_school.csv
Created August 1, 2022 09:14
第104回全国高等学校野球選手権大会出場校一覧
地区 学校 出場回数 住所 URL
北北海道 旭川大高 3年ぶり10度目 北海道旭川市永山7条16丁目3−16 http://www.asahikawa-uhs.ed.jp/
南北海道 札幌大谷 初出場 北海道札幌市東区北16条東9丁目1 https://www.s-ohtani.ed.jp/
青森 八戸学院光星 3年ぶり11度目 青森県八戸市湊高台6丁目14−5 http://kh.hachinohe-u.ac.jp/
岩手 一関学院 12年ぶり7度目 岩手県一関市八幡町5−24 https://ichinoseki-gakuin.jp/
秋田 能代松陽 11年ぶり4度目 秋田県能代市緑町4−7 http://www.noshiroshoyo-h.akita-pref.ed.jp/
山形 鶴岡東 3年ぶり7度目 山形県鶴岡市切添町22−30 https://tsuruokahigashi.net/
宮城 仙台育英 3年ぶり29度目 宮城県仙台市宮城野区宮城野2の4の1 https://www.sendaiikuei.ed.jp/hs/
福島 聖光学院 3年ぶり17度目 福島県伊達市六角3−2 https://www.seikogakuin.jp/
茨城 明秀学園日立 初出場 茨城県日立市神峰町3丁目2−26 https://www.meishu.ac.jp/
@ko31
ko31 / functions.php
Last active October 20, 2021 07:24
How to replace the input values of a checkbox to the email body with a line break in Contact Form 7.
add_filter( 'wpcf7_mail_tag_replaced', function ( $replaced, $submitted, $html, $mail_tag ) {
// In this case, the value of "options" tag will be replaced.
if ( 'options' === $mail_tag->field_name() ) {
$replaced = implode( "\n", $submitted );
}
return $replaced;
}, 10, 4 );
@ko31
ko31 / biz-calendar-shortcode.php
Created August 9, 2021 01:01
Biz Calendar プラグインのカレンダーをショートコードから出力する
<?php
/*
Plugin Name: Biz Calendar Shortcode
Plugin URI: https://gist.github.com/ko31
Description: Biz Calendar のカレンダーをショートコードから出力
Version: 0.1.0
Author: ko31
Author URI: https://go-sign.info
*/
@ko31
ko31 / sample.sh
Created May 13, 2021 08:35
How to send a reply text message from the console using the LINE Message API
# via Messaging API reference
# https://developers.line.biz/en/reference/messaging-api/#text-message
# Send text message
curl -v -X POST https://api.line.me/v2/bot/message/push \
-H 'Content-Type:application/json' \
-H 'Authorization: Bearer {your channel access token}' \
-d '{
"to": "{userId}",
"messages":[
@ko31
ko31 / how-to-send-an-email-manually-using-woocommerce-email-templates.php
Last active August 25, 2023 20:32
How to send an email manually using WooCommerce email templates.
<?php
// Load the WooCommerce email templates.
$wc_emails = WC()->mailer()->get_emails();
/**
* You can specify which template mail is to be sent from the following array elements.
* 'WC_Email_New_Order'
* 'WC_Email_Cancelled_Order'
* 'WC_Email_Failed_Order'
* 'WC_Email_Customer_On_Hold_Order'
@ko31
ko31 / ldap.php
Created September 25, 2020 14:35
A sample code of user authentication with LDAP from PHP
<?php
// LDAP settings
const LDAP_HOST = "ldap-host";
const LDAP_PORT = 389;
const LDAP_DC = "dc=example,dc=com";
const LDAP_CN = "admin";
const LDAP_PASS = "password";
// Connect
$ldap_conn = ldap_connect(LDAP_HOST, LDAP_PORT);