Skip to content

Instantly share code, notes, and snippets.

View check-data-onlu-me.php
<?php
global $current_user;
$user_info_obj = wp_get_current_user();
//var_dump( $user_info_obj );
//var_dump( $user_info_obj->data->user_login );
$spesific_user = $user_info_obj->data->user_login;
if ( is_user_logged_in() && $spesific_user === 'xxxxx' ) {
var_dump($wp_query->found_posts);
}
@marushu
marushu / check_kuroneko.sh
Created Jun 7, 2017
Check the baggage with the baggage inquiry system of Kuroneko Yamato. :)
View check_kuroneko.sh
#!/bin/sh
# Check the baggage with the baggage inquiry system of Kuroneko Yamato. :)
echo 'Enter the number.'
read KURONEKONUM
open http://jizen.kuronekoyamato.co.jp/jizen/servlet/crjz.b.NQ0010?id=${KURONEKONUM}
@marushu
marushu / search-replace.sh
Created Jun 1, 2017
Set the value of search-replace based on the value of Movefile.
View search-replace.sh
#!/bin/sh
# "../Movefil" : Set the path to Movefile in each project. Rewrite it accordingly.
# This command needs to be executed in the directory where the WordPress core is located.
# --skip-columns=guid
# @see https://developer.wordpress.org/cli/commands/search-replace/
wp search-replace $(grep "vhost:" ../Movefile | sed -e s/vhost://g | tr -d '\"\ ' | sed -n 2p) $(grep "vhost:" ../Movefile | sed -e s/vhost://g | tr -d '\"\ ' | sed -n 1p) --skip-columns=guid
@marushu
marushu / backup.sh
Created Jun 1, 2017
Backup from remote datas.
View backup.sh
#!/bin/sh
# Important!! Run this command in the vccw directory.
# Backup from remote
# - Login to vagrant
# - Fire wordmove pull -tup
# - Make backup.sql
# - Download backup.sql using scp.
# - Fire wp db import and search-replace.
View more_extended.php
<?php
// カスタムフィールドの値 : for_all, need_loginで分岐
// set single.php
while ( have_posts() ) : the_post();
$raw_content = get_extended( $post->post_content );
$everyone_can_read_content = ! empty( $raw_content )
? $raw_content['main']
: get_the_content();
$logged_in_can_read_content = $raw_content['extended'];
@marushu
marushu / package.json
Last active Jul 8, 2017
Task runner for building WordPress theme
View package.json
{
"name": "task-runner-for-wordpress-theme",
"version": "1.1.0",
"description": "new task runner for hibou build themes :)",
"scripts": {
"lint": "eslint ./js || true",
"scss": "node-sass --output-style expanded --indent-type tab --indent-width 2 -o ./ ./sass/style.scss",
"autoprefixer": "postcss -u autoprefixer --autoprefixer.browsers '> 5%, ie 9' -r ./style.css",
"imagemin": "imagemin ../../../../dist/* -o ./common/img",
"icons": "svgo -f ./common/img && mkdir -p ./common/img && svg-sprite-generate -d ../../../../dist/ -o ./common/img/icons.svg",
@marushu
marushu / add_thumbnail_admin_column.php
Last active Dec 7, 2016
Add specific data to admin column.
View add_thumbnail_admin_column.php
<?php
/**
* Add post thumbnail to admin column.
*/
// add product field admin column
function add_blog_admin_columns_head( $defaults ) {
$defaults[ 'post_thumbnail' ] = 'アイキャッチ画像';
return $defaults;
}
add_filter( 'manage_blog_posts_columns', 'add_blog_admin_columns_head' );
@marushu
marushu / count.sh
Last active Oct 25, 2016
jqで配列の数を取得
View count.sh
#!/bin/sh
# Count returned json array length.
# --graboff is for [] parameter.
curl --globoff https://private.hibou-web.com/wp-json/wp/v2/posts?filter[posts_per_page]=5 | jq length
@marushu
marushu / package-sample.json
Created Oct 23, 2016
For browser-sync ligt test. :)
View package-sample.json
{
"name": "liottest",
"version": "1.0.0",
"description": "liot test",
"main": "index.js",
"scripts": {
"test": "start",
"start": "browser-sync start --server --files='./*.html'"
},
"author": "",
@marushu
marushu / resize.js
Created Oct 19, 2016 — forked from wgkoro/resize.js
指定サイズ以内の画像幅、高さを算出、img要素にそのサイズを適用するスクリプト
View resize.js
/**
* 指定サイズ以内の画像幅、高さを算出、
* img要素にそのサイズを適用する
*
* 使い方:
*
* ) 幅150px, 高さ200px以内で画像を表示する
* var img = document.createElement('img');
* img.src = 'http://hoge.com/img/fuga.jpg';
* imgResize.resize(img, 150, 200);
You can’t perform that action at this time.