Skip to content

Instantly share code, notes, and snippets.

View inc2734's full-sized avatar

Takashi Kitajima inc2734

View GitHub Profile
@inc2734
inc2734 / .php
Last active December 29, 2015 13:31
How to use habakiri_theme_mods_defaults
<?php
function habakiri_child_theme_setup() {
class Habakiri extends Habakiri_Base_Functions {
public function __construct() {
parent::__construct();
add_action( 'habakiri_theme_mods_defaults', array( $this, 'habakiri_theme_mods_defaults' ) );
}
/**
@inc2734
inc2734 / .php
Created November 11, 2015 11:25
Add html using action hook on Habakiri
<?php
function habakiri_child_theme_setup() {
class Habakiri extends Habakiri_Base_Functions {
public function __construct() {
parent::__construct();
// habakiri_before_entry_content フックにフックさせる場合
add_action( 'habakiri_before_entry_content', array( $this, 'habakiri_before_entry_content' ) );
}
@inc2734
inc2734 / .php
Created November 11, 2015 01:27
Register custom post type on Habakiri
<?php
function habakiri_child_theme_setup() {
class Habakiri extends Habakiri_Base_Functions {
public function __construct() {
parent::__construct();
add_action( 'init', array( $this, 'register_post_types' ) );
}
/**
* カスタム投稿タイプを定義
@inc2734
inc2734 / gist:7b3f73c010d76b1d1306
Created June 10, 2015 10:27
Habakiri トップページサンプルコード
<section class="jumbotron section-image section-fixed" style="background-image: url( hoge.jpg )">
<div class="containter text-center">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h1>Habakiri</h1>
This section has classes, jumbotron, section-image and section-fixed. If you attach the .btn-default, displaying beautiful.
<div class="col-md-8 col-md-offset-2">
<a class="btn btn-default btn-block">CONTACT</a>
@inc2734
inc2734 / gist:9f6d65c7473d060d0fd6
Last active April 30, 2022 09:26
smart-cf-register-fields のサンプル
<?php
/**
* カスタムフィールドを定義
*
* @param array $settings Smart_Custom_Fields_Setting オブジェクトの配列
* @param string $type 投稿タイプ or ロール
* @param int $id 投稿ID or ユーザーID
* @param string $meta_type post | user
* @return array
*/
@inc2734
inc2734 / gist:ae217cc4967073ed8bc5
Created January 21, 2015 04:58
画像( img#hoge )を読み込んだ後に処理を行う
$( '<img />' ).one( 'load', function() {
// do something
} ).attr( 'src', $( 'img#hoge' ).attr( 'src' ) );
@inc2734
inc2734 / gist:6bc63c8fa27db64ea32a
Created January 16, 2015 05:42
WordPress でサムネイルか、それが無いときのデフォルト画像を出し分けるテンプレートタグ
<?php
class Hoge {
/**
* get_the_post_thumbnail
* @param string $size
* @param array $attributes
* @return string
*/
public static function get_the_post_thumbnail( $size = 'post-thumbnail', array $attributes = array() ) {
if ( has_post_thumbnail() ) {
@inc2734
inc2734 / gist:03d23ce33eec770ec784
Last active August 29, 2015 14:13
WordPressで一番親のディレクトリ名を取得する。サブディレクトリインストール型対応。
<?php
/**
* get_second_directory
*/
function get_second_directory() {
if ( $_SERVER['REQUEST_URI'] ) {
$home_url = home_url();
$home_url = explode( '/', $home_url );
$REQUEST_URI = $_SERVER['REQUEST_URI'];
$REQUEST_URI = preg_replace( '/^(.*)?\?.*$/', '$1', $REQUEST_URI );