Skip to content

Instantly share code, notes, and snippets.

View hissy's full-sized avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@wokamoto
wokamoto / crazy_bone-admin_menu_capability.php
Last active December 21, 2015 01:28
[WordPress] [Crazy Bone] Don't show menu 'Login log' to non-administrator.
<?php
add_filter('crazy_bone::admin_menu_capability', 'crazy_bone_capability');
function crazy_bone_capability($capability){
return 'edit_users';
}
@tenman
tenman / gist:6373691
Created August 29, 2013 02:37
このファイルは、個別のテーマやプラグインファイルの簡単な検査と、それぞれのファイルで使用されているMD5_FILEの値を計算し配列として表示します。 表示された配列を、テーマやプラグインディレクトリに、check-same.phpという名前で表示すると、次回から現在のMD5_FILEと記録されたMD5_FILEと比較して、ファイルに変更があったかどうかを表示する事が出来ます。
<?php
/*
File Name: detect-bom.php
Description: WordPressのインストールディレクトリに配置する事で、テーマ、プラグインの簡易的な検査と、それぞれのテーマやテンプレートファイルで使われているファイルのMD5_FILEを、表示します。テーマやプラグインのルートディレクトリにcheck-same.phpとして表示された配列をphpとしてペーストしておくと、次回の検査で、check-same.php配置後に変更されたテーマやテンプレートの同一性をチェックする事ができます。
Author: Tenman
Author URI: http://www.tenman.info/
Version: 0.1
License: GNU General Public License v2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
@miya0001
miya0001 / gist:7840745
Last active December 30, 2015 14:09
WordPressに独自のURLこの例では、/json/を追加する際のサンプル。 プラグインの無効化時にルールをキャッシュから削除 & 他のプラグインや管理者の操作によってflush_rewrite_rules()が発火した際に再登録を行う。
<?php
// プラグインの有効化時/無効化時の処理を登録
register_activation_hook( __FILE__ , 'my_activation_callback' );
register_deactivation_hook( __FILE__ , 'my_deactivation_callback' );
// 他のプラグインや管理者の操作によってflush_rewrite_rules()が発火した際にこのプラグイン用のrewrite ruleを再登録する
add_action( 'delete_option', 'my_delete_option', 10, 1 );
@tao-s
tao-s / get_updated_stack_pages.php
Last active March 24, 2016 21:08
concrete5 5.7系で、更新されたスタックとグローバルエリアが利用されているページのcID一覧を取得するJobのサンプルコード
<?php
namespace Application\Job;
use Concrete\Core\Cache\Cache;
use Config;
use Job as AbstractJob;
use Core;
use Database;
use PermissionKey;
@miya0001
miya0001 / class-addrewriterules.php
Created September 30, 2011 15:02
WPに任意のURLを追加するためのクラス
<?php
if (!class_exists('WP_AddRewriteRules')):
class WP_AddRewriteRules{
private $rule = null;
private $query = null;
private $callback = null;
function __construct($rule, $query, $callback)
{
@CAWeissen
CAWeissen / rscsv-p2p-plugin.php
Last active July 16, 2016 23:14
This plugin allows Posts 2 Posts connections to be created and imported using Really Simple CSV Importer. This WordPress plugin requires Really Simple CSV Importer (https://wordpress.org/plugins/really-simple-csv-importer/) and Posts 2 Posts (https://wordpress.org/support/view/plugin-reviews/posts-to-posts)
<?php
/*
-------------------------------------------------------
Plugin Name: RSCSV/Posts 2 Posts
Description: Connect imported posts using Posts 2 Posts connections
Author: Chris Weissenberger, Aleksandr Beliaev
Version: 1.3
*/
add_filter('really_simple_csv_importer_post_saved', function($post) {
if (is_object($post)) {
@PhilippSoehnlein
PhilippSoehnlein / modernizr-test_position_fixed_ios.js
Created November 3, 2011 12:23
Modernizr Test for position fixed (including iOS tests)
/* modernizr-test_position_fixed_ios.js
* Original by Daniel Ott (https://gist.github.com/1333800)
* 3 March 2011
* Updated by Philipp Söhnlein 3 November 2011
* Custom Tests using Modernizr's addTest API
*/
/* iOS
* There may be times when we need a quick way to reference whether iOS is in play or not.
* While a primative means, will be helpful for that.
@miya0001
miya0001 / gist:1916258
Created February 26, 2012 11:49
都道府県コード(PHP)
<?php
$pref_codes = array("01" => "北海道", "02" => "青森県", "03" => "岩手県", "04" => "宮城県", "05" => "秋田県", "06" => "山形県", "07" => "福島県", "08" => "茨城県", "09" => "栃木県", "10" => "群馬県", "11" => "埼玉県", "12" => "千葉県", "13" => "東京都", "14" => "神奈川県", "15" => "新潟県", "16" => "富山県", "17" => "石川県", "18" => "福井県", "19" => "山梨県", "20" => "長野県", "21" => "岐阜県", "22" => "静岡県", "23" => "愛知県", "24" => "三重県", "25" => "滋賀県", "26" => "京都府", "27" => "大阪府", "28" => "兵庫県", "29" => "奈良県", "30" => "和歌山県", "31" => "鳥取県", "32" => "島根県", "33" => "岡山県", "34" => "広島県", "35" => "山口県", "36" => "徳島県", "37" => "香川県", "38" => "愛媛県", "39" => "高知県", "40" => "福岡県", "41" => "佐賀県", "42" => "長崎県", "43" => "熊本県", "44" => "大分県", "45" => "宮崎県", "46" => "鹿児島県", "47" => "沖縄県");
?>
@pimpmywp
pimpmywp / class-pm-schedule-post.php
Created December 29, 2012 08:21
[WordPress] 記事の公開開始日時・公開終了日時をカスタムフィールドで個別/同時に指定する
<?php
if ( ! class_exists( 'PM_Schedule_Post' ) ) {
class PM_Schedule_Post {
protected $from = '';
protected $to = '';
protected $label = '';
public function __construct( $from, $to, $label = 'expired' ) {
$this->from = $from;
$this->to = $to;
@katzueno
katzueno / .htaccess
Last active January 30, 2018 00:27 — forked from hissy/.htaccess
Whitelisting IP for concrete5 dashboard / IP アドレス制限
## -- concrete5 urls start --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Change RewriteBase path if this concrete5 is installed on subdirectory / concrete5 がサブディレクトリにインストールされていたら、RewriteBase の変更が必要です。
# IP address restriction starts here / IP アドレス制限、アクセス許可するのIPの設定
RewriteCond %{REMOTE_ADDR} !123\.4\.56\.789
RewriteCond %{REMOTE_ADDR} !123\.123\.123\.123
# Add more lines is you have more IP / もっとIPがある場合は、行を追加してください