Skip to content

Instantly share code, notes, and snippets.

@retgef
retgef / wysiwyg-meta-box.php
Created September 10, 2011 02:06
How to add a Wordpress WYSIWYG editor to a meta box.
<?php
define('WYSIWYG_META_BOX_ID', 'my-editor');
define('WYSIWYG_EDITOR_ID', 'myeditor'); //Important for CSS that this is different
define('WYSIWYG_META_KEY', 'extra-content');
add_action('admin_init', 'wysiwyg_register_meta_box');
function wysiwyg_register_meta_box(){
add_meta_box(WYSIWYG_META_BOX_ID, __('WYSIWYG Meta Box', 'wysiwyg'), 'wysiwyg_render_meta_box', 'post');
}
@miya0001
miya0001 / gist:1378387
Created November 19, 2011 03:30
指定された期限内の記事だけを取得する
<?php
/*
現在の日時から2日後のタイムスタンプを保存する
$d = 2 * 60 * 60 * 24; // 2日間
$expire = current_time('timestamp', get_option("gmt_offset")) + $d;
update_post_meta($post->ID, '_expire', $expire);
@sterlingwes
sterlingwes / tourney.html
Created December 3, 2012 23:42
Tournament Bracket Generator (Javascript + CSS, no tables)
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@wgkoro
wgkoro / resize.js
Last active October 19, 2016 10:56
指定サイズ以内の画像幅、高さを算出、img要素にそのサイズを適用するスクリプト
/**
* 指定サイズ以内の画像幅、高さを算出、
* img要素にそのサイズを適用する
*
* 使い方:
*
* 例) 幅150px, 高さ200px以内で画像を表示する
* var img = document.createElement('img');
* img.src = 'http://hoge.com/img/fuga.jpg';
* imgResize.resize(img, 150, 200);
@gatespace
gatespace / default.conf
Last active July 15, 2016 03:00
網元でWordPressの管理画面にアクセス制限(IP or Basic認証)をかける時に /etc/nginx/conf.d/default.conf に追記する内容
server {
# (略)
location ~* /wp-login\.php|/wp-admin/((?!admin-ajax\.php).)*$ {
index index.php index.html index.htm;
# 許可するIPアドレスを記述
allow 192.168.0.1;
deny all;
# Basic認証のメッセージ
@charleslouis
charleslouis / custom-search-acf-wordpress.php
Last active December 15, 2023 09:11
PHP - Wordpress - Search - wordpress custom search function that encompasses ACF/advanced custom fields and taxonomies and split expression before request
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
}

BASE API v1 ドキュメント (β版)

BASEのAPIの開発者向けのドキュメントです。

概要

このAPIを使うと、あなたのアプリケーションとBASEを連携させることができます。

例えば

  • BASEのアカウントでログインする
  • BASEのショップの商品情報を取得する
@galengidman
galengidman / search.php
Last active September 26, 2021 16:45
WordPress search form & results for custom post type
<?php
// check to see if there is a post type in the URL
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] ) {
// save it for later
$post_type = $_GET['post_type'];
// check to see if a search template exists
if ( locate_template( 'search-' . $post_type . '.php' ) ) {
@wokamoto
wokamoto / gist:5771b3b0b9b83d2e1642
Last active December 7, 2023 07:53
[PHP] Google Calendar API v3 から祝日取得
<?php
function get_holidays_this_month($year, $month){
// 月初日
$first_day = mktime(0, 0, 0, intval($month), 1, intval($year));
// 月末日
$last_day = strtotime('-1 day', mktime(0, 0, 0, intval($month) + 1, 1, intval($year)));
$api_key = 'YOUR API KEY HERE';
$holidays_id = 'outid3el0qkcrsuf89fltf7a4qbacgt9@import.calendar.google.com'; // mozilla.org版
@miya0001
miya0001 / gist:db3ce191e31871964a57
Last active October 21, 2017 02:14
テーマレビュワーのためのVCCW裏ワザ

初期設定

$ mkdir -p ~/vagrants/vccw
$ cd ~/vagrants/vccw
$ git clone git@github.com:miya0001/vccw.git .

次に以下のコードを~/.bash_profileに登録