This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
the_post(); | |
/** | |
* Get color function. | |
* | |
* Get term meta on loop is little bit annoying. | |
* You should define some wrapper function. | |
*/ | |
function get_color($tag){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if( isset( $argv[1] ) && preg_match('/(-{1,2})?help$/', $argv[1] ) ) { | |
echo <<<'TXT' | |
/** | |
* Archive git diff file between specified commit | |
* | |
* git_diff ./archive 29879823c HEAD | |
* | |
* Enter above, diff between HEAD and 29879823c will be arvhived to `./archive`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml" class="blog logged-in epub-toc rtl" | |
xmlns:epub="http://www.idpf.org/2007/ops"> | |
<head> | |
<meta charset="UTF-8"/> | |
<title> 目次</title> | |
<meta name="viewport" content="width=device-width"/> | |
<link rel="stylesheet" href="../Asset/wp-content/themes/hametuha/assets/css/epub.css" type="text/css"/> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$table = new \cli\Table(); | |
$table->setHeaders( $header ); | |
$table->setRows( $body ); | |
$table->display(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// これでWordPress関数がほとんど使えるようになる! | |
include 'wp-load.php'; | |
// オプションを10件取得 | |
$options = $wpdb->get_results("SELECT * FROM {$wpdb->options} LIMIT 10"); | |
// 公開済み投稿の本文の長さを全部足す | |
$query = <<<SQL | |
SELECT SUM(CHAR_LENGTH(post_content)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The MeCab PHP extension | |
* | |
* Copyright (c) 2006-2012 Ryusuke SEKIYAMA. All rights reserved. | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a | |
* copy of this software and associated documentation files (the "Software"), | |
* to deal in the Software without restriction, including without limitation | |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = explode("\n", file_get_contents('./lsf.txt')); | |
$variables = []; | |
$sass = []; | |
foreach($file as $row){ | |
list($title, $aliases, $unicode) = array_map('trim', explode("\t", trim($row))); | |
$title = 'lsf-'.$title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* catchブロックの中でエラーを投げてみる | |
* | |
* php try-catch.php 1000と入力すると、 | |
* Uncaught exceptionが発生。したがって、こういうことをやりたい場合は | |
* 入れ子にしないとダメ。 | |
* 結果的に、例外の種類が増えると入れ子がどんどん深くなっていく | |
* 5.5ならfinally があるので、もうちょっとすっきりできる | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function($){ | |
// ショートコード挿入 | |
$('.button-shortcode').click(function(e){ | |
e.preventDefault(); | |
// ex. ショートコードの値 | |
var shortcode = $(this).prev('input').val(), | |
mce = window.parent.tinyMCE; | |
if( mce.activeEditor && !(mce.activeEditor.isHidden()) ){ | |
// TinyMCEがオープンならそれを使う | |
window.parent.tinyMCE.activeEditor.execCommand( 'mceInsertContent', false, shortCode ) |