-WordPress

パスワード保護ページは、デフォルトで10日のパスワード保存であり、
クッキーでパスワードを保存させない。
(パスワード保護してあるページすべてが毎回パスワード入力の必要が出てくる可能性があるので注意)
以下のコードをfuncthion.phpに追加

add_action('after_setup_theme', 'my_after_setup_theme' );
function my_after_setup_theme(){
setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], 0, COOKIEPATH);
}

キャッシュさせたくない(最新ページを表示して欲しい)

ヘッダーキャッシュしないでと書き込む

[html]<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT" />
[/html]

が、やはり、便利な機能なので、全部ページをキャッシュしないサイトはイカンので、WordPress関数を使って指定ページにのみヘッダーに追加するという事で、こんな感じで

[php]<?php if(is_page(‘ページID’)): ?>
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Expires" content="Thu, 01 Dec 1994 16:00:00 GMT" />
<?php endif; ?>
[/php]

覚書です。

SI CAPTCHA Anti-Spam 使えなかった

WordPressのセキュリティーアップとして、プラグイン「SI CAPTCHA Anti-Spam」を使いたかったのですが、他のプラグインと競合しているようで使えませんでした。
具体的には、ログイン画面に設定すると正しいパスワードを入れてもログインできなくなります・・・(゜o゜)

もし、FTPなどでサーバー領域にアクセスできない場合はヤバいですが、そんなことはないと思いますので、じかにアクセスして、該当のプラグインのフォルダー名など変更してください。

他のセキュリティー対策考えよ・・・

ということで、Stealth Login Page これを使ってみました。
シンプルですが充分です。

カスタマイズのために functions-auth-key.php ファイルを少し触ってOK!

もちろん作成したお客様のサイトの仕様によって対処方法は様々です。
今回は、これってことになりました。

CSSの達人

CSSの達人になりたいと思っているのとは別に、WPを触っていて、時々そのページだけCSSを編集したい、という場合に、重宝する機能
カスタムCSS custom CSS

これは便利です。こちらから引用(Thanks!)

下記のデータをfunction.phpに書き込む

[php]
//Custom CSS Widget
add_action(‘admin_menu’, ‘custom_css_hooks’);
add_action(‘save_post’, ‘save_custom_css’);
add_action(‘wp_head’,’insert_custom_css’);
function custom_css_hooks() {
add_meta_box(‘custom_css’, ‘Custom CSS’, ‘custom_css_input’, ‘post’, ‘normal’, ‘high’);
add_meta_box(‘custom_css’, ‘Custom CSS’, ‘custom_css_input’, ‘page’, ‘normal’, ‘high’);
}
function custom_css_input() {
global $post;
echo ‘<input type="hidden" name="custom_css_noncename" id="custom_css_noncename" value="’.wp_create_nonce(‘custom-css’).’" />’;
echo ‘<textarea name="custom_css" id="custom_css" rows="5" cols="30" style="width:100%;">’.get_post_meta($post->ID,’_custom_css’,true).'</textarea>’;
}
function save_custom_css($post_id) {
if (!wp_verify_nonce($_POST[‘custom_css_noncename’], ‘custom-css’)) return $post_id;
if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return $post_id;
$custom_css = $_POST[‘custom_css’];
update_post_meta($post_id, ‘_custom_css’, $custom_css);
}
function insert_custom_css() {
if (is_page() || is_single()) {
if (have_posts()) : while (have_posts()) : the_post();
echo ‘<style type="text/css">’.get_post_meta(get_the_ID(), ‘_custom_css’, true).'</style>’;
endwhile; endif;
rewind_posts();
}
}
[/php]

ついでにJSも

[php]
JavaScriptを追加できるようにする場合は、以下をfunctions.phpに記述します。
//Custom JS Widget
add_action(‘admin_menu’, ‘custom_js_hooks’);
add_action(‘save_post’, ‘save_custom_js’);
add_action(‘wp_head’,’insert_custom_js’);
function custom_js_hooks() {
add_meta_box(‘custom_js’, ‘Custom JS’, ‘custom_js_input’, ‘post’, ‘normal’, ‘high’);
add_meta_box(‘custom_js’, ‘Custom JS’, ‘custom_js_input’, ‘page’, ‘normal’, ‘high’);
}
function custom_js_input() {
global $post;
echo ‘<input type="hidden" name="custom_js_noncename" id="custom_js_noncename" value="’.wp_create_nonce(‘custom-js’).’" />’;
echo ‘<textarea name="custom_js" id="custom_js" rows="5" cols="30" style="width:100%;">’.get_post_meta($post->ID,’_custom_js’,true).'</textarea>’;
}
function save_custom_js($post_id) {
if (!wp_verify_nonce($_POST[‘custom_js_noncename’], ‘custom-js’)) return $post_id;
if (defined(‘DOING_AUTOSAVE’) && DOING_AUTOSAVE) return $post_id;
$custom_js = $_POST[‘custom_js’];
update_post_meta($post_id, ‘_custom_js’, $custom_js);
}
function insert_custom_js() {
if (is_page() || is_single()) {
if (have_posts()) : while (have_posts()) : the_post();
echo ‘<script type="text/javascript">’.get_post_meta(get_the_ID(), ‘_custom_js’, true).'</script>’;
endwhile; endif;
rewind_posts();
}
}
[/php]

WPデータ移行

WordPress サイト作成時に 仮の領域でサイト作成し、本番環境に移すことが多々あるのですが、
お客様の状況により、仮領域と本番環境間でデータ移行を何度か繰り返す事がありました。

その際、移行時の手続きはバッチしOKと思ったのですが、うまくいかない時がありました。
その時に行った対応をφ(..)メモメモ

1.カスタムメニューを使っている場合は、メニューを保存を再度押す
(メニュー部がおかしいので気づきやすい)

2. ページ・記事が表示されない現象が起こった時は、パーマリンク設定の保存ボタンももう一度押す。
(TOPだけは正常に表示されたりするので気づきにくい。しかもTOP以外が表示されないので移行のミスかと思う)

文字化けメモ

メモ φ(..)メモメモ
Terapadで文字コードを変換(utf-8)にすればOKだったのですが・・・
Wpへの移行作業で、どうしても一部(日本語表記の部分)が文字化けする・・・・

flashバリバリのサイト。

Terapadの「ファイル」⇒ 「文字コードして再読み込み」でなく、
「文字/改行コード指定保存」で utf-8N を選ぶと文字化け消えました・・・・

Nありかなしかは、ボムありかなしかってヤツですね。。。
φ(..)メモメモ