Skip to content

Instantly share code, notes, and snippets.

View ShinichiNishikawa's full-sized avatar
🏠
Working from home

Shinichi Nishikawa ShinichiNishikawa

🏠
Working from home
View GitHub Profile
@ShinichiNishikawa
ShinichiNishikawa / wp-backup.sh
Last active December 23, 2015 01:38
Local backup. Fetch remote files/db. Save log. Create email body. Save in Dropbox folder.
#!/bin/sh -u
# exit if wp-cli or wordmove is not installed.
type wp >/dev/null 2>&1 || { echo >&2 "wp-cli is not installed. Aborting."; exit 1; }
type wordmove >/dev/null 2>&1 || { echo >&2 "Wordmove is not installed. Aborting."; exit 1; }
type git >/dev/null 2>&1 || { echo >&2 "git is not installed. Aborting."; exit 1; }
# Variables.
URL_LOCAL=$(wp option get home)
@ShinichiNishikawa
ShinichiNishikawa / gulpfile.js
Last active November 26, 2015 08:42
gulpfile.js
var gulp = require("gulp");
var sass = require("gulp-sass");
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require("gulp-autoprefixer");
var browserSync = require("browser-sync").create();
var plumber = require("gulp-plumber");
gulp.task('serve', ['sass'], function() {
browserSync.init({
@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>
@ShinichiNishikawa
ShinichiNishikawa / nskw-template-loader.php
Last active September 6, 2016 07:35
Load template file in plugin folder.
<?php
class nskw_template_loader {
public function __construct() {
add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
}
public static function template_loader( $template ) {
wp core download
wp core config --dbname=sample --dbuser=root --dbpass=root
wp core install --url=http://example.dev --title="WordPress Sample Site" --admin_user=nishikawa --admin_password=pass [email protected]
wp plugin install show-current-template wp-basic-auth theme-check plugin-check wp-multibyte-patch --activate
wp plugin install wordpress-beta-tester jetpack contact-form-7 vk-all-in-one-expansion-unit
wp plugin delete hello
wp option update blogdescription "This is a new project!!"
wp option update posts_per_page 5
wp option update thread_comments 1
wp option update thread_comments_depth 3
*.log
*.sql
.DS_Store
.htaccess
*.map
error_log
Movefile
wp-cli.yml
sitemap.xml
sitemap.xml.gz
@ShinichiNishikawa
ShinichiNishikawa / Movefile.init
Last active December 22, 2015 07:10
Movefile for my local
local:
vhost: "http://example.dev"
wordpress_path: "/Users/papa/Sites/example.dev"
database:
name: "example"
user: "root"
password: "root"
host: "localhost"
@ShinichiNishikawa
ShinichiNishikawa / newreview
Last active June 26, 2016 14:08
Creating a whole new Theme Review environmet in 1 minute using wp-cli
wp db reset --yes
wp core install --url=http://theme-review.loc --title="This is a really long long title to check if this theme design doesn't break with the long site title" --admin_user=admin --admin_password=admin [email protected]
wp core update
wp plugin install theme-check debug-bar log-deprecated-notices monster-widget wordpress-importer show-current-template customizer-theme-resizer --activate
wp plugin install wordpress-beta-tester debogger jetpack
wp plugin update --all
wp option update blogdescription "I'm in the theme review process and this is a very very long tagline to see if this long tagline text string in WordPress doesn't break the design of the theme header and else."
wp option update posts_per_page 5
wp option update thread_comments 1
wp option update thread_comments_depth 3
@ShinichiNishikawa
ShinichiNishikawa / add_body_class_locale.php
Last active August 29, 2015 14:02
Add locale to body_class
// add locale such as locale_ja, locale_en_US to body class
add_filter( 'body_class', 'add_body_class_locale' );
function add_body_class_locale( $classes ) {
$classes[] = 'locale_' . sanitize_html_class( get_bloginfo('language') );
return $classes;
}
@ShinichiNishikawa
ShinichiNishikawa / gist:11371541
Last active August 29, 2015 14:00 — forked from wokamoto/gist:11365599
おかもとさんより
<?php
add_filter( 'the_content', 'my_pre_shortcode', 7 );
function my_pre_shortcode( $content ) {
global $shortcode_tags;
$shortcode_tags_org = $shortcode_tags;
remove_all_shortcodes();
add_shortcode( 'code', 'code_shortcode_handler' );
$content = do_shortcode( $content );