Skip to content

Instantly share code, notes, and snippets.

Avatar

Shinichi Nishikawa ShinichiNishikawa

View GitHub Profile
View theme-init
#!/bin/sh -eu
# exit if wp-cli, wordmove or git is not installed.
type wp >/dev/null 2>&1 || { echo >&2 "wp-cli is not installed. Aborting."; exit 1; }
# Variables.
DIRNAME=${PWD##*/}
URL_LOCAL=$(cd ../../.. && echo "${PWD##*/}")
npm init --yes
@ShinichiNishikawa
ShinichiNishikawa / wp-backup.sh
Last active Dec 23, 2015
Local backup. Fetch remote files/db. Save log. Create email body. Save in Dropbox folder.
View wp-backup.sh
#!/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)
View 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 Mar 18, 2016
Tags I use a lot in WordPress content area.
View WP Content Area Markup
<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 Sep 6, 2016
Load template file in plugin folder.
View nskw-template-loader.php
<?php
class nskw_template_loader {
public function __construct() {
add_filter( 'template_include', array( __CLASS__, 'template_loader' ) );
}
public static function template_loader( $template ) {
View wp-cli commands for new client projects
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 --admin_email=example@example.com
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
View wordpress.gitignore
*.log
*.sql
.DS_Store
.htaccess
*.map
error_log
Movefile
wp-cli.yml
sitemap.xml
sitemap.xml.gz
@ShinichiNishikawa
ShinichiNishikawa / Movefile.init
Last active Dec 22, 2015
Movefile for my local
View Movefile.init
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 Jun 26, 2016
Creating a whole new Theme Review environmet in 1 minute using wp-cli
View newreview
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 --admin_email=example@example.com
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
View add_body_class_locale.php
// 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;
}