Skip to content

Instantly share code, notes, and snippets.

if ( ! function_exists( 'mw_wp_form_colored_status' ) ) :
function mw_wp_form_colored_status( $classes, $class, $ID )
{
if ( ! in_array( 'mw-wp-form/mw-wp-form.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
return $classes;
}
if ( 'edit.php' !== basename( $_SERVER['PHP_SELF'] ) ) {
return $classes;
}
if ( ! isset( $_REQUEST['post_type'] ) || ! post_type_exists( $_REQUEST['post_type'] ) || false === strpos( $_REQUEST['post_type'], MWF_Config::DBDATA ) ) {
@mt8
mt8 / _ide_helper.php
Created May 5, 2016 08:50 — forked from barryvdh/_ide_helper.php
Laravel IDE Helper for Netbeans / PhpStorm / Sublime Text 2 CodeIntel, generated using https://github.com/barryvdh/laravel-ide-helper
<?php
/**
* A helper file for Laravel 5, to provide autocomplete information to your IDE
* Generated for Laravel 5.1.31 (LTS) on 2016-03-01.
*
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
namespace {
@mt8
mt8 / functions.php
Last active July 20, 2016 06:55
[WordPress] カスタム投稿タイプのアーカイブ件数を変更する
<?php
function set_cpt_per_page( $query ) {
$cpt = 'news';
$per_page = 10;
if ( ! is_admin() && $query->is_main_query() && is_post_type_archive( $cpt ) ) {
$query->set( 'posts_per_page', $per_page );
}
}
add_action( 'pre_get_posts', 'set_cpt_per_page' );
@mt8
mt8 / php-build.patch
Last active October 19, 2016 03:07
phpenv + php-build で libphp5.so をapatcheモジュールにコピーしないためのパッチ v0.11.0dev対応
diff --git bin/php-build bin/php-build
index 273a11a..60fe31a 100755
--- bin/php-build
+++ bin/php-build
@@ -334,6 +334,10 @@ function build_package() {
cd "$source_path"
{
+ if which apxs > /dev/null 2>&1; then
+ _LIBEXECDIR=`apxs -q LIBEXECDIR`
@mt8
mt8 / plugin.php
Created February 3, 2017 02:22
特定のWordPressプラグインを管理画面メニューでON/OFFするプラグイン
<?php
/*
* Plugin Name: Plugin On Off
*/
$poo = new Plugin_On_Off();
$poo->register_hooks();
class Plugin_On_Off {
@mt8
mt8 / functions.php
Last active April 14, 2017 08:01
StaticPressとか使うとき用。非SSLWordPressで再構築するときにGravatarをSSLで取得するためのコード
<?php
function my_pre_get_avatar_data( $args, $id_or_email ) {
$args['scheme'] = 'https';
return $args;
}
add_filter( 'pre_get_avatar_data', 'my_pre_get_avatar_data', 10, 2 );
@mt8
mt8 / lambda_function.py
Last active October 4, 2017 10:41
[AWS] Lambdaで出力したCloudWatchログのログストリームURLをLambda内で取得するPython(エラー調査などに便利)
def lambda_handler(event, context):
region = context.invoked_function_arn.split(":")[3]
request_id = context.aws_request_id
log_group_name = context.log_group_name
log_stream_name = context.log_stream_name
log_url = "https://"+region+".console.aws.amazon.com/cloudwatch/home?region="+region+"#logEvent:group="+log_group_name+";stream="+log_stream_name
print log_url
@mt8
mt8 / add_inputs_for_reply.php
Last active January 9, 2018 04:57
[WordPress] bbPressのカスタマイズサンプル
<?php
//「今後の返信をメールで通知」の後にフック
add_action('bbp_theme_after_reply_form_subscription', 'my_bbp_theme_after_reply_form_subscription');
/**
* トピック回答フォームの「今後の返信をメールで通知」項目の後のアクションフック処理
*/
function my_bbp_theme_after_reply_form_subscription() {
?>
@mt8
mt8 / memo.sh
Last active January 31, 2018 07:58
Time4VPSでBitZenyをマイニングするメモ https://mt8.biz/953
#ブログ記事はコチラ:https://mt8.biz/953
#====================
#事前準備(Mac)
#====================
#---手元のマシン(Mac)で鍵を作成---
cd ~/.ssh/
ssh-keygen -t rsa -f time4vps
@mt8
mt8 / wp-cli.sh
Created May 17, 2018 11:13
wp-cliで◯年の記事を一括で削除する
wp post delete $(wp post list --post_type='post' --format=ids --date_query=2017)