Skip to content

Instantly share code, notes, and snippets.

@mt8
mt8 / somewhere.php
Created May 9, 2024 00:17
[WordPress] ACF 6.2.9 からの the_field() の自動エスケープを強制的にさせないコード
<?php
add_filter( 'acf/the_field/allow_unsafe_html', function ( $allowed, $atts ) {
return true;
}, 10, 2 );
@mt8
mt8 / functions.php
Created October 11, 2023 02:28
[WordPress] My Snow MonkeyでAdvanced Posts Blocks のテンプレート上書きをできるようにする
<?php
add_filter(
'advanced_posts_blocks_default_template_path',
function ( $template_path, $name, $query, $args ) {
$skin_template_base_dir = __DIR__ . '/override/template-parts/blocks/advanced-posts-blocks/';
if ( array_key_exists( 'p', $query->query ) ) {
$skin_template_base_dir .= 'post/';
} else {
$skin_template_base_dir .= 'posts/';
@mt8
mt8 / memo.md
Created September 10, 2023 02:17
[WordPress] Welcartの注文データ・会員データをマスクするSQL

wp db query のあとに以下のSQLを実行する

UPDATE
	wp_usces_member
SET
	mem_email = CONCAT( CONCAT( 'member', ID ), '@example.com' )
,	mem_name1 = CONCAT( '会員', ID )
,	mem_name2 = 'テスト'
@mt8
mt8 / 1.php
Last active December 18, 2020 15:03
Shifter Advent Calendar 2020 Day20
<?php
define( 'SGA4SS_GA_UA_ID', 'UA-XXXXXXXXX-X' );
define( 'SGA4SS_GA_DIMENSION_NAME', 'dimensionX' );
add_action( 'wp_footer', function () {
ob_start(); ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_html(SGA4SS_GA_UA_ID) ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
@mt8
mt8 / functions.php
Last active December 14, 2020 05:38
[WordPress] Change the theme/plugin zip update folder to /tmp instead of /uploads .
<?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 November 18, 2020 12:08
Local by flywheel の仮想ディスクを圧縮
#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 October 7, 2020 15:32
エックスサーバー でwp-cliをPHPバージョン指定して動かすエイリアス
echo 'alias wp="/opt/php-7.4.4/bin/php /usr/bin/wp"' >> ~/.bashrc
source ~/.bashrc
@mt8
mt8 / funcitons.php
Last active July 9, 2020 09:55
[WordPress] #WordPress の #Auth0 プラグインで、Twitter認証したときにプロフィール名がカタカナだとWordPressユーザー作成に失敗してログインできない問題を回避する
<?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 July 5, 2020 22:57
[WordPress] ACFのフィールドをreadonlyにして表示専用にする
<?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 13:14
[WordPress Plugin] MW WP Formから送信されたデータを投稿に複製する
<?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 {