Skip to content

Instantly share code, notes, and snippets.

@marushu
marushu / import_data_use_sessionstorage.js
Last active August 29, 2015 13:56
イベントデータをロード。 データのポップアップを非表示(閉じるをクリックしたら) ・イベントの終了時間 ・イベントid をsessionStorageに格納。 それぞれのイベントが終わって、 かつ非表示設定になっているイベントデータの情報をクリアする。
var nagasa = $(".each_creature_event li.live").size();
var storage = sessionStorage;
var storageLength = storage.length;
var arr = new Array();
var checkarr = new Array();
var date = new Date();
var unixTimestamp = Math.round( date.getTime() / 1000 );
var pageAttribute = $("html").attr("lang");
@marushu
marushu / content.php
Last active August 29, 2015 13:56
ACF(Advanced Custom Fields)プラグインを使って、館内イベントのデータを取得、直近のイベント10分前からイベントを出力させる
<section id="data_inner">
<?php
// 緊急のお知らせ用カウンタ
$boxcounter = 0;
// サイトの「今日」の日付を取得
$local_timestamp = current_time( 'timestamp' ); // ローカルのタイムスタンプ
$now = gmdate( 'H', $local_timestamp ); // ローカルの時刻文字列
//echo "nowを出力" . $now; // 現在時刻の「時」を出力
<?php
define('CRON_SCHEDULE_HANDLER', 'load_oricon_entry_38');
// wp-cron で実行させたい処理
function cron_schedule_handler() {
load_oricon();
// 指定時間後に再度起動
$time_interval = 5 * 60; // 5 * 60 : 5分おき
wp_schedule_single_event( time() + $time_interval, CRON_SCHEDULE_HANDLER );
<?php
// user role display test
global $wp_roles;
$all_roles = $wp_roles->roles;
echo "<pre>";
print_r( $wp_roles );
echo "</pre>";
ditable_roles = apply_filters('editable_roles', $all_roles);
echo "<pre>";
print_r( $editable_roles );
# Copyright (C) 2014
# This file is distributed under the same license as the package.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/login-lockdown\n"
"POT-Creation-Date: 2014-05-17 05:44:39+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@marushu
marushu / eventcalendar.php
Last active August 29, 2015 14:05
イベントカレンダーをget_calendarコピってきてやってみたんだけど、テーブル書き出す所で今ひとつわかんないところ…。。何度も書き出してしまう所を何とかしたいんだけどなぁ…(^0^;)
<?php
/**
* from /wp-include/general-template : get_calendar
*
* @since 1.5.0
*
* @param int $num Number of day.
* @return int Days since the start of the week.
*/
function monthly_calendar_cosme_week_mod($num) {
@marushu
marushu / order_of_the_japanese_syllabary.php
Last active August 29, 2015 14:05
50音順で出力やりたくてやってみた…(^0^;) いっぺんにダーッとループさせてア行、イ行とか書き出せないもんだろか…
<?php // ア行
$args = array(
'post_type' => 'media_research',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'media_kana',
'value' => 'あ',
'compare' => '>=',
@marushu
marushu / term_bread_clumb.php
Created August 22, 2014 18:41
タームのパンくず。get_ancestorsで辿る感じ。sortで良いのかわかんないんだよなぁ…(^0^;)
<?php
$test = wp_get_post_terms($post->ID, 'product_cat' );
if( ! empty( $test ) && ! is_wp_error( $test ) ) {
$test_2 = wp_get_object_terms( $post->ID, 'product_cat' );
$last_cat_link = get_term_link( $test_2[0]->term_id, 'product_cat' );
$last_cat_name = $test_2[0]->name;
$last_cat_tag = $last_cat_name;
foreach( $test_2 as $var ) {
@marushu
marushu / for_sidebar_widget_recent_post.php
Created August 22, 2014 18:46
サイドバーに各種投稿の新着を出す。テキストウィジェットにショートコードOKな感じで
<?php
function update_list( $atts ) {
extract( shortcode_atts( array(
'post_type' => array( 'ranking', 'magazinenavi', 'topics' ),
'num' => 8,
'class' => 'recent_post',
'order' => 'DESC',
'orderby' => '',
'post_parent' => null,
@marushu
marushu / exclude-same-title-posts.php
Last active August 29, 2015 14:12
投稿を抽出する際、タイトルが同じ投稿がある場合、同名の投稿の中でIDが一番新しいもののみを出す
<?php
$get_posts_arr = array();
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => 'post',
'numberposts' => 10000,
'posts_per_page' => 100,
'paged' => $paged,
);
$another_way_retrieve_posts = get_posts( $args );