Skip to content

Instantly share code, notes, and snippets.

@wokamoto
wokamoto / wp-custom-search.php
Last active May 5, 2024 08:06
WordPress でユーザー名とか、タグ名・カテゴリ名も検索対象に
<?php
function custom_search($search, $wp_query) {
global $wpdb;
//サーチページ以外だったら終了
if (!$wp_query->is_search)
return $search;
if (!isset($wp_query->query_vars))
return $search;
@wokamoto
wokamoto / gist:5771b3b0b9b83d2e1642
Last active December 7, 2023 07:53
[PHP] Google Calendar API v3 から祝日取得
<?php
function get_holidays_this_month($year, $month){
// 月初日
$first_day = mktime(0, 0, 0, intval($month), 1, intval($year));
// 月末日
$last_day = strtotime('-1 day', mktime(0, 0, 0, intval($month) + 1, 1, intval($year)));
$api_key = 'YOUR API KEY HERE';
$holidays_id = 'outid3el0qkcrsuf89fltf7a4qbacgt9@import.calendar.google.com'; // mozilla.org版
@wokamoto
wokamoto / user_meta_transient.php
Last active July 17, 2023 11:53
[WordPress] user_meta transient
<?php
/**
* Delete a user meta transient.
*/
function delete_user_meta_transient( $user_id, $transient ) {
global $_wp_using_ext_object_cache;
$user_id = (int) $user_id;
do_action( 'delete_user_meta_transient_' . $transient, $user_id, $transient );
@wokamoto
wokamoto / replace-siteurl.php
Created September 4, 2012 23:22
WordPress のDB上のサイトURLを一気に変換
#!/usr/bin/php
<?php
switch($argc) {
case 1:
case 2:
echo "please input new site url and wp directory name!\n";
exit();
default:
$old_site = isset($argv[3]) ? $argv[3] : '';
$path = $argv[2];
@wokamoto
wokamoto / pushToSlack.js
Created March 13, 2023 07:57
pushToSlack.js
'use strict';
const https = require('https');
const util = require('util');
const project = process.env.project;
const slachChannel = process.env.slachChannel;
const slackPath = process.env.slackPath;
async function sendRequest(opts,replyData){
@wokamoto
wokamoto / keybaseProof.md
Last active January 13, 2023 00:43
keybaseProof.md

Keybase proof

I hereby claim:

  • I am wokamoto on github.
  • I am wokamoto (https://keybase.io/wokamoto) on keybase.
  • I have a public key ASDGzDKw-516wDu3n1fgijVBijydz-Qn8a4goEHH6Va3Pwo

To claim this, I am signing this object:

@wokamoto
wokamoto / gist:b9eb0f22d9948a38544d
Last active December 15, 2021 04:39
[Nginx][WordPress] Nginx で WordPress の管理画面に BASIC 認証をかける ( ただし /wp-admin/admin-ajax.php, /wp-admin/css/*, /wp-admin/js/* にはかけない )
location ~* /wp-login\.php|/wp-admin/((?!(admin-ajax\.php|css/|js/)).)*$ {
index index.php index.html index.htm;
# Basic認証のメッセージ
auth_basic "Please enter your ID and password";
# .htpasswd ファイルのパス
auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
location ~ .*\.php$ {
try_files $uri =404;
@wokamoto
wokamoto / gist:9340462
Last active April 29, 2021 20:08
[Nginx] mobile-detect
set $mobile '';
set $mobile_off '';
if ($http_user_agent ~* '(DoCoMo|J-PHONE|Vodafone|MOT-|UP\.Browser|DDIPOCKET|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode|WILLCOM|SoftBank|Semulator|Vemulator|J-EMULATOR|emobile|mixi-mobile-converter|PSP)') {
set $mobile "@ktai";
}
if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') {
set $mobile "@smartphone";
}
if ($http_cookie ~* "wptouch[^\=]+\=(normal|desktop)") {
set $mobile_off "${mobile}.off";
@wokamoto
wokamoto / Brewfile
Last active February 27, 2021 12:19
cask_args appdir: "/Applications"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-versions"
tap "homebrew/cask-fonts"
tap "homebrew/core"
tap "argon/mas"
tap "rcmdnk/file"
'use strict';
const lastUpdateFileName = './lastupdate.txt';
const feedUrl = 'https://example.com/rss';
const typetalkTopicNum = '__TYPETALK_TOPIC_NUMBER_HERE__';
const typetalkToken = '__TYPETALK_TOKEN_HERE__'
const fs = require('fs');
const FeedParser = require('feedparser');
const https = require('https');