Skip to content

Instantly share code, notes, and snippets.

View YuzuruSano's full-sized avatar

Yuzuru Sano (sizenkainookite) YuzuruSano

  • Kyoto,Japan
View GitHub Profile
@YuzuruSano
YuzuruSano / functions.php
Created June 25, 2019 09:47
class内でactionに追加されたメソッドを削除する / taxonomy expander利用時、最新バージョンでクイック編集が動作しないためactionを削除
<?php
/**
* クラス内で定義されたactionを削除する
*
* @param string $tag 削除したいfilter名
* @param string $class 削除したいメソッドを内容するclass名
* @param string $method 削除したいメソッド名
* @param intger $priority 優先度
* @return bool 削除の結果
*/
@YuzuruSano
YuzuruSano / index.php
Last active May 6, 2019 09:55
Cloud Translate APIの利用
<?php
//キーの取得はこちらを参考に
//https://alaki.co.jp/blog/?p=2636
require_once './vendor/autoload.php';
use Google\Cloud\Translate\TranslateClient;
//「TranslateClient」クラスを呼び出し
@YuzuruSano
YuzuruSano / .php_cs.dist
Created April 12, 2019 01:10
.php_cs.dist
<?php
return PhpCsFixer\Config::create()
->setRules([
'array_syntax' => [
'syntax' => 'short',
],
'blank_line_before_return' => true,
'function_typehint_space' => true,
'method_separation' => true,
'no_unused_imports' => true,
@YuzuruSano
YuzuruSano / index.html
Created February 18, 2019 03:59
youtubeAPI埋め込みのイベントから計測タグ発火させるサンプル
<script src="https://www.youtube.com/iframe_api""></script>
<!-- html設定サンプル -->
<div class="js-apiLoader" data-ytid="wUn05hdkhjM" data-an="{event}|{eventCategory}|{eventAction}|{eventLabel}"></div>
<div class="js-apiLoader" data-ytid="AhgwJyMPGNU" data-an="{event}|{eventCategory}|{eventAction}|{eventLabel}"></div>
@YuzuruSano
YuzuruSano / functions.php
Created December 20, 2018 02:54
MW WP FORMでReply-toヘッダを指定する
<?php
//xxxはMW WP FORMのフォームIDを入れる
add_action('mwform_before_send_admin_mail_mw-wp-form-xxx', function ($Mail_admin, $Data) {
add_filter('wp_mail', function($param) use ($Data){
$data = $Data->gets();
if(isset($param['to'])){
//管理者と閲覧者でReply-To設定を分けたい場合はメールアドレスの文字列で判定
//下記はサンプルでtoに含まれるドメインで判定
preg_match('/mydomain\.jp/', $param['to'],$match);
if(count($match) > 0){
@YuzuruSano
YuzuruSano / functions.php
Created December 19, 2018 13:51
WordPress 4.9.9でメディアライブラリからcsvをアップできない対策(場当たり的)
<?php
add_filter('wp_handle_upload_prefilter', 'custom_upload_filter' );
function custom_upload_filter( $file ){
if('csv' == substr($file['name'], strrpos($file['name'], '.') + 1)){
$file['type'] = 'text/csv';
}
if($file['type'] == 'text/csv' && mime_content_type($file['tmp_name']) == 'text/plain'){
add_filter('upload_mimes', function($existing_mimes){
$existing_mimes['csv'] = 'text/plain';
@YuzuruSano
YuzuruSano / hytInsertMockPosts.php
Last active September 8, 2018 00:17
[Wordpress] 投稿タイプ、タクソノミ、件数指定して大量のテスト用投稿をinsertする
<?php
class hytInsertMockPosts {
public function __construct($post_type = 'post',$taxonomies = ['category'],$num = 10){
$this->post_type = $post_type;
$this->taxonomies = $taxonomies;
$this->num = $num;
}
public function mbRange($start, $end){
if ($start == $end) {
return array($start);
@YuzuruSano
YuzuruSano / wp-cli.yml
Created September 2, 2018 03:43
WordPress default install setting
url: {http://xxx.com}
user: {admin_user}
color: false
core download:
locale: ja
version: latest
core config:
dbuser: {dbuser}
dbpass: {dbpass}
@YuzuruSano
YuzuruSano / index.html
Last active October 16, 2018 17:08
画像の配置テスト
<div class="entry-inner"><p>画像の配置テストへようこそ ! 画像をいろいろな位置に配置してみるのに一番良い方法は、言葉の海の中に画像をそっとうずめてみることです。さあ、はじめましょう。</p>
<p>画像の配置では、ユーザーが「指定なし」「右寄せ」「左寄せ」「中央揃え」の中から自分の好きなものを選べるようにする必要があります。さらに、「サムネイル」「中サイズ」「大サイズ」「フルサイズ」という選択肢の中から大きさを選べるようにするべきです。</p>
<p style="text-align: center;"><img class="size-full wp-image-906 aligncenter" title="画像配置 580x300" alt="画像配置 580x300" src="https://wpthemetestdata.files.wordpress.com/2013/03/image-alignment-580x300.jpg" width="580" height="300"></p>
<p>上記の画像は<strong>中央寄せ</strong>になるはずです。</p>
<p><strong><img class="size-full wp-image-904 alignleft" title="画像配置 150x150" alt="画像配置 150x150" src="https://wpthemetestdata.files.wordpress.com/2013/03/image-alignment-150x150.jpg" width="150" height="150"></strong>このパラグラフの残り画像を左寄せしたとき、文章が150ピクセルの画像の周りを囲むようになるかどうか見るためのものです。<strong></strong></p>
<p>ご覧のとおり、画像の上・下・右にスペースが空いている事がわかると思います。テキストは画像にこっそりと忍びよってはいません、忍び寄ることは良くない事です。画像だって十分に呼吸ができるスペースが必要なのです。画像が文章にイライラさせられることなく役割を果たせるようにしてあげてください。次の文章では、テキストが画像の右から下へとシームレスに途切れることなく続いている事がわかりますね。これで完了です !</p>
<
@YuzuruSano
YuzuruSano / index.html
Created July 31, 2018 05:39
特殊文字
<p>タイトルに特殊記号を含めた場合にも、レイアウトや機能に悪影響が出ないようにする必要があります。</p>
<p>投稿タイトル内の特殊記号は minify された JavaScript を使用している際に問題を引き起こす場合があることが確認されています。特に管理画面での投稿編集に影響が出やすいので注意しましょう (例: メタ・ボックス、メディアアップロードなど) 。</p>
<h2>ラテン文字テスト</h2>
<p>これは、テーマで使われているフォントで基本的なラテン文字が表示できるかどうかのテストです。</p>
<table>
<tbody>
<tr>
<td>!</td>
<td>“</td>
<td>#</td>