Skip to content

Instantly share code, notes, and snippets.

View yousan's full-sized avatar
💻
I must work everyday

Yousan_O yousan

💻
I must work everyday
View GitHub Profile
@yousan
yousan / wp_query_example.php
Last active September 22, 2018 05:01 — forked from Olein-jp/wp_query_example
WP_Queryで出力する際のサンプル
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
* Japanese translated by hissy
*
* CODEX: http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/WP_Query#.E3.83.91.E3.83.A9.E3.83.A1.E3.83.BC.E3.82.BF
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
* Original: https://gist.github.com/luetkemj/2023628/9e911982440141a13cb1dd8ba1ad6b35cd7bbdd7
*/
@yousan
yousan / Readme.md
Created July 13, 2018 05:32
Gitの運用ルール

ブランチ名について

  1. 名前は features/yousan/201801/fix-admin-panel といった名前でブランチを作ってください。 開発用ブランチとして、features/ブランチの以下にユーザ名(例: yousan/)、年月(例: 201801)、機能概要(例: fix-admin-panel)としてください。

feature以外のブランチについて

  1. ブランチの作成はdevelopから行ってください。
  2. masterブランチ、developブランチへの直接コミットは行わないようにしてください。
  3. featureブランチの作成にはSourceTreeのGit Flowを使うと便利です。

コミットとブランチの粒度について

@yousan
yousan / uuid_to_fstab.sh
Last active June 13, 2018 13:15
uuid to fstab
#!/bin/bash
# UUID=1234-37bd-4098-9f8b-85e99c9c5219 /boot xfs defaults 0 0
blkid | grep $1 | sed -r 's#^.*UUID="([a-Z0-9\-]+)".*TYPE="([a-Z0-9\-]+)".*$#UUID=\1\t'$2'\t\2\tdefaults\t0\t0#'
@yousan
yousan / sec.php
Last active September 24, 2017 08:07
my wordpress might be hacked
<?php
/**
* Provides a block to display 'Site branding' elements.
*
* @Block(
* id = "system_branding_block",
* admin_label = @Translation("Site branding")
* )
*/
@yousan
yousan / composer.json
Created June 8, 2017 04:40
Install WordPress with composer
{
"require": {
"php": ">=5.4",
"johnpbloch/wordpress": "4.7.5"
},
"extra": {
"wordpress-install-dir": "public/wp"
},
"post-install-cmd": {
<?php
/**
* Smart Custom Fieldsの定義用クラス
* グループごとにメソッドを作ると良い
*
* @link https://2inc.org/blog/2015/03/12/4670/
*/
Class Test_SmartCustomFields {
#!/usr/bin/env bash
if [ $# -lt 3 ]; then
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]"
exit 1
fi
DB_NAME=$1
DB_USER=$2
DB_PASS=$3
// https://codex.wordpress.org/Transients_API
// kショートコードをsキャッシうュるコード
add_shortcode('someshortcode', function() {
echo 'hoge';
});
add_shortcode('someshortcode_cached', function() {
if ( $ret = get_transient('someshortcode') ) {
return $ret;
<?php
if ( ! class_exists( 'RecommendPost' ) ) {
class RecommendPost {
static function init() {
add_action( 'admin_menu', array( __CLASS__, 'add_meta_box' ) );
add_action( 'save_post', array( __CLASS__, 'save_meta_data' ) );
add_action( 'pre_get_posts', array( __CLASS__, 'change_order' ) );
}
#!/usr/bin/env bash
# @see http://qiita.com/miya0001/items/4dc5949dd792963ef578 Thanks!
# Usage: ssh [email protected]
# Automatically adds `-i [email protected]` argument for `ssh` command.
# test: bash -c 'source ssh_bash.bash; ssh [email protected] ls'
function ssh {
local HOSTSTR