Skip to content

Instantly share code, notes, and snippets.

View s-hiroshi's full-sized avatar

Hiroshi Sawai s-hiroshi

View GitHub Profile
@s-hiroshi
s-hiroshi / functions.php
Created August 24, 2012 07:49
WordPress > snippets > custom post type
/**
* カスタム投稿タイプ example
*/
add_action('init', 'create_example');
function create_example(){
$labels = array(
'name' => 'サンプル',
'singular_name' => 'サンプル',
'add_new' => 'サンプルを追加',
'add_new_item' => '新しいサンプルを追加',
@s-hiroshi
s-hiroshi / functions.php
Created August 24, 2012 08:07
WordPress > snippets > custom taxonomy
<?php
// カスタムタクソノミーを登録
register_taxonomy(
'example_tax', // カスタムタクソノミー名
'example', // 投稿タイプの指定
array(
'hierarchical' => true, // trueの場合はカテゴリーのように表示
'update_count_callback' => '_update_post_term_count',
'label' => '分類',
'singular_label' => '分類',
@s-hiroshi
s-hiroshi / functions.php
Created August 24, 2012 08:30
WordPress >snippets > custom field on custom post type example
// カスタム投稿タイプ
function create_example(){
$labels = array(
'name' => 'サンプル',
'singular_name' => 'サンプル',
'add_new' => 'サンプルを追加',
'add_new_item' => '新しいサンプルを追加',
'edit_item' => 'サンプルを編集',
'new_item' => '新しいサンプル',
'view_item' => 'サンプルを編集',
@s-hiroshi
s-hiroshi / ajax.html
Created September 11, 2012 06:06
JavaScript > Ajax > base sample
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Ajax sample used jQuery</title>
<style>
#response {
margin: 1em 0;
padding: .5em;
background: #C6DDAA;
@s-hiroshi
s-hiroshi / permission.php
Created September 12, 2012 04:57
PHP > file
// ファイルの権限(パーミッション)を表示する
<?php
$data = array(
'file' => 'sample.txt',
);
if (file_exists($data['file'])) {
$data['exists'] = 'exists';
} else {
$data['exists'] = 'no exists';
@s-hiroshi
s-hiroshi / README.md
Last active April 27, 2018 20:22
jQuery > snippet > dropdown

Condition

gte IE 8 and firefox, chrome, safari, opera latest version

Usage

<link rel="stylesheet" href="style.css" media="all">
@s-hiroshi
s-hiroshi / index.html
Created September 20, 2012 08:55
JavaScript > iframe sample
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>インラインフレームのテスト</title>
</head>
<body>
<iframe width="200" id="frame" height="150" src="sample.html">
テスト
</iframe>
@s-hiroshi
s-hiroshi / common.js
Created September 24, 2012 05:32
JavaScript > Qunit QUnitを使ったハンドラのテスト
/*
* 名前空間を提供する。トップレベルオブジェクト
*
* <p>Christian Johansen(著),長尾高弘(翻訳)『テスト駆動JavaScript』ASCII
* 下記サイトで配布されているスクリプトを変更。</p>
* <p>http://tddjs.com/</p>
*/
function Common() {}
/**
* 名前空間を設定・管理する。
@s-hiroshi
s-hiroshi / async.html
Created September 25, 2012 02:49
JavaScript > QUnit 非同期のテスト
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>event test sample</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" media="all">
<script src="http://code.jquery.com/qunit/git/qunit.js"></script>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
@s-hiroshi
s-hiroshi / editor.js
Created October 1, 2012 02:37
JavaScript > editor
jQuery(function($) {
// 選択範囲取得は下記ライブラリを利用している。
// jQuery.selection
// http://madapaja.github.com/jquery.selection/
// テキストエリア(#input)の文字列を取得し
// 改行を<br>へ置換しDIV要素(#output)へ表示する。
var outputText = $('#input').val();
outputText = outputText.replace(/\n/g, '<br>');
$('#output').html(outputText);