Skip to content

Instantly share code, notes, and snippets.

View fumikito's full-sized avatar
🐕
Have 1 dog. Her name is Packing.

Takahashi Fumiki fumikito

🐕
Have 1 dog. Her name is Packing.
View GitHub Profile
@fumikito
fumikito / setup.sh
Last active June 19, 2018 06:52
さくらインターネットのレンタルサーバーでやること
# シェルBashに変更(要パスワード入力)
chsh -s /usr/local/bin/bash
echo "export LANG=ja_JP.UTF-8" >> .bash_profile
source .bash_profile
# 鍵認証(コピペ)
vim ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# コマンドインストール
#!/usr/bin/env php
# 利用方法
# 1. このファイルをホームフォルダなどのパスが通っている場所に maisu として保存します。
# wget https://gist.githubusercontent.com/fumikito/5496923ec71e4cc891f263029be79dec/raw/6154450c6a547d14522a2ee7aa6ffd438fcfe3b7/maisu.php -O ~/bin/maisu
# 2. 実行権限を付与します。
# chmod +x maisu
# 3. ファイルを指定して実行します。
# maisu example.txt
# => 400字詰原稿用紙(20字×20行)換算で1枚(12行)です。
#
@fumikito
fumikito / wp-import.sh
Created September 30, 2019 08:08
Import theme unit test data from WP-CLI.
#!/usr/bin/env bash
set -e
# Activate WP Importer plugin.
wp plugin install wordpress-importer --activate
# Don't know why, but failed importing directly.
wget https://raw.githubusercontent.com/WPTRT/theme-unit-test/master/themeunittestdata.wordpress.xml
# Import
wp import themeunittestdata.wordpress.xml --authors=create
@fumikito
fumikito / regisgter_post_or_taxonomy_labels.php
Created January 23, 2020 06:56
Arguments of WordPress post and taxonomy labels to copy & paste.
<?php
$post_labels = [
'name' => __( '', 'domain' ),
'singular_name' => __( '', 'domain' ),
'add_new' => __( '', 'domain' ),
'add_new_item' => __( '', 'domain' ),
'edit_item' => __( '', 'domain' ),
'new_item' => __( '', 'domain' ),
'view_item' => __( '', 'domain' ),
'view_items' => __( '', 'domain' ),
@fumikito
fumikito / hide-cf7.php
Created February 27, 2020 10:47
Hide recaptcha v3 on every page with Contact Form 7
<?php
/**
* Remove recaptcha if it's not contact form.
*/
add_action( 'wp_enqueue_scripts', function() {
if ( is_singular() && has_shortcode( get_queried_object()->post_content, 'contact-form-7' ) ) {
return;
}
wp_deregister_script( 'google-recaptcha' );
@fumikito
fumikito / lazy-load-images.php
Last active March 16, 2020 04:27
Add lazy attributes to all img tags in WordPress.
<?php
/**
* Add loading="lazy" and decodiing="async"
*
* @see https://spelldata.co.jp/blog/blog-2019-12-19.html
*/
/**
* Start buffer for img attributes.
*/
@fumikito
fumikito / gianism-login-button.php
Created October 19, 2020 10:38
Change label for Gianism login button
<?php
/**
* Gianismのログインボタンのラベルを変更
*
* @param string $label
* @param bool $register
* @param string $context
* @return string
*/
add_filter( 'gianism_login_button_label', function( $label, $register, $context ) {
@fumikito
fumikito / block-editor-notice.js
Created November 27, 2020 08:16
Display notice depending on the contents in WordPress block editor
/*!
* Test document.
*
* @deps wp-data, wp-dom-ready
*/
const { data, domReady } = wp;
const wordLimiter = {
80: false,
@fumikito
fumikito / block-editor-modal.js
Last active November 28, 2020 15:56
Force something in block editor and change post title programatically
/*!
* Force post title to include "WordPress"
*
* @deps wp-data, wp-dom-ready, wp-element, wp-components
*/
const { data, domReady } = wp;
const { render, Component } = wp.element;
const { Modal, Button, TextControl } = wp.components;
@fumikito
fumikito / yamato-b2-change-shipping-from.php
Created December 21, 2020 06:18
注文の請求先と配送先が異なる時、Yamato B2 Exporter for WooCommerceプラグインの出力するCSVを変更します。
<?php
/*
Plugin Name: Yamato B2 Exporter Change Shipping From
Plugin URI: https://kunoichiwp.com/product/plugin/yamato-b2-exporter
Description: 注文の請求先と配送先が異なる時、Yamato B2 Exporter for WooCommerceプラグインの出力するCSVを変更します。
Version: 1.0.0
Author: Hametuha INC.
Author URI: https://kunoichiwp.com/product/plugin/yamato-b2-exporter
License: GPLv3 or later
*/