Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* ブロックエディタのoEmbedへcss追加
* wp-content/themes/snow-monkey/vendor/inc2734/wp-oembed-blog-card/src/App/View/View.php
* apply_filters( 'inc2734_wp_oembed_blog_card_block_editor_template', $template, $url );
*/
add_filter(
'inc2734_wp_oembed_blog_card_block_editor_template',
function ( $template, $url ) {
$template .= sprintf(
<?php
/**
* Embed ブログカードをカスタマイズ
* https://snow-monkey.2inc.org/manual/manual-advanced/customize-blog-card/
*/
add_filter(
'snow_monkey_oembed_blog_card_template',
function( $template, $cache ) {
$template = '';
<?php
// addtoany ショートコードを追加
add_filter(
'snow_monkey_template_part_render_template-parts/common/page-header',
function ( $html, $name, $vars ) {
$html .= do_shortcode( '[addtoany]' );
return $html;
<?php
// 実際のページ用の CSS 読み込み
add_action(
'wp_enqueue_scripts',
function() {
wp_enqueue_style(
'my-snow-monkey',
MY_SNOW_MONKEY_URL . '/style.css',
[ Framework\Helper::get_main_style_handle() ],
filemtime( MY_SNOW_MONKEY_PATH . '/style.css' )
@marushu
marushu / check-data-onlu-me.php
Created February 1, 2019 08:10
check data only me.
<?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 June 7, 2017 11:24
Check the baggage with the baggage inquiry system of Kuroneko Yamato. :)
#!/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 June 1, 2017 07:49
Set the value of search-replace based on the value of Movefile.
#!/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 June 1, 2017 02:38
Backup from remote datas.
#!/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.
<?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 July 8, 2017 05:33
Task runner for building WordPress theme
{
"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",