LoginSignup
7
8

More than 5 years have passed since last update.

WordPressのバージョン情報・プラグイン・テーマ名を非表示にさせる

Posted at

WordPressにおけるセキュリテイー対策です。

■ 起因

WordPressでサイトを構築した際のセキュリティー対策として、さまざまなバージョンやプラグイン、テーマ名などを表示させているとセキュリティー的に古いものだったりすると脆弱性があり攻撃される可能性があるので非表示にするのがおすすめです。

■ 解決策

WordPressのテーマディレクトリに下記を記載していくだけです。

{WordPress_Dir}/DocumentRoot/wp-content/themes/{テーマ}/functions.php
// generator
remove_action( 'wp_head', 'wp_generator');

// rel="shortlink"
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );

// WLW(Windows Live Writer) wlwmanifest.xml
remove_action( 'wp_head', 'wlwmanifest_link');

// RSD xmlrpc.php?rsd
remove_action( 'wp_head', 'rsd_link');

//JavaScriptやCSSに付加されるWordPressのバージョン番号(?ver=4.4.2など)を削除します。
function remove_src_wp_ver( $dep ) {
    $dep->default_version = '';
}
add_action( 'wp_default_scripts', 'remove_src_wp_ver' );
add_action( 'wp_default_styles', 'remove_src_wp_ver' );
7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8