Skip to content

Instantly share code, notes, and snippets.

View miya0001's full-sized avatar

Takayuki Miyauchi miya0001

View GitHub Profile
@miya0001
miya0001 / twitter2facebook.php
Created April 24, 2011 04:33
コマンドライン引数で指定したユーザーの最新のツイートをfacebookのウォールに投稿する。
<?php
require_once(dirname(__FILE__).'/src/facebook.php'); // facebook SDK for php
define("TOKEN", "YOUR ACCESS TOKEN");
define("API", "http://twitter.com/statuses/user_timeline/%s.json");
define("LINK_URL", "http://twitter.com/#!/%s/status/%s");
$facebook = new Facebook(array(
'appId' => 'YOUR APP ID',
@miya0001
miya0001 / gist:946144
Created April 28, 2011 10:38
oEmbed gist
<?php
/*
Plugin Name: oEmbed gist
Plugin URI: http://firegoby.theta.ne.jp/wp/oembed-gist
Description: Embed source from gist.github.
Author: Takayuki Miyauchi (THETA NETWORKS Co,.Ltd)
Version: 0.1.0
Author URI: http://firegoby.theta.ne.jp/
*/
@miya0001
miya0001 / gist:950365
Created May 1, 2011 09:21
facebookのJavaScript SDKでiframeの高さを調整してスクロールバーを回避する
<script type="text/javascript"
src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/JavaScript">
FB.init({
appId: 'Your App ID', // edit it
status: true,
cookie: true,
xfbml: true,
logging: true
});
@miya0001
miya0001 / example.php
Created May 4, 2011 08:03
add_actionの使い方
<?php
/*
以下はどちらの方法が良いのでしょう?
add_action()を条件式の中に入れるべき? 関数の中に条件式を入れるべき?
*/
/* 書くのがちょっとだけ楽 */
if (is_home()) {
@miya0001
miya0001 / fblinter.php
Created May 5, 2011 19:41
update cache on facebook of your post
<?php
/*
Plugin Name: Facebook Linter
Author: Takayuki Miyauchi
Description: update cache on facebook of your post
*/
new FBLinter();
class FBLinter {
@miya0001
miya0001 / disable_quick_cache.php
Created May 6, 2011 12:21
Do not cache mobile theme of wptouch with quick cache
<?php
/*
Plugin Name: Disable Quick Cache with WPtouch
Author: Takayuki Miyauchi
*/
add_filter('theme_root', 'disable_quick_cache', 9999);
function disable_quick_cache($path){
if (preg_match("/plugins\/wptouch/", $path)) {
@miya0001
miya0001 / suffix2console.php
Created May 7, 2011 17:12
WordPress管理画面のhook_suffixをJavaScriptコンソールに出力する
<?php
/*
Plugin name: Hook Suffix Console
*/
add_action("admin_head", 'suffix2console');
function suffix2console() {
global $hook_suffix;
if (is_user_logged_in()) {
$str = "<script type=\"text/javascript\">console.log('%s')</script>";
@miya0001
miya0001 / gist:962076
Created May 9, 2011 04:56
ビジュアルエディターに必要なJavaScriptやCSSをロードする
<?php
function admin_head_editor()
{
wp_enqueue_script('common');
wp_enqueue_script('jquery-color');
wp_print_scripts('editor');
if (function_exists('add_thickbox')) add_thickbox();
wp_print_scripts('media-upload');
if (function_exists('wp_tiny_mce')) wp_tiny_mce();
@miya0001
miya0001 / instagram.php
Created May 9, 2011 19:27
Instagramの写真のパーマリンクからユーザーID、JsonのURL、AtomのURLを取得する
<?php
/*
Author: Takayuki Miyauchi
URL: http://firegoby.theta.ne.jp/archives/2246
*/
class instagram {
private $json = "http://instagram.heroku.com/users/%s.json";
private $atom = "http://instagram.heroku.com/users/%s.atom";
@miya0001
miya0001 / switchTheme.php
Created May 10, 2011 19:39
switch theme class for wordpress plugin
<?php
class switchTheme {
private $name = null;
private $dir = null;
private $url = null;
function __construct($name = null, $dir = null, $url = null)
{
$this->name = $name;