Skip to content

Instantly share code, notes, and snippets.

View mhige's full-sized avatar

minaminohige mhige

View GitHub Profile
@mhige
mhige / tomareba-custome.css
Last active July 19, 2018 01:44
トマレバ カスマイズ CSS
/* micro clearfix */
.tomarebalink-box,
.tomarebalink-link1 {
zoom: 1;/* IE6,7の対応しないならいらないです */
}
.tomarebalink-box:after,
.tomarebalink-link1:after {
content: "";
display: block;
clear: both;
@mhige
mhige / php-error-reporting.php
Last active July 27, 2018 00:51
WordpressでPHPエラーの出力を非表示にする
<?php
//functionにこれを追記する
error_reporting(0);
?>
@mhige
mhige / barba-js-wp-enque-script.php
Last active July 27, 2018 00:52
Barba.jsをWordrepssで読み込む(wp enqueue script)
<?php
// add_filesの部分は自分で理解しやすい名前をつけてOK
function add_files() {
// barba.js本体を読み込む
wp_enqueue_script( 'barba-js', get_template_directory_uri() . '/js/barba.min.js', array(), '1.0.0', true);
// カスタムのjsを読み込む
wp_enqueue_script( 'barba-custom', get_template_directory_uri() . '/js/barba-custom.js', 'array(barba-js)', '', true);
}
add_action('wp_enqueue_scripts', 'add_files');
?>
@mhige
mhige / barba-js-load-script-doc-write.js
Last active July 28, 2018 01:48
Barba.jsでdocument.writeを含む外部スクリプトをDOM上に読み込む代替処理
// Dispatcher (newPageReadyのところに記述)
Barba.Dispatcher.on('newPageReady', function(currentStatus, oldStatus, container, newPageRawHTML) {
// 記事内のscriptタグを取得(NodeList)
// querySelectorAllはDOMで細かく指定してOK
// 例: querySelectorAll('#content script')
// ↑IDがcontentのタグの中のscriptタグ
var scripttag = document.querySelectorAll('script');
// scriptそれぞれに処理
@mhige
mhige / barba-js-tag.html
Created July 27, 2018 02:03
Barba.jsで非同期で読み込みたい部分をタグで囲う。
<div id="barba-wrapper">
<div class="barba-container">
<!-- ここに非同期で読み込みたいコンテンツ -->
</div>
</div>
@mhige
mhige / barba-js-tag-wp-themes.php
Created July 27, 2018 02:16
Wordpressテーマだと、たとえばこんな感じの構造になる。
<?php get_header(); ?>
<div id="content">
<div class="container">
<!-- コンテンツ部分を丸ごと読み込む場合 -->
<div id="barba-wrapper"><!-- 追加 -->
<div class="barba-container"><!-- 追加 -->
<div class="main">
@mhige
mhige / barba-custom.js
Last active April 16, 2020 22:20
Barba.jsのカスタマイズ例(jQuery利用)
// 現在と同じページのリンクをクリックした場合、リロードをしない設定
// リロードしたい場合は削除
var links = document.querySelectorAll('a[href]');
var cbk = function(e) {
if(e.currentTarget.href === window.location.href) {
e.preventDefault();
e.stopPropagation();
}
};
for(var i = 0; i < links.length; i++) {
@mhige
mhige / wordpress-get-post-title.php
Last active September 20, 2018 01:53
Wordpressのget_post関数で記事IDを指定して記事情報を取得し、その中からタイトル情報を出力
<?php
// ID9999の記事の"タイトル"を出力
echo get_post( 9999 )->post_title;
?>
@mhige
mhige / wordpress-get-permalink.php
Last active September 20, 2018 01:52
Wordpressのget_permalinkタグで記事IDを指定してURLを出力
@mhige
mhige / wordpress-get-the-post-thumbnail.php
Last active September 20, 2018 01:52
Wordpressのget_the_post_thumbnailタグで記事IDを指定してサムネール画像を出力
<?php
// ID9999の記事の"サムネール画像"を出力
echo get_the_post_thumbnail( 9999 );
?>