Skip to content

Instantly share code, notes, and snippets.

@kurudrive
kurudrive / gist:7411031
Last active December 28, 2015 00:09
[WP] 親子構造を持ったタームのリンク
function term_parent_child( $taxonomy, $separator ) {
// タームの配列を取得
$terms = get_the_terms( $post->ID, $taxonomy);
// print '<pre>';print_r($terms);print '</pre>';
foreach ($terms as $term) {
if ($term->parent == 0) {
// parent が 0 のタームが先祖なのでIDを取得
$parent_term_id = $term->term_id;
} else {
// 子のターム
@kurudrive
kurudrive / page-login.php
Last active December 28, 2015 03:48
[WP] パスワード無しで特定多数のIDを既に持ったユーザーをログインさせる
<?php
/*
※もっとスマートな実装方法があれば教えてください。
【1】 閲覧ユーザー用のIDを1つ発行
予め
ID : member
パスワード : memberpass
のユーザーを購読者権限で発行
@kurudrive
kurudrive / gist:7738772
Created December 1, 2013 18:17
php の文字列置換例文
$subject = '<div id="pickId_4046"></div><div id="pickId_3077"></div><div class="888"></div>';
$subject = esc_html(file_get_contents( site_url() ));
$not_in_array = '';
$pattern = '/id="pickId_([0-9]+)"/';
preg_match_all($pattern,$subject,$out, PREG_PATTERN_ORDER);
$not_in_array = $out[1]; // [0]はマッチした条件部分の配列
print '<pre>';print_r($not_in_array);print '</pre>';
@kurudrive
kurudrive / gist:7804444
Created December 5, 2013 12:30
[javascript]cookieの受け渡し
<script type="text/javascript">
jQuery(document).ready(function(){
// クッキーに投げる
jQuery.cookie('jsNotIn','値');
// クッキーの値を受け取る
var notIn = jQuery.cookie('jsNotIn');
console.log(notIn);
});
</script>
@kurudrive
kurudrive / gist:09f37db0939d57df08c1
Last active January 16, 2023 06:25
[WordPress]よく使うエスケープ処理の書き方
/* 参照・参考
http://firegoby.jp/archives/2244
http://www.rescuework.jp/blog/customfield-escape.html
*/
// HTMLをエスケープ
esc_html($content);
// URLをエスケープ
esc_url($url);
@kurudrive
kurudrive / gist:2358198279164ae321ad
Last active August 29, 2015 14:10
wp-login.phpのBASIC認証
<Files wp-login.php>
AuthType Basic
AuthUserFile /*サーバーのパス*/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
require valid-user
</Files>
@kurudrive
kurudrive / gist:ce304c3aae275a2662c7
Created November 23, 2014 14:25
WordPressの管理画面のBASIC認証
AuthType Basic
AuthUserFile /*サーバーのパス*/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
Require valid-user
<FilesMatch "(admin-ajax.php)$">
Satisfy Any
Order allow,deny
Allow from all
Deny from none
<?php
/*
* Template Name: 採用情報
*/
get_header(); ?>
<!-- [ #container ] -->
<div id="container" class="innerBox">
<!-- [ #content ] -->
<div id="content" class="content">
@kurudrive
kurudrive / multi_language.php
Created December 13, 2015 17:46
オレオレ多言語サイト対応プログラム
<!-- [ header.phpなどに記入 ] -->
<ul class="lang_list">
<li id="lg_bt_en"><a href="#">ENGLISH</a></li>
<li id="lg_bt_ja"><a href="#">JAPAN</a></li>
</ul>
<?php
/*
functons.phpなどに記入
@kurudrive
kurudrive / gist:d818df68b5f33f65ad48
Created January 30, 2016 13:06
リンクボタン
<div class="moreLink right sectionBox">
<a href="リンク先URL">ボタン名</a>
</div>