Skip to content

Instantly share code, notes, and snippets.

View hideokamoto's full-sized avatar

Hidetaka Okamoto hideokamoto

View GitHub Profile
@torounit
torounit / useMeta.js
Last active September 1, 2020 03:28
useState 風味に WordPressのカスタムフィールドを扱うやつ
import { Fragment, useCallback } from '@wordpress/element';
import { useDispatch, useSelect } from '@wordpress/data';
const useMeta = ( key ) => {
const meta = useSelect( ( select ) => {
const { getEditedPostAttribute } = select( 'core/editor' );
const values = getEditedPostAttribute( 'meta' ) || {};
return values[ key ] || '';
}, [] );
// Builderオブジェクトの型
type Builder<Props, Result> = ({} extends Props
? {
build: () => Result;
}
: {}) &
{ [P in keyof Props]-?: SetFunction<Props, P, Result> };
type SetFunction<Props, K extends keyof Props, Result> = (
value: Exclude<Props[K], undefined>
@shield-9
shield-9 / le-renewal.sh
Created February 8, 2016 04:23
Let's Encrypt Auto-renew
./letsencrypt-auto certonly --apache --keep -d extendwings.com -d www.extendwings.com
./letsencrypt-auto certonly --apache --keep -d aigis.pw
./letsencrypt-auto certonly --apache --keep -d shield-9.org
sudo apachectl graceful
@wokamoto
wokamoto / cloudfront-input.json
Last active April 8, 2016 07:43
[AWS][WordPress] WordPress 用 CloudFront 設定サンプル
{
"DistributionConfig": {
"Comment": "",
"CacheBehaviors": {
"Items": [
{
"TrustedSigners": {
"Enabled": false,
"Quantity": 0
},
@miya0001
miya0001 / wp-setup.sh
Last active November 27, 2015 16:44
AMIMOTO Automated Setup
#!/usr/bin/env bash
set -ex;
# WordPressをec2-user権限で動かすように設定を変更
curl -L https://raw.githubusercontent.com/amimoto-ami/run-httpd-as-ec2-user/master/run-httpd-as-ec2-user.sh | sudo bash
# WordPressのセットアップ
wp --path=/var/www/vhosts/$(curl -L http://169.254.169.254/latest/meta-data/instance-id) \
core install \
@ShinichiNishikawa
ShinichiNishikawa / WP Content Area Markup
Last active March 18, 2016 05:20
Tags I use a lot in WordPress content area.
<h1>見出し壱:夏目漱石著『吾輩は猫である』</h1>
<h2>見出し弐:レオ・レオニ作『スイミー 小さなかしこいさかなのはなし』</h2>
<h3>見出し参:あまん きみこ作、上野 紀子絵『ちいちゃんのかげおくり』</h3>
<h4>見出し四:モンゴルの民話『スーホの白い馬』</h4>
<h5>見出し五:新美南吉作『手袋を買いに』</h5>
<h6>見出し六:芥川龍之介著『羅生門』</h6>
<h2>引用 (Blockquote) テスト</h2>
<blockquote>これは言語みたいなものだ。アルファベットすなわち音階を学び、文すなわちコードを学ぶ。そしてやがてホーンと即興で会話するようになる。即興で話すのはすばらしいことだと思うが、私には決して会得できないだろう。しかし音楽ともなれば、私は即座によろこんで会話する。そう、それがジャズ音楽のすべてだ。
<cite>スタン・ゲッツ</cite></blockquote>
@uedayou
uedayou / WBKYOTO1510.md
Last active October 5, 2015 01:03
WordBench京都10月号 WordPress × オープンデータ × データビジュアライゼーションハンズオン会 用メモ
<?php
/**
* @package Structured Data of JSON-LD
* @version 2.0
*/
/*
Plugin Name: Structured Data of JSON-LD
Plugin URI: http://wordpress.org/plugins/ejls-easy-json-ld-setter/
Description: Set Structured Data of "JSON-LD" to your WebSite.schema type that you can use is "Article","Person","WebSite" and "searchAction".
Author: Hidetaka Okamoto
@wokamoto
wokamoto / gist:048b93a4c87b86b184d6
Last active November 24, 2015 03:22
[WordPress] git 管理しているテーマでバージョンとして git のコミットIDをバージョン番号として使用するサンプル
<?php
$version = 'default';
$stylesheet_dir = get_stylesheet_directory();
if ( file_exists( $stylesheet_dir.'/.git/HEAD' ) ) {
$head = explode(' ', trim(file_get_contents($stylesheet_dir.'/.git/HEAD')) );
if ( isset($head[1]) && file_exists($stylesheet_dir.'/.git/'.$head[1]) ) {
$version = trim(file_get_contents($stylesheet_dir.'/.git/'.$head[1]));
}
}
define( 'THEME_VERSION', $version );
@mypacecreator
mypacecreator / functions.php
Last active March 1, 2017 08:46
WordPress ログイン時にダッシュボードではなくサイトトップへ飛ばす
<?php
//管理者以外はログイン成功後ダッシュボードではなくトップページへ飛ばす
function redirect_login_front_page() {
if( !current_user_can('administrator') ){
$home_url = site_url('', 'http');
wp_safe_redirect($home_url);
exit();
}
}