Skip to content

Instantly share code, notes, and snippets.

@yokotak0527
yokotak0527 / gist:9148582
Created February 22, 2014 04:08
dmp3 template
<!doctype html>
<html lang="ja-JP">
<head>
<meta charset="UTF-8">
<title>DmP03 template</title>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script>
// ここにコードを書きましょう!
</script>
</head>
@yokotak0527
yokotak0527 / gist:9303216
Created March 2, 2014 07:28
後で書き直し
// =============================================================================
// 指定された固定ページの親子関係か否か
// =============================================================================
function _in_page($val = ""){
global $post;
$valArr;
$val = preg_replace('/\/$/', '', $val);
$val = preg_replace('/^\//', '', $val);
$valArr = preg_split("/\//", $val);
ini_set('display_errors', 0); // 画面へのエラー非表示
ini_set("log_errors", 1); // エラーログ出力
ini_set('error_log','/home/sites/heteml/users86/y/o/k/yokotakenji/web/log/wp-content/themes/log2015/log/debug.log'); // エラーログのパス指定
// ob_start(); // バッファへの出力を開始
// var_dump("dddd"); // ダンプして
// $cnt = ob_get_contents(); // バッファ内容を取得して
// ob_end_clean(); // バッファ終了 : 終了と同時にバッファが消されるので注意
// error_log($cnt); // エラーログとして出力
@yokotak0527
yokotak0527 / gist:30f55f18e4a81784c03a
Last active August 29, 2015 14:12
WordPress custom post template
// register_post_type ↓
// 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/register_post_type
// taxonomiesは省略しています。追加するかregister_taxonomy()を利用してください。
add_action('init', 'custom_post');
function custom_post(){
$label_arr = array(
// 'name' => '', // 投稿タイプの一般名、通常は複数形。省略すると $post_type_object->label と同じ値になる。
// 'singular_name' => '', // この投稿タイプのオブジェクト 1 個の名前(単数形)。デフォルトは 'name' の値。
// 'menu_name' => '', // メニュー名のテキスト。メニュー項目の名前を決める文字列です。デフォルトは 'name' の値。
// 'name_admin_bar' => '', // 管理バーの「新規追加」ドロップダウンに入れる名前。デフォルトは、'singular_name' があればその値になり、無ければ 'name' の値になる。
@yokotak0527
yokotak0527 / gist:16084c16eb8c0a83483f
Last active August 29, 2015 14:12
WordPress custom taxonomy template
// register_taxonomy ↓
// 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/register_taxonomy
add_action('init','custom_tax');
function custom_tax(){
$label_arr = array(
'name' => '', // タクソノミーの一般的な名前(普通は複数形)。 $tax->label によって上書きされて同じになる。デフォルトは _x( 'Post Tags', 'taxonomy general name' ) または _x( 'Categories', 'taxonomy general name' ) 。この文字列を国際化するときは、gettext context を使用してカスタム投稿タイプに合わせてください。例: _x('Writers', 'taxonomy general name');
'singular_name' => '', // タクソノミーのオブジェクト 1 個の名前(単数形)。デフォルトは _x( 'Post Tag', 'taxonomy singular name' ) または _x( 'Category', 'taxonomy singular name' ) 。この文字列を国際化するときは、gettext context を使用してカスタム投稿タイプに合わせてください。例: _x('Writer', 'taxonomy singular name');
'menu_name' => '', // メニュー名の文字列。メニュー項目の名前になります。無指定の場合、デフォルトで name のラベルが入ります。
'all_items' => '', // 「すべての項目」の文字列。デフォルトは __( 'All Tags' ) または __( 'All Categories' )
'edit_item' => '', // 「項目を編集」
@yokotak0527
yokotak0527 / gist:888852
Created March 27, 2011 02:13
design pattern
//
// singleton pattern
//
var Singleton = (function(){
var instance;
return function(){
if(instance){
return instance;
};
@yokotak0527
yokotak0527 / gist:2834564
Created May 30, 2012 08:36
wordpressでエントリーのルートカテゴリーを取得する
//ex -> the_root_category(get_the_category(),"span");
function the_root_category($cat,$mode="li"){
$cat = get_root_category($cat);
$cnt = count($cat);
$_cat;
for($i = 0;$i<$cnt;$i++){
echo "<".$mode." class='catGroup catGroup".$i." ".$cat[$i]->slug."'>".$cat[$i]->name."</".$mode.">";
}
};
@yokotak0527
yokotak0527 / welcart $wcmbで分岐
Created July 19, 2012 01:15
welcart 拡張プラグイン WCEX MobileのオブジェクトでPC、スマホ、ガラケーの分岐
// welcart 拡張プラグイン WCEX Mobile
// http://www.welcart.com/archives/1626.html
// $wcmbのプロパティで環境ごとの分岐ができそうだったのでメモ
// ガラケーかどうかの判定っぽい。返り値はintかboolian
// PCで0:int スマホで10:int ガラケーでtrue:bool
$wcmb['check_garak']
// デバイスの名前が入ってる
// PCだとPC:string スマホ、ガラケーだと機種名
@yokotak0527
yokotak0527 / welcart priceArr
Created July 27, 2012 03:07
welcart 価格の配列を返すやつ
// 使い方は
// $arr = priceArr(usces_the_firstPrice('return'));
// みたいな感じ。
// 返り値は配列。
// 管理画面で税率は必ず指定しておくこと!
function priceArr($price=0){
global $usces;
$pos = $usces->options;
@yokotak0527
yokotak0527 / gist:4346916
Created December 20, 2012 17:21
yeoman Gruntfileにgrunt-growl足したやつ
module.exports = function( grunt ) {
'use strict';
//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({
// ------------------------------------