Skip to content

Instantly share code, notes, and snippets.

Avatar

mt8.biz mt8

View GitHub Profile
@mt8
mt8 / functions.php
Last active Nov 24, 2020
[WordPress] Change the theme zip update folder to /tmp instead of /uploads .
View functions.php
<?php
add_filter( 'upload_dir', function ( $dir ) {
global $pagenow;
if ( ! isset( $pagenow ) || 'update.php' !== $pagenow ) {
return $dir;
}
if ( ! isset( $_REQUEST['action'] ) || 'upload-theme' !== $_REQUEST['action'] ) {
return $dir;
}
@mt8
mt8 / bash.sh
Created Nov 18, 2020
Local by flywheel の仮想ディスクを圧縮
View bash.sh
#https://qiita.com/Gushi_maru/items/3efd3e5ac497f25f7606
#http://satorumpen.blogspot.com/2014/03/vagrant.html
#https://qiita.com/RyujiAMANO/items/a904399b7c45d1f0b658
#Local で
sudo dd if=/dev/zero of=zero bs=4k; \rm zero
#Mac から
$ cd /Users/kzuut/.docker/machine/machines/local-by-flywheel
@mt8
mt8 / wp-cli-on-xserver.sh
Last active Oct 7, 2020
エックスサーバー でwp-cliをPHPバージョン指定して動かすエイリアス
View wp-cli-on-xserver.sh
echo 'alias wp="/opt/php-7.4.4/bin/php /usr/bin/wp"' >> ~/.bashrc
source ~/.bashrc
@mt8
mt8 / funcitons.php
Last active Jul 9, 2020
[WordPress] #WordPress の #Auth0 プラグインで、Twitter認証したときにプロフィール名がカタカナだとWordPressユーザー作成に失敗してログインできない問題を回避する
View funcitons.php
<?php
add_filter( 'auth0_create_user_data', 'my_auth0_create_user_data' , 10, 2 );
function my_auth0_create_user_data( $user_data, $userinfo )
{
if ( ! is_null( $userinfo ) && is_object( $userinfo ) ) {
$identities = property_exists( $userinfo, 'identities' ) ? $userinfo->identities : [];
if ( is_array( $identities ) && ! empty( $identities ) ) {
$identitiy = $identities[0];
if ( ! is_null( $identitiy ) && is_object( $identitiy ) ) {
$provider = property_exists( $identitiy, 'provider' ) ? $identitiy->provider : '';
@mt8
mt8 / functions.php
Created Jul 5, 2020
[WordPress] ACFのフィールドをreadonlyにして表示専用にする
View functions.php
<?php
add_filter(
'acf/load_field/key=field_xxxxxxxxxxxxx',
function ( $field ) {
$field[ 'readonly' ] = 1;
return $field;
}
);
@mt8
mt8 / plugin.php
Last active May 8, 2020
[WordPress Plugin] MW WP Formから送信されたデータを投稿に複製する
View plugin.php
<?php
/**
* Plugin Name: MW WP Form Data 2 Post
* Description: MW WP Formから送信されたデータを投稿に複製する
* Author: mt8
* Version: 1.0
* License: GPL2
* MW WP Form Data 2 Post is free software: you can redistribute it and/or modify
*/
class MW_WP_Form_Data_2_Post {
@mt8
mt8 / .babelrc
Last active Sep 5, 2019
Block Editor Handbook やるときのwebpack設定など
View .babelrc
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
]
}
@mt8
mt8 / base_items.php
Last active Jul 31, 2019
WordPressとBASEを連携させるためのプラグイン「BASE Item List」のテンプレート機能の使い方
View base_items.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
global $base_items;
/*
* item
* item_id int
* title string
* detail string
* price int
* stock int
@mt8
mt8 / bash.sh
Created Jul 30, 2019
Local by Flywheel でインストールしたWordPresssをサブディレクトリに移動する
View bash.sh
#!/bin/bash
if [ "$1" = "" ]
then
echo "please set sub dir name"
exit 1
fi
echo "move your wp to $1!"
@mt8
mt8 / memo.sh
Last active Jun 6, 2019
Homebrewでインストールしたterraformを任意のバージョンに戻す🍺
View memo.sh
# terraformのGitコミットログを確認
$ brew log terraform
Warning: homebrew/core is a shallow clone so only partial output will be shown.
To get a full clone run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
commit 74f8f0f9c5cd3703dd36031cfada22e721b244e5
Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
Date: Tue Jun 4 19:00:44 2019 +0000
You can’t perform that action at this time.