ヘッダからバージョン情報を消す

アクセスログを見ていると、最近どうもアタックの数が多い。と言っても、SOMY SpamBlock Japanese のおかげでことごとくブロック出来ているのでデータベースが汚染されることはないのだけれど。でもやっぱり精神衛生上、よろしくない。 :mad:

WP 2.5 になってヘッダに自動的にバージョン情報が追加されるようになってみたいで、それがもしやボットたちのトリガーになってない?と思ったり。というのも、昔バージョン情報を記載しているとそのバージョンの脆弱性をめがけてスパムアタックがあるのでバージョン情報はヘッダから消してしまおう!というのがあった、、、はず。たぶん。なので、バージョン情報を消したらアタックが減らないかなーと思い、調べるとさすが!フォーラムでも消したい人がいたようです (http://wordpress.org/support/topic/164884)。

<meta name="generator" content="WordPress 2.5" /> を消す

やりかたは簡単。使っているテーマの functions.php に

remove_action('wp_head', 'wp_generator');

を追加するだけでオッケー。 :smile:

ついでに wlwmanifest も消しちゃえ

バージョン情報と一緒に wlwmanifest.xml というのもヘッダに自動的についています。Windows Live Writer と連携するためのものらしいのですが、自分は使わないので一緒に消しちゃいました。

さっきと同じように functions.php に

remove_action('wp_head', 'wlwmanifest_link');

remove_action('wp_head', 'rsd_link');

と追加しました。(via http://wordpress.org/support/topic/140794)

2008年 4月 13日 | WordPress | , , | 5

Hack widgets.php

初期状態のwidgets.phpでは自分で設定したタイトルがウィジェットの各タブ?には表示されないので、ポップアップをクリックしないと確認できず、不便です。この問題をMP:Blog - Mediaprojekte - » WordPress Widgets Hack: Show Title on Widgetで解決してくれています。が、このままだと設定したタイトルとタブのタイトルが同じ場合でも表示されてしまい、見辛く(煩く)なってしまうので、変更しました。

widgets.php 624行目付近(日本語版とオリジナルで行が違うようです):

echo "\n\t\t\t<li class='module' id='widgetprefix-$san_name'><span class='handle'>" . __($name) . "$popper</span></li>";

を削除し、

// start widget title enhancements by georg leciejewski
    if ( !empty( $registered_widgets[$name]['params'] ) ) {
        $number = $registered_widgets[$name]['params'][0];
        $options = get_option( $registered_widgets[$name]['classname'] );
        $widgettitle = $options[$number]['title'];
    } else {
        $options = get_option( $registered_widgets[$name]['classname'] );
        $widgettitle = $options['title'];
    }
//show only if title is populated
    if ( !empty( $widgettitle ) ) {
        if ( $widgettitle != __($name) ) $show_title = ' : ' . $widgettitle;
    }
// end widget title enhancements by georg leciejewski
    echo "\n\t\t\t<li class='module' id='widgetprefix-$san_name'><span class='handle'>" . __($name) . $show_title . $popper . "</span></li>";

を加えてください。

但し、設定したタイトルが表示されるまでワンテンポ(更新1回分)遅れるようです・・・:cry:

2006年 6月 1日 | WordPress | | 0

GetRecentlyCommentedをWidget化

Executable PHP widgetを使うとウィジェット編集画面から同様のことが出来ます。

Hirobee's Trail [Memorandum]さんで配布されているGet Recently CommentedをWidgetに加える方法です。

プラグイン自体を変更することがないので個人的には好きなやり方ではあるのですが、functionが肥大化するのは目に見えており、それが心配です・・・。

【方法】
以下の文を使用しているテーマのfunction.phpに加えてください。(Widget、Get Recently Commented双方がすでに導入されていることが前提です。)

<?php if ( function_exists('get_recently_commented') ) {
function widget_get_recently_commented($args) {
    extract($args);
    $options = get_option('widget_get_recently_commented');
    $num_items = (int) $options['items'];
    if ( empty($num_items) || $num_items &lt;1 ) $num_items = 10;
    $title = empty($options['title']) ? __('Recent Comments', 'widgets') : $options['title'];
?>
    <?php echo $before_widget; ?>
        <?php echo $before_title . $title . $after_title; ?>
        <ul>
        <?php get_recently_commented($limit = $num_items); ?>
        </ul>
    <?php echo $after_widget; ?>
<?php
}
function widget_get_recently_commented_control() {
    $options = $newoptions = get_option('widget_get_recently_commented');
    if ( $_POST['get_recently_commented_submit'] ) {
        $newoptions['title'] = strip_tags(stripslashes($_POST["get_recently_commented_title"]));
        $newoptions['items'] = (int) $_POST["get_recently_commented_items"];
    }
    if ( $options != $newoptions ) {
        $options = $newoptions;
        update_option('widget_get_recently_commented', $options);
    }
    $title = htmlspecialchars($options['title'], ENT_QUOTES);
    $items = (int) $options['items'];
?>
            <p>
                <label for="get_recently_commented_title"><?php _e('Title:', 'widgets'); ?>&nbsp;
                <input style="width: 250px;" id="get_recently_commented_title" name="get_recently_commented_title" type="text" value="
<?php echo $title; ?/>
" />
                </label>
            </p>
            <p>
                <label for="
get_recently_commented_items"><?php _e('How many items would you like to display:', 'widgets'); ?>&nbsp;
                <input style="
width: 30px;" id="get_recently_commented_items" name="get_recently_commented_items" type="text" value="<?php echo $items; ?/>" />
            </label></p>
            <input type="
hidden" id="get_recently_commented_submit" name="get_recently_commented_submit" value="1" />
<?php
}
register_sidebar_widget('Get Recently Commented', 'widget_get_recently_commented');
register_widget_control('Get Recently Commented', 'widget_get_recently_commented_control', 300, 90);
}
?>

【追記】
"e"が抜けていたので修正しましたm(_ _"m)ペコリ

2006年 5月 23日 | WordPress | , | 0

Sidebar Widgets vs Tiger Style Admin

前回の投稿からひと月かぁ・・。ちゃんと書かないとなぁと思い直す今日この頃です :sad:

先日から、テストページにてウィジェットを試して遊んでみているのですが、TigerAdminではポップアップ画面が正常に手前に表示されないという問題がありました。解決方法がないかと公式のサポートサイトやテクノラティで検索したりしては見ましたが、「無効化せよ」という呆気ない一言しか見つけられなかったので自分で探ってみることにしました。:P

何時間やっていたんでしょう・・。3時間くらいはコードと対峙していたのですが、やっと原因をつかめました:!: position: relativeにはバグを有するとどこかのサイトにあり、positionとz-index(cssとjavascriptの双方で)を中心にあれこれいじくっていた所、widget.php側ではなく、tiger.css側に問題がありました。

wp-admin-tiger\wp-admin-tiger_files\tiger.css 57行目:

position: relative;

これが悪事を働いていたようです。削除してみたところ、見た目が崩れることは無く、ウィジェットの動作も完璧になりまし :idea:  ウィジェットをTigerAdminと併用したい方は是非消してあげてください(笑)。ところで、日本のWPユーザでウィジェットを使っている人は少数なのでしょうか・・?

[How to fix]
line57 in "wp-admin-tiger\wp-admin-tiger_files\tiger.css"
Delete this:

position: relative;

That's ALL!!

2006年 5月 13日 | WordPress | , | 0

HackPart.2

フェイスマークのタグにはwidthとheightが無く、いつもタグチェックをするとエラーになってしまうので、それを修正。
wp-includes/vars.phpの106行目付近のimgタグにwidth='15' height='15'を追加。

さらに、quicktags.jsの編集。lightbox用にコピーライトをクリックで挿入できるようにし、<>⁄∗を実体参照にするように追加。

codeタグにはoverflow: auto;を追加。

2/16にWP2.0.1がリリースされるようなので、
その時にWP2へ移行する予定にしよう :grin:

2006年 1月 25日 | WordPress | | 0
Back to Top ▲