self::SLUG ), admin_url( 'admin.php' ) ); array_unshift( $links, '' . esc_html__( 'Settings', '360-orbit-security-digest' ) . '' ); return $links; } public static function register_menu() { self::$hook = add_submenu_page( Wp360_Security_Digest_Orbit_Menu::SLUG, 'Security Digest', 'Security Digest', 'manage_options', self::SLUG, array( __CLASS__, 'render_page' ) ); add_action( 'load-' . self::$hook, array( __CLASS__, 'add_help_tabs' ) ); } /** * Einheitliches Hilfe-Panel (README "Suite-übergreifend"): WordPress' * eigene "Hilfe"-Lasche oben rechts mit den drei wichtigsten Fragen, * statt sie ungenutzt zu lassen. Reine Texte, keine Logik. */ public static function add_help_tabs() { $screen = get_current_screen(); if ( ! $screen ) { return; } $screen->add_help_tab( array( 'id' => 'wp360-sd-help-basics', 'title' => __( 'What does Security Digest do?', '360-orbit-security-digest' ), 'content' => '
' . __( 'It collects what WordPress already knows about pending core, plugin and theme updates and sends it as one calm digest email — daily, weekly or monthly, as configured — instead of the scattered notices in wp-admin. It has no update-checking mechanism of its own; it only reads WordPress\'s own transients.', '360-orbit-security-digest' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 'wp360-sd-help-nothing', 'title' => __( 'Why did I get no email this week?', '360-orbit-security-digest' ), 'content' => '' . __( 'If nothing is due at the scheduled time, no email is sent — only a "Nothing due" entry is added to the history below. Use "Send digest now" on the Status tab to test at any time; that always sends, even if nothing is due.', '360-orbit-security-digest' ) . '
', ) ); $screen->add_help_tab( array( 'id' => 'wp360-sd-help-delivery', 'title' => __( 'The digest never arrives — what now?', '360-orbit-security-digest' ), 'content' => '' . __( 'WordPress only confirms that the email was handed off, not that it actually arrived. Check the Status tab: a reported delivery error shows up there and after every manual test. Most often the cause is a missing SMTP plugin with proper SPF/DKIM for your domain.', '360-orbit-security-digest' ) . '
', ) ); } /** * Deaktivierungs-Rückfrage (README "Suite-übergreifend"): kein Formular, * nur ein kurzer Hinweis vor dem eigentlichen Deaktivieren in der * Plugin-Liste, was dabei aufhoert und was erhalten bleibt. */ public static function enqueue_deactivation_notice_script( $hook ) { if ( 'plugins.php' !== $hook || ! defined( 'WP360_SD_FILE' ) ) { return; } $basename = plugin_basename( WP360_SD_FILE ); $message = __( 'Deactivate Security Digest? The scheduled digest email (and the immediate security alert, Pro) will stop. Your settings, mute list and history stay saved and come back if you reactivate the plugin.', '360-orbit-security-digest' ); // Kein eigenes Script-Tag im Markup (WordPress.org-Richtlinie): ein Handle // ohne Datei, an das der Code per wp_add_inline_script() haengt. wp_register_script( 'wp360-sd-deactivate', false, array(), WP360_SD_VERSION, true ); wp_enqueue_script( 'wp360-sd-deactivate' ); wp_add_inline_script( 'wp360-sd-deactivate', sprintf( '( function () { var row = document.querySelector( %s ); var link = row ? row.querySelector( \'a[href*="action=deactivate"]\' ) : null; if ( ! link ) { return; } link.addEventListener( \'click\', function ( event ) { if ( ! window.confirm( %s ) ) { event.preventDefault(); } } ); } )();', wp_json_encode( 'tr[data-plugin="' . $basename . '"]' ), wp_json_encode( $message ) ) ); } /** * Gesundheitscheck (README "Suite-übergreifend"): traegt zur * gemeinsamen "360 WP Orbit"-Uebersicht bei -- rein lesend, nichts * wird hier ausgeloest. Bewusst am gemeinsamen, nicht praefigierten * Filter 'wp360_orbit_health' registriert (siehe class-orbit-menu.php). */ public static function health_lines( array $lines, $slug ) { if ( '360-orbit-security-digest' !== $slug ) { return $lines; } $history = Wp360_Security_Digest_Digest::history(); $lines[] = $history ? sprintf( /* translators: %s: date of the last sent digest */ __( 'Last digest: %s', '360-orbit-security-digest' ), wp_date( 'd.m.Y', strtotime( $history[0]['sent_at'] ) ) ) : __( 'No digest sent yet.', '360-orbit-security-digest' ); $integrity = Wp360_Security_Digest_Integrity::summary(); if ( $integrity['enabled'] && $integrity['checked_at'] ) { $lines[] = sprintf( /* translators: %s: date and time of the last file check */ __( 'Last file check: %s', '360-orbit-security-digest' ), wp_date( 'd.m.Y', $integrity['checked_at'] ) ); } $vuln = Wp360_Security_Digest_Vulnerabilities::summary(); if ( $vuln['enabled'] && $vuln['checked_at'] ) { $lines[] = sprintf( /* translators: %d: number of known vulnerabilities */ _n( '%d known vulnerability', '%d known vulnerabilities', $vuln['total'], '360-orbit-security-digest' ), $vuln['total'] ); } return $lines; } private static function current_tab() { // 'security'/'transfer'/'license' gibt es nur im PRO-Build; FREE zeigt // stattdessen einen einzigen Hinweis-Tab 'pro'. $valid = array( 'status', 'files', 'vulnerabilities', 'settings', 'pro' ); if ( isset( $_GET['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $tab = sanitize_key( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( in_array( $tab, $valid, true ) ) { return $tab; } } return 'status'; } public static function enqueue_assets( $hook ) { if ( self::$hook !== $hook ) { return; } wp_enqueue_style( 'wp360-sd-admin', WP360_SD_URL . 'assets/admin.css', array(), WP360_SD_VERSION ); wp_enqueue_script( 'wp360-sd-admin', WP360_SD_URL . 'assets/admin.js', array( 'jquery' ), WP360_SD_VERSION, true ); wp_localize_script( 'wp360-sd-admin', 'wp360UpdateDigest', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'wp360_sd_nonce' ), 'strings' => array( 'saved' => __( 'Saved.', '360-orbit-security-digest' ), 'saveError' => __( 'Error while saving.', '360-orbit-security-digest' ), 'sending' => __( 'Sending …', '360-orbit-security-digest' ), 'sendError' => __( 'Error while sending.', '360-orbit-security-digest' ), 'mailError' => __( 'Mail delivery reported an error:', '360-orbit-security-digest' ), 'loading' => __( 'Loading …', '360-orbit-security-digest' ), 'previewError' => __( 'Error while loading the preview.', '360-orbit-security-digest' ), 'days' => __( 'days', '360-orbit-security-digest' ), 'muteFor' => __( 'Mute for', '360-orbit-security-digest' ), /* translators: 1: number of the package being checked, 2: total number of packages, 3: name of the package being checked */ 'checking' => __( 'Checking %1$s of %2$s: %3$s', '360-orbit-security-digest' ), 'checkPaused' => __( 'Paused.', '360-orbit-security-digest' ), 'checkError' => __( 'The check could not be continued.', '360-orbit-security-digest' ), 'vulnChecking' => __( 'Asking WPVulnerability …', '360-orbit-security-digest' ), 'vulnDone' => __( 'Done.', '360-orbit-security-digest' ), 'vulnNothing' => __( 'Nothing to ask: every package was checked within the last 24 hours. Each package is asked at most once a day.', '360-orbit-security-digest' ), 'vulnError' => __( 'The check could not be completed.', '360-orbit-security-digest' ), 'quickstarting' => __( 'Applying …', '360-orbit-security-digest' ), 'quickstartError' => __( 'Error while applying the recommended settings.', '360-orbit-security-digest' ), ), ) ); } private static function render_tabs( $current_tab ) { $tabs = array( 'status' => __( 'Status', '360-orbit-security-digest' ), ); $tabs['files'] = __( 'Files', '360-orbit-security-digest' ); $tabs['vulnerabilities'] = __( 'Vulnerabilities', '360-orbit-security-digest' ); // FREE: ein einziger Pro-Tab statt gesperrter Attrappen-Tabs // (WordPress.org-Richtlinie 11: Upgrade-Hinweise sparsam und nur auf // der eigenen Einstellungsseite). $show_pro_tab = true; $tabs['settings'] = __( 'Settings', '360-orbit-security-digest' ); if ( $show_pro_tab ) { $tabs['pro'] = __( 'Security Digest Pro', '360-orbit-security-digest' ); } ?>
'; $html .= esc_html( sprintf( /* translators: %s: date and time of the last file check */ __( 'Last check: %s', '360-orbit-security-digest' ), wp_date( 'd.m.Y H:i', (int) $result['checked_at'] ) ) ); $html .= ' · '; $html .= $changed ? esc_html( sprintf( /* translators: %d: number of packages with findings */ _n( '%d package with findings', '%d packages with findings', $changed, '360-orbit-security-digest' ), $changed ) ) : esc_html__( 'No findings in the packages that could be checked.', '360-orbit-security-digest' ); if ( $unverif ) { $html .= ' · ' . esc_html( sprintf( /* translators: %d: number of packages that could not be checked */ _n( '%d package could not be checked', '%d packages could not be checked', $unverif, '360-orbit-security-digest' ), $unverif ) ); } $html .= '
'; $html .= '| ' . esc_html__( 'Package', '360-orbit-security-digest' ) . ' | '; $html .= '' . esc_html__( 'Version', '360-orbit-security-digest' ) . ' | '; $html .= '' . esc_html__( 'Result', '360-orbit-security-digest' ) . ' | '; $html .= '
|---|---|---|
| ' . esc_html( $package['name'] ) . ''; if ( 'theme' === $package['type'] ) { $html .= ' ' . esc_html__( 'Theme', '360-orbit-security-digest' ) . ''; } $html .= ' | '; $html .= '' . esc_html( $package['version'] ) . ' | '; $html .= '';
if ( 'ok' === $package['state'] ) {
$html .= '' . esc_html__( 'Unchanged', '360-orbit-security-digest' ) . ' ';
$html .= '' . esc_html(
sprintf(
/* translators: %d: number of files */
_n( '%d file', '%d files', (int) $package['files'], '360-orbit-security-digest' ),
(int) $package['files']
)
) . '';
} elseif ( 'unverifiable' === $package['state'] ) {
$html .= '' . esc_html__( 'Could not be checked', '360-orbit-security-digest' ) . ' ';
$html .= '' . esc_html( $reasons[ $package['reason'] ] ?? '' ) . '';
} else {
$html .= '' . esc_html__( 'Findings', '360-orbit-security-digest' ) . '';
foreach ( $kinds as $kind => $label ) {
$count = (int) ( $package['counts'][ $kind ] ?? 0 );
if ( ! $count ) {
continue;
}
$html .= '' . esc_html( $label ) . ' (' . esc_html( (string) $count ) . ')
|
' . esc_html__( 'A changed file is not proof of an attack: hosts, translations and manual fixes change files too. If you cannot explain a finding, reinstall the package from the Updates screen and check again.', '360-orbit-security-digest' ) . ' ' . esc_html( $limits ) . '
'; return $html; } /** * Reiter „Schwachstellen“: Schalter, Abruf und der Bericht. */ private static function render_vulnerabilities_tab( array $settings ) { $enabled = ! empty( $settings['vuln_enabled'] ); ?>
'; if ( $report['checked_at'] ) { $html .= esc_html( sprintf( /* translators: %s: date and time the vulnerability data was last fetched */ __( 'Data last fetched: %s', '360-orbit-security-digest' ), wp_date( 'd.m.Y H:i', (int) $report['checked_at'] ) ) ); $html .= ' · '; $html .= $affected ? esc_html( sprintf( /* translators: %d: number of affected packages */ _n( '%d package affected', '%d packages affected', $affected, '360-orbit-security-digest' ), $affected ) ) : esc_html__( 'No known vulnerabilities in the packages that could be checked.', '360-orbit-security-digest' ); } else { $html .= esc_html__( 'No data has been fetched yet.', '360-orbit-security-digest' ); } if ( $unchecked ) { $html .= ' · ' . esc_html( sprintf( /* translators: %d: number of packages that were not checked */ _n( '%d package not checked', '%d packages not checked', $unchecked, '360-orbit-security-digest' ), $unchecked ) ); } $html .= '
'; $html .= '| ' . esc_html__( 'Package', '360-orbit-security-digest' ) . ' | '; $html .= '' . esc_html__( 'Version', '360-orbit-security-digest' ) . ' | '; $html .= '' . esc_html__( 'Result', '360-orbit-security-digest' ) . ' | '; $html .= '
|---|---|---|
| ' . esc_html( $package['name'] ) . ''; if ( isset( $types[ $package['type'] ] ) ) { $html .= ' ' . esc_html( $types[ $package['type'] ] ) . ''; } $html .= ' | ' . esc_html( $package['version'] ) . ' | ';
if ( 'clean' === $package['state'] ) {
$html .= '' . esc_html__( 'No known vulnerabilities', '360-orbit-security-digest' ) . '';
if ( ! empty( $package['muted'] ) ) {
$html .= ' ' . esc_html(
sprintf(
/* translators: %d: number of muted entries */
_n( '%d entry muted', '%d entries muted', count( $package['muted'] ), '360-orbit-security-digest' ),
count( $package['muted'] )
)
) . '';
}
} elseif ( 'unchecked' === $package['state'] ) {
$html .= '' . esc_html__( 'Not checked', '360-orbit-security-digest' ) . ' ';
$html .= '' . esc_html( $reasons[ $package['reason'] ] ?? '' ) . '';
} else {
$html .= '' . esc_html__( 'Affected', '360-orbit-security-digest' ) . '';
$html .= '
|
' . esc_html__( 'An entry means that this version is listed as affected, not that your website was attacked. An empty list is no proof of safety: the list is only as complete as its source, and paid or custom plugins and themes are usually not covered.', '360-orbit-security-digest' ) . '
'; $html .= '' . esc_html__( 'Vulnerability data from WPVulnerability', '360-orbit-security-digest' ) . '
'; return $html; } private static function render_settings_tab( array $settings ) { $days = array( 1 => __( 'Monday', '360-orbit-security-digest' ), 2 => __( 'Tuesday', '360-orbit-security-digest' ), 3 => __( 'Wednesday', '360-orbit-security-digest' ), 4 => __( 'Thursday', '360-orbit-security-digest' ), 5 => __( 'Friday', '360-orbit-security-digest' ), 6 => __( 'Saturday', '360-orbit-security-digest' ), 7 => __( 'Sunday', '360-orbit-security-digest' ), ); ?>