旧環境は、最初は静的HTMLと掲示板CGI、後にBlosxom、ファイル操作をミスって日付がおかしくなったあたりからWordPressを使うようになりました。
この環境でWordPressを使うにはなかなか重荷で、PHP5.6未満の頃はAPCuとかOPcacheを別途makeしてみたり(CGIモードだったので効果無かったのですが…)キャッシュプラグインをあれこれ入れてみてなんとか凌いでました。
2004年から14年間、趣味にお仕事に支えていただいた旧環境、本当にありがとうございました。
これからも新環境でどうぞよろしくお願いいたします。
源ノ明朝をウェブフォントとして利用したいけどハイパー重いので、ひらがな・カタカナ・よく使う英数記号・常用漢字だけを抜き取って書き出したい。
あらかじめPythonがインストールされている環境で(MacだとHomebrewで入れるのが良さそう)、fonttools と brotli をインストール。
> pip install fonttools brotli
以下の例は源ノ明朝のサブセットを作る流れです。
> pyftsubset ./SourceHanSerif-Medium.otf --text-file=./subset_joyo.txt --layout-features='*' --flavor=woff --output-file=./SHS-M-joyo.woff > pyftsubset ./SourceHanSerif-Medium.otf --text-file=./subset_joyo.txt --layout-features='*' --flavor=woff2 --output-file=./SHS-M-joyo.woff2
概ね現実的なサイズまで小さくなりました。
@font-face { font-family: "mincho"; src: url("./SHS-M-joyo.woff2") format('woff2'), url("./SHS-M-joyo.woff") format('woff'); } .mincho { font-family: mincho,serif; font-feature-settings: 'palt'; font-size: 24px; letter-spacing: 0.7px; }
毎回フォントファイルを読み込んでしまう場合は、 .htaccess に以下の指定を入れておく。
AddType application/font-woff .woff AddType application/font-woff2 .woff2 <IfModule mod_deflate.c> SetOutputFilter DEFLATE SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|ico)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/font-woff AddOutputFilterByType DEFLATE application/font-woff2 </IfModule> <ifModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 1 seconds" ExpiresByType text/html "access plus 0 seconds" ExpiresByType image/gif "access plus 2592000 seconds" ExpiresByType image/jpeg "access plus 2592000 seconds" ExpiresByType image/png "access plus 2592000 seconds" ExpiresByType text/css "access plus 604800 seconds" ExpiresByType application/javascript "access plus 604800 seconds" ExpiresByType application/font-woff "access plus 1 year" ExpiresByType application/font-woff2 "access plus 1 year" </ifModule>
他所から参照されないようにしておくと安心。
参照 : .htaccess – Prevent others from leaching/downloading fonts using htaccess? – Stack Overflow
SetEnvIfNoCase Referer "^https?://([^/]*)?textbox\.jp/" local_ref=1 SetEnvIf Referer ^$ local_ref=1 <FilesMatch "\.(woff|woff2)$"> Order Allow,Deny Allow from env=local_ref </FilesMatch>]]>
手垢が付きまくった小ネタ。
最初、URLを分解して抜き出すみたいなことをやってたのですが、ページ内のフォーム要素に記載されているようなのでそちらを利用することにします。
PCやスマホ画面を眺めてみると、商品コードが収まる <input type=”hidden”> 要素のnameが ASIN.0 とか ASIN とか asin などまちまちだったので、 document.querySelector に全てのセレクタをつっこんで、見つかったものを摘めばシンプルでよかろうと思いました。
なんやかんやで結局シンプルに、 #cr-state-object 要素のJSONをパースして、商品コード asin を抜き出し、無ければフォーム要素から抜き出すようにしてみました。
javascript:!function(){var e,t=window.location.hostname,a=document.querySelector("#cr-state-object");(e=a?JSON.parse(a.getAttribute("data-state")).asin:document.querySelector('[name="ASIN.0"],[name="ASIN"],[name="asin"],[name="itemId"],[name="titleID"]').value)&&(location.href="https://"+t+"/dp/"+e)}();
上のブックマークレットは、以下のコードをJavaScript Minifierに通しました。
(function(){ var asin, h = window.location.hostname, state = document.querySelector('#cr-state-object'); if ( state ) { asin = JSON.parse( state.getAttribute('data-state') ).asin; } else { asin = document.querySelector('[name="ASIN.0"],[name="ASIN"],[name="asin"],[name="itemId"],[name="titleID"]').value } if ( asin ) location.href = 'https://'+h+'/dp/' + asin; })();]]>
今年も先人の文字を参考に書き初め。
]]>最近のChromeのバージョンでは、以下サイトの方法が最良です。
必要な時はしばらくこんな具合で使ってみます。
font-family: "游ゴシック Medium", "Yu Gothic Medium", "游ゴシック体", YuGothic, "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ Pro W3", Meiryo, Verdana, sans-serif;
※ここから下は現在参考になりませんのでご留意ください。
以外と厄介なんですね…
@font-face { font-family: "Yu Gothic"; src: local("Yu Gothic Medium"),local("Yu Gothic"); font-weight: 500; } @font-face { font-family: "Yu Gothic"; src: local("Yu Gothic Bold"),local("Yu Gothic"); font-weight: bold; } body { font-family: "Yu Gothic", YuGothic, sans-serif; }
たまにこんな塩梅で使っています。
body { font-family: "Yu Gothic", YuGothic, "Lucida Grande", "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ Pro W3", "メイリオ", Meiryo, Osaka, Verdana, sans-serif; font-feature-settings: 'pkna'; letter-spacing: 0.5px; }
比較画像を作ってみました。
游ゴシックは16px未満だと本文書体としては厳しそう。
]]>明代の文人、文徴明氏の「酉」をお手本にしました。
]]>※textbox.jpでは使っていません。
add_action( 'comment_post', 'proxy_comment_unapproved', 15, 1 ); function proxy_comment_unapproved( $comment_ID ) { if ( !empty($_SERVER['HTTP_X_FORWARDED_FOR']) || !empty($_SERVER['HTTP_VIA']) ) { $comment = get_comment( $comment_ID ); $comment_arr = array(); $comment_arr['comment_ID'] = $comment_ID; if ( $comment->comment_approved !== 'spam' ) { $comment_arr['comment_approved'] = 0; } wp_update_comment( $comment_arr ); } }
参考:Function Reference/wp update comment
もうちょっと頑張るならば、例えばTorの出口ノードリストを定期的に取得して保存しておき、投稿者のIPアドレスがそれに含まれるか判定する条件分岐を追加しても良いかもしれません。
]]>global $post; $url = get_permalink($post->ID); $enc_url = rawurlencode($url); $title = get_the_title($post->ID) . ' | (短めのサイト名)'; $enc_title = rawurlencode($title); $thumbnail = get_the_post_thumbnail_url($post->ID,'large'); $enc_thumbnail = rawurlencode($thumbnail); $link_twitter = 'http://twitter.com/intent/tweet?text='.$enc_title.'&url='.$enc_url; $link_facebook = 'http://www.facebook.com/sharer.php?u='.$enc_url; $link_hatena = 'http://b.hatena.ne.jp/entry/'.$enc_url; $link_line = 'http://line.me/R/msg/text/?'.$enc_title.'%20'.$enc_url; $link_pinterest = 'http://www.pinterest.com/pin/create/button/?url='.$enc_url.'&media='.$enc_thumbnail.'&description='.$enc_url;]]>
■使用例
*中のテキストもまるごと取り下げたい
[limit_link href="http://www.google.com" end="2016-03-05 01:51:00"]サンプルテキスト[/limit_text]
*リンクだけ取り下げたい+別ウィンドウで開く
[limit_link href="http://www.google.com" end="2016-03-05 01:51:00" target="_blank" text="show"]サンプルテキスト[/limit_link]
function custom_shortcode_limit_link( $atts, $content = null ) { extract( shortcode_atts( array( 'href' => 'http://example.com/', 'target' => '_self', 'end' => '2015-12-31 23:59:59', 'text' => 'hide' ), $atts ) ); $now = date_i18n('U'); // 現在の時刻 $expire_date = date('U',strtotime($end)); // 取り下げ時刻 if($expire_date >= $now) { // リンク掲出期間中 return '<a href="' . esc_html($href) . '" target="' . esc_html($target) . '">' . esc_html($content) . '</a>'; } elseif ($text === 'show') { // 掲出終了後、テキストは表示する場合 return esc_html($content); } else { // 掲出終了後、丸ごと消す場合 return; } } add_shortcode('limit_link', 'custom_shortcode_limit_link');]]>
下記サイトを参考にしました。
How can I add a default description to uploaded files?
http://wordpress.stackexchange.com/questions/121709/how-can-i-add-a-default-description-to-uploaded-files