View duration_time.js
function duration(str) {
var matches = str.match(/PT(\d*)H*(\d+)M*(\d+)S*/i);
var d = (matches[1] && matches[1] + ':'); //hour
d += (matches[1] && matches[2] < 10 ? '0' : '') + (matches[2] && matches[2] + ':'); //min
d += (matches[3] && matches[3] < 10 ? '0' : '') + (matches[3] && matches[3]); //sec
return d;
}
View get_category_posts_customfield_value.php
<?php
/*
カテゴリーに所属する記事に設定されている指定したカスタムフィールドの値をリスト形式で得る
*/
function get_category_posts_customfield_value($cat_id, $meta_key) {
global $wpdb;
$limit = get_option('posts_per_page');
$offset = get_query_var('paged') * $limit;
View get_gategory_name_by_id.php
<?php
$result = $wpdb->get_results($wpdb->prepare("
SELECT name
FROM $wpdb->terms AS tm
JOIN $wpdb->term_taxonomy AS tmt
USING(term_id)
WHERE tmt.taxonomy = %s
AND term_id = %d
", 'category', $cat_id));
View get_category_posts_data.php
<?php
/*
$cat_idで渡したカテゴリーIDに登録されている記事の情報を返す
返す情報はSELECTの内容に基づく(記事IDと記事タイトル)
参考:https://qiita.com/m-shin/items/cec1b8278448e70be168
get_category_posts_data(get_cat_ID(single_cat_title('', false)));
*/
function get_category_posts_data($cat_id) {
View jquery.pager.js
/**
* jQuery Pager plugin
* Licensed under the MIT license
* This plugin is refer to how to write "jQuery ScrollSpy Plugin".
*/
(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== 'undefined') {
View Compass flexbox mixin
//http://compass-style.org/reference/compass/css3/flexbox/
//http://jsdo.it/Tenderfeel/ofwd
@include flexbox((
display: box,
box-orient: vertical,
box-pack: justify,
box-align: start
), $version: 1);
View isIE.js
var isIE = (function() {
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('msie') >= 0 || ua.indexOf('trident') >= 0) {
var array = /(msie|rv:?)\s?([\d\.]+)/.exec(ua);
return (array) ? array[2] : true;
} else {
return false;
}
}());
View jquery.jpreloader.js
/**
jPreLoader Custom - jQuery plugin
Original: http://www.inwebson.com/demo/jpreloader-v2/
<div id="jpreOverlay">
<div id="jpreLoader">
<div id="jpreAnim">
<img id="jpreAnimImg" src="loader.png" alt="loading">
</div>
<div id="jpreBarWrapper">
<div id="jpreBar"></div>
View checkDatetime.js
//日時チェック(RFC 3339形式)
//@param value {string} datetime-local.value
function checkDatetime(value) {
return(!/20[0-9]{2}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]:[0-5][0-9]/.test(value));
}
View countTxtLength.js
//文字数数える(半角0.5 全角1)
//@param value {string} 数える文字列
function countTxtLength(value) {
var count = 0;
for(var i = value.length; i--; ) {
if(/^[\u0020-\u007e]+$/.test(value.charAt(i))) {
count += 0.5;
} else {
count += 1;