Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ 石川さん確認待ち / 2人目確認待ち ][ No index ] 検索エンジンがサイトをインデックスしないようにする にチェックが入ってたらアラートを出す機能を追加 #1173

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion inc/noindex/noindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,32 @@ function veu_display_nest_checkbox( $array, $raw_array, $options ) {
}
echo '</ul>';
}
}
}

/**
* 検索にインデックスしない設定の場合にダッシュボードにアラートを表示
* If the site is set to not be indexed by search engines, display an alert on the dashboard.
*/
function veu_noindex_admin_notice() {
if ( get_option( 'blog_public' ) == '0' && get_current_screen()->base === 'dashboard' ) {
$reading_settings_url = admin_url( 'options-reading.php' );
echo '<div class="notice notice-warning is-dismissible">';
echo '<p>';
echo __( 'This site is set to not be indexed by search engines.', 'vk-all-in-one-expansion-unit' ) . '<br>';
printf(
__( 'To disable this setting, go to <a href="%s">Settings > Reading</a> and uncheck "Discourage search engines from indexing this site".', 'vk-all-in-one-expansion-unit' ),
esc_url( $reading_settings_url )
);
echo '</p>';
echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'vk-all-in-one-expansion-unit' ) . '</span></button>';
echo '</div>';
echo '<script type="text/javascript">
(function($){
$(document).on("click", ".notice-dismiss", function(){
$(this).closest(".notice").fadeOut();
});
})(jQuery);
Comment on lines +320 to +326
Copy link
Collaborator

@goutetsuguma goutetsuguma Feb 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

すみません、、AIでコードレビューをしたところ、以下の回答がありました。
回答通りに該当の箇所を削除したところ、閉じるボタンは動くようで問題なさそうでした。
しかしながら、プロジェクト統一の書き方もあると思いますので、さらっと見ていただき検討していただけますと良いかなとおもいました。

WordPressのダッシュボードでは、.notice-dismissボタンの機能は既にWordPressコアによって自動的に処理されています。そのため、以下のjQueryコードは不要です。

echo '<script type="text/javascript">
     (function($){
        $(document).on("click", ".notice-dismiss", function(){
            $(this).closest(".notice").fadeOut();
         });
     })(jQuery);
 </script>';

WordPress の標準の is-dismissible クラスを使う場合は、手動で を追加する必要はなく、WordPress が自動的に閉じるボタンを追加して処理します。以下のコードは不要です。

echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'vk-all-in-one-expansion-unit' ) . '</span></button>';

</script>';
}
}
add_action( 'admin_notices', 'veu_noindex_admin_notice' );
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ e.g.
== Changelog ==

[ Add function ][ SNS : Share button ] Added a main setting page for Share button style in ExUnit.
[ Add function ][ No index ] Add a feature to display an alert on the dashboard if "Discourage search engines from indexing this site" is enabled in Settings > Reading.

= 9.103.1 =
[ Bug fix ][ CTA ] Fixed some CSS being escaped.
Expand Down
Loading