register_settings( aiou()->settings() ); ( new Feature() )->register(); ( new LogAdminPage() )->register(); } /** * Register the "Email Log" section on the existing Emails tab. * * @param SettingsRegistry $settings The settings registry. * @return void */ private function register_settings( SettingsRegistry $settings ): void { $settings->add_section( 'emails', 'logging', __( 'Email Log', 'all-in-one-utilities' ), __( 'Keep a record of every email this site sends -- any plugin\'s, not just this one\'s -- independent of the content customization above.', 'all-in-one-utilities' ), 40 ); $settings->add_field( 'emails', 'logging', new Field( id: 'enabled', label: __( 'Enable email logging', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Log every email this site sends to a separate database table', 'all-in-one-utilities' ) ), doc: new Doc( title: __( 'Email Log', 'all-in-one-utilities' ), short: __( 'Adds an "Email Log" page under All-In-One Utilities while this is on.', 'all-in-one-utilities' ), detailed: __( 'Captures every email sent through WordPress\'s own wp_mail() function -- contact forms, WooCommerce, this plugin\'s own notifications, and anything else -- after all other plugins (including this one\'s Email Settings) have already applied their content.', 'all-in-one-utilities' ), warnings: array( __( 'Logged content can include sensitive data (password reset links, personal details). Only administrators can view the log, and a retention window below keeps it from growing forever.', 'all-in-one-utilities' ) ) ), priority: 10 ) ); $settings->add_field( 'emails', 'logging', new Field( id: 'log_body', label: __( 'Store full message content', 'all-in-one-utilities' ), type: 'checkbox', default: 0, args: array( 'toggle_label' => __( 'Store the subject and message body, not just the recipient and status', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), doc: new Doc( title: __( 'Store full message content', 'all-in-one-utilities' ), short: __( 'Turn off to log only the recipient, subject, and send status.', 'all-in-one-utilities' ), warnings: array( __( 'Some emails this site sends (e.g. password reset) include a one-time link in the body. Metadata-only logging avoids storing that link at all.', 'all-in-one-utilities' ) ) ), priority: 20 ) ); $settings->add_field( 'emails', 'logging', new Field( id: 'retention', label: __( 'Keep logged emails for', 'all-in-one-utilities' ), type: 'select', default: '30', args: array( 'choices' => array( '0' => __( 'Keep forever', 'all-in-one-utilities' ), '7' => __( '7 days', 'all-in-one-utilities' ), '15' => __( '15 days', 'all-in-one-utilities' ), '30' => __( '30 days', 'all-in-one-utilities' ), '90' => __( '90 days', 'all-in-one-utilities' ), ), 'description' => __( 'Logged emails older than this are deleted automatically, once a day.', 'all-in-one-utilities' ), 'depends_on' => 'enabled', ), priority: 30 ) ); } }