Skip to content

Instantly share code, notes, and snippets.

@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);
@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認証のメッセージ
@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);
@miya0001
miya0001 / wp-update.sh
Last active January 4, 2017 10:18
wp-cli
#!/usr/bin/env bash
set -eu
wp @all core verify-checksums
wp @all vackup create
wp @all core update
wp @all core language update
wp @all plugin update --all
@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に登録

@miya0001
miya0001 / tello.js
Last active January 30, 2019 18:36
Tello + Node.js example
#!/usr/bin/env node
'use strict'
const PORT = 8889;
const HOST = '192.168.10.1';
const dgram = require('dgram');
const client = dgram.createSocket('udp4');
<?php
/**
* Get Google Page Speed Screenshot
*
* Uses Google's Page Speed API to generate a screenshot of a website.
* Returns the image as a base64 jpeg image tag
*
* Usage Example:
* echo getGooglePageSpeedScreenshot("http://ghost.org", 'class="thumbnail"');
*

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

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

概要

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

例えば

  • BASEのアカウントでログインする
  • BASEのショップの商品情報を取得する
@fumikito
fumikito / request.php
Created March 2, 2017 08:07
A typical jQuery request to WordPress REST API
<?php
/**
* Regsiter script
*/
add_action( 'wp_enqueue_scripts', function() {
// Set dependency to wp-api, which has nonce and endpoint root.
wp_enqueue_script( 'api-handler', '/path/to/api-handler.js', [ 'jquery', 'wp-adpi' ], '1.0', true );
} );
@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' ) ) {