From b4f43215ba77b4caa7ab8c7a03189fbe82dc140f Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 6 Jun 2021 18:24:46 +0900 Subject: [PATCH] =?UTF-8?q?WP=20PLUGIN=20MTEE(Meta=20Tag=20etc=20Extend)?= =?UTF-8?q?=20RSS=E3=81=A8=E7=B5=B5=E6=96=87=E5=AD=97=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ・RSSと絵文字タグの無効化設定を追加 --- class/mtee.php | 2 +- class/mtee_version_setting.php | 70 ++++++++++++++++++++++------------ meta-tag-etc-extend.php | 17 +++++++-- template/index.php | 21 +++++++++- 4 files changed, 79 insertions(+), 31 deletions(-) diff --git a/class/mtee.php b/class/mtee.php index 1caba8a..30a2aeb 100644 --- a/class/mtee.php +++ b/class/mtee.php @@ -74,7 +74,7 @@ if (!class_exists('MTEE')) { public function is_disable($type): bool { if (isset($this->get_options()[$type]) - && $this->get_options()['asset_ver_disabled'] == 1) { + && $this->get_options()[$type] == 1) { return true; } diff --git a/class/mtee_version_setting.php b/class/mtee_version_setting.php index 6a1c46d..6cdcaf7 100644 --- a/class/mtee_version_setting.php +++ b/class/mtee_version_setting.php @@ -1,36 +1,56 @@ options = $options; - $this->change_wp_version_view(); - $this->change_asset_version_view(); - } + public function __construct($options) { + $this->options = $options; + $this->disabled_wp_version_view(); + $this->disabled_asset_version_view(); + $this->disabled_emoji(); + $this->disabled_rss_feed(); + } - public function change_wp_version_view() { - if ( $this->options['wp_ver_disabled'] == 1 ) { - remove_action( 'wp_head', 'wp_generator' ); - } - } + public function disabled_wp_version_view() { + if ($this->options['wp_ver_disabled'] == 1) { + remove_action('wp_head', 'wp_generator'); + } + } - public function change_asset_version_view() { - if ( $this->options['asset_ver_disabled'] == 1 ) { - add_action( 'wp_default_scripts', array( $this, 'remove_src_wp_ver' ) ); - add_action( 'wp_default_styles', array( $this, 'remove_src_wp_ver' ) ); - } - } + public function disabled_asset_version_view() { + if ($this->options['asset_ver_disabled'] == 1) { + add_action('wp_default_scripts', array($this, 'remove_src_wp_ver')); + add_action('wp_default_styles', array($this, 'remove_src_wp_ver')); + } + } - function remove_src_wp_ver( $dep ) { - $dep->default_version = ''; - } + public function remove_src_wp_ver($dep) { + $dep->default_version = ''; + } + public function disabled_emoji() { + if ($this->options['emoji_disabled'] == 1) { + remove_action('wp_head', 'print_emoji_detection_script', 7); + remove_action('wp_print_styles', 'print_emoji_styles'); + } + } - } + public function disabled_rss_feed() { + if ($this->options['rss_disabled'] == 1) { + //RSS Feedを停止 + remove_action('do_feed_rdf', 'do_feed_rdf'); + remove_action('do_feed_rss', 'do_feed_rss'); + remove_action('do_feed_rss2', 'do_feed_rss2'); + remove_action('do_feed_atom', 'do_feed_atom'); + //RSSリンクを無効化 + remove_action('wp_head', 'feed_links', 2); + remove_action('wp_head', 'feed_links_extra', 3); + } + } + } } \ No newline at end of file diff --git a/meta-tag-etc-extend.php b/meta-tag-etc-extend.php index be87aa6..5b15c67 100644 --- a/meta-tag-etc-extend.php +++ b/meta-tag-etc-extend.php @@ -62,10 +62,19 @@ if ($mtee->is_enable('noindex_nofollow')) { new mtee_meta_output_noindexnofollow(); } -//disabled WP version, WP JS/CSS version -if ($mtee->is_disable('asset_ver_disabled') || $mtee->is_disable('asset_ver_disabled')) { - require_once MTEE_CLASS_DIR . 'mtee_version_setting.php'; - new mtee_version_setting($options); +//disabled WP version, WP JS/CSS version, Emoji, RSS Feed +$disabled_checks = array( + 'asset_ver_disabled', + 'asset_ver_disabled', + 'emoji_disabled', + 'rss_disabled' +); +foreach ($disabled_checks as $disabled_check) { + if ($mtee->is_disable($disabled_check)) { + require_once MTEE_CLASS_DIR . 'mtee_version_setting.php'; + new mtee_version_setting($options); + break; + } } diff --git a/template/index.php b/template/index.php index ae60a71..b8753a6 100644 --- a/template/index.php +++ b/template/index.php @@ -7,6 +7,8 @@ $ogp_setting = $this->get_key_setting('ogp_setting'); $canonical_setting = $this->get_key_setting('canonical_setting'); $wp_ver_disabled = $this->get_key_setting('wp_ver_disabled'); $asset_ver_disabled = $this->get_key_setting('asset_ver_disabled'); +$emoji_disabled = $this->get_key_setting('emoji_disabled'); +$rss_disabled = $this->get_key_setting('rss_disabled'); ?>

meta keyword, description / バージョン情報 設定

@@ -143,7 +145,15 @@ $asset_ver_disabled = $this->get_key_setting('asset_ver_disabled'); value="1">有効
- +
+

RSS

+ +

OGPタグ出力

+
+

絵文字

+ +