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 / upgrade-mysql56to57-on-macports.sh
Created January 30, 2024 23:55
Update MySQL 5.6 to 5.7 on Macports / MacportsでMySQL5.6から5.7にアップデートする
# Update Macports / Macportsを最新に
sudo port selfupdate
# Stop MySQL 5.6 / MySQL 5.6を停止
sudo port unload mysql56-server
# Remove from service. / 自動起動から削除
sudo lauchctl unload -w /Library/LaunchDaemons/org.macports.mysql56-server.plist
# Install MySQL 5.7 / MySQL 5.7をインストール
@fumikito
fumikito / wp-env-restore.sh
Created April 12, 2023 06:31
Fix wp-env container
#! /usr/bin/env bash
# see https://otti.xyz/2021/05/how-to-fix-wp-env-mysqlcheck-error.html
LINE=$( docker ps | grep tests-wordpress- )
HERE=$(pwd)
LINE=${LINE##* }
LINE=${LINE%%-*}
echo "Restore container: $LINE"
@fumikito
fumikito / trait-member-property.php
Created December 8, 2022 04:54
1つのtraitを利用する2つのtraitがあり、それを1つのクラスで実装した場合の変数の扱い
<?php
trait BaseTrait {
private $counter = 0;
private $greeting = 'Hello World!';
public function say_hello() {
@fumikito
fumikito / block.js
Last active October 22, 2021 18:09
[WordPress Gutenberg] Check next block type in block editor.
const { registerBlockType, registerBlockStyle } = wp.blocks;
const { select } = wp.data;
/**
* Get next blokc from client ID.
*/
const getNextBlock = ( id ) => {
const allBlocks = select( 'core/block-editor' ).getBlocks();
let index = null;
for ( let i = 0; i < allBlocks.length; i++ ) {
@fumikito
fumikito / new_email.php
Created January 7, 2021 08:52
WordPress' update user email confirmation.
<?php
/**
* WP Core logic to change user email.
*
* This method is monolithic because it depends on admin ui.
* So if you need custom user page,
* you need re-implement these features.
*
* @see https://github.com/WordPress/WordPress/blob/master/wp-admin/user-edit.php#L100-L116
* @see https://github.com/WordPress/WordPress/blob/master/wp-includes/user.php#L2994-L3102
@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
*/
@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 / 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 / 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 / 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.
*/