wp_recovery_mode()


WordPressのwp_recovery_mode()関数は、リカバリーモードを管理するために使用されます。このモードは、致命的なエラーが発生した際に管理者に通知し、サイトの復旧を支援します。

構文

wp_recovery_mode();

例1: リカバリーモードの有効化

リカバリーモードを手動で有効にします。

add_action('init', 'enable_recovery_mode'); function enable_recovery_mode() { wp_recovery_mode()->enable(); }

例2: リカバリーモードの無効化

リカバリーモードを手動で無効にします。

add_action('init', 'disable_recovery_mode'); function disable_recovery_mode() { wp_recovery_mode()->disable(); }

例3: リカバリーモードのステータス確認

リカバリーモードが有効かどうかを確認します。

if (wp_recovery_mode()->is_active()) { echo 'リカバリーモードが有効です'; }

例4: リカバリーモードのクッキー設定

リカバリーモード用のクッキーを設定します。

wp_recovery_mode()->set_cookie();

例5: リカバリーモードのクッキー削除

リカバリーモード用のクッキーを削除します。

wp_recovery_mode()->clear_cookie();

例6: リカバリーモードのエラーメッセージ表示

リカバリーモードで表示されるエラーメッセージをカスタマイズします。

add_filter('recovery_mode_email_message', 'custom_recovery_message'); function custom_recovery_message($message) { return 'カスタムエラーメッセージ'; }

例7: リカバリーモードのメール送信

リカバリーモードの通知メールを送信します。

wp_recovery_mode()->send_email();

注意事項

  • リカバリーモードは管理者のみが利用できます。
  • 誤った使用はサイトのアクセスに影響を与える可能性があります。

関連機能: