WordPress maaguu (^^; com 北海道札幌でホームページ制作を楽しむ

WordPress, WordPress MU(μ) についての話題、プラグイン作成、カスタマイズ。

bloginfo(‘admin_email’)のメールアドレスを数値文字参照に変換する

WordPressのテンプレートにbloginfo('admin_email')と書くと、メールアドレスがそのまま書き出されます。メールアドレス収集ロボットのこともありまして、それはちょっと困ったということで、これを数値文字参照に変換してしまいます(数値文字参照が有効かどうかはさておき、ほんの少しの精神的安定のため)。

<?php
/*
Plugin Name: maaguu_replace_admin_email.php
Plugin URI: http://wp.maaguu.com/2008/12/12/replace-admin-email/
Description:
Version: 1.0
Author: maaguu
Author URI: http://maaguu.com/
*/

/*  Copyright 2008 maaguu (email : info@mx.maaguu.com)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

class maaguu_replace_admin_email
{
    private $replace_admin_email;

    public function __construct()
    {
        $this->replace_admin_email;
        add_filter('option_admin_email', array($this, 'replace_admin_email'));
    }

    public function replace_admin_email($email)
    {
        for ($i = 0; $i < strlen($email); $i++)
        {
            $this->replace_admin_email .= '&#' . ord($email[$i]) . ';';
        }
        return $this->replace_admin_email;
    }
}

new maaguu_replace_admin_email();

/* End of file maaguu_admin_email.php */

プラグインディレクトリに置いて有効にするだけで使えます。

しかしここで問題が。

headのメールアドレスは変換されていますが、プラグインで書き出したフッタが変換されません(^^ゞ どうしようかなあ……。

というより、このプラグイン、動作がおかしいですので使わないほうがよさげ(^^ゞ

ポイントを現金でキャッシュバック

「bloginfo(‘admin_email’)のメールアドレスを数値文字参照に変換する」へのコメント(One Response)

  1. Eメールアドレスを数値文字参照に変換する関数 | WordPress maaguu (^^; com 北海道札幌でホームページ制作を楽しむ

    [...] こんな関数があるのなら、bloginfo(’admin_email’)のメールアドレスを数値文字参照に変換するのは無駄でした。 [...]

コメントを残す


※入力必須

※入力必須
Email to maaguu:info@mx.maaguu.com Powered by WordPress MU Clicky Web Analytics