Skip to content

Instantly share code, notes, and snippets.

@lunaluna
lunaluna / basic-oauth.md
Last active March 30, 2020 02:16
Basic認証のあるページにURLだけで直接アクセス

ユーザー名とパスワードを一緒に入力してアクセス

https://{{user}}:{{password}}@example.com/

ユーザー名がメアドだった場合(あるいはパスワードに @ が含まれていた場合)

@ をURLエンコード( %40 )する

@lunaluna
lunaluna / ie10-hack.css
Created March 24, 2020 03:05
【IE11】CSS hack
@media all and (-ms-high-contrast:none){
.foo { color: green } /* IE10 */
}
@lunaluna
lunaluna / functions-update_option_new_admin_email.php
Last active March 5, 2020 18:06
【WordPress】管理者のメールアドレスを変更したときに飛ぶ確認通知を無効に
remove_action( 'add_option_new_admin_email', 'update_option_new_admin_email' );
remove_action( 'update_option_new_admin_email', 'update_option_new_admin_email' );
/**
* Disable the confirmation notices when an administrator
* changes their email address.
*
* @see http://codex.wordpress.com/Function_Reference/update_option_new_admin_email
*/
function wpdocs_update_option_new_admin_email( $old_value, $value ) {
@lunaluna
lunaluna / functions-ex.php
Last active January 24, 2020 05:11
【WordPress】wp_add_inline_script( string $handle, string $data, string $position = 'after' )
<?php
// WordPress 4.4.x までの書き方
function ex_enqueue_scripts() {
if ( !wp_script_is( 'jquery', 'done' ) ) {
wp_enqueue_script( 'jquery' );
}
}
add_action( 'wp_enqueue_scripts', 'ex_enqueue_scripts' );
@lunaluna
lunaluna / functions.php
Last active January 24, 2020 04:51
【WordPress】外部から読み込んでいる各スクリプト要素にハッシュ値と crossorigin="anonymous" を挿入する
<?php
// 例えばそれぞれのスクリプトを CDN から読み込ませてるときは enqueue したあとにこんなふうに書くと追記できる
add_filter( 'script_loader_tag', 'add_attribs_to_scripts', 10, 3 );
function add_attribs_to_scripts( $tag, $handle, $src ) {
$easing = array( 'easing' ); // ここは enqueue したときのハンドル名
$popper = array( 'popper' );
$bootstrap = array( 'bootstrap' );
$validate = array( 'validate' );
@lunaluna
lunaluna / git_rm_cached.md
Last active June 12, 2019 05:02
.gitignoreを後から適用する

通常の場合(あとから変更したものを反映させたい場合)

$ git rm -r --cached .

部分的に(特定のファイルだけ)反映させたい場合

$ git rm --cached ***.php
@lunaluna
lunaluna / front_page_id.php
Created June 11, 2019 09:39
WordPressのフロントページに設定したページのIDを取得
<?php
$front_page_id = get_option( 'page_on_front' );
@lunaluna
lunaluna / wget_basic_authentication.md
Created May 31, 2019 04:57
BASIC認証で制限の掛かったサーバーからwgetする
$ wget --http-user={username} --http-passwd={password} {url}
@lunaluna
lunaluna / zip_command.md
Last active August 9, 2023 07:04
zipコマンドでディレクトリをzip化
  1. zipコマンドでディレクトリをzip化
$ zip -r {directory_name}.zip {directory_name}
  1. unzip
$ unzip {zip_name}.zip
@lunaluna
lunaluna / pull_remote_branch.md
Created May 31, 2019 02:17
リモートのgitブランチをローカルにチェックアウトする
  1. まず fetch する。
$ git fetch
  1. ローカルブランチ名を指定して、リモートブランチをチェックアウトする
$ git checkout -b {{branch}} origin/{{branch}}