id : ''; if ( ! current_user_can( Plugin::CAPABILITY ) || ! self::is_relevant_screen( $screen_id ) ) { return; } if ( '' === Settings::api_key() ) { // Ohne Key ist alles andere Folgefehler. Keine Stoerung, sondern // eine Einladung, deshalb nicht auf dem Dashboard. if ( 'dashboard' === $screen_id ) { return; } self::show( 'info', __( 'Aivor Content Import is installed. Connect your Aivor account to receive articles.', 'aivor-content-import' ), __( 'Set up now', 'aivor-content-import' ), Plugin::MENU_SLUG ); return; } self::stalled_cron(); self::job_errors(); self::insecure_home_url(); self::unverified_url(); } /** * Ob die aktuelle Seite Hinweise bekommt. * * @param string $screen_id ID des aktuellen Bildschirms, leer ohne Bildschirm. * @return bool */ private static function is_relevant_screen( string $screen_id ): bool { if ( '' === $screen_id ) { return false; } if ( in_array( $screen_id, array( 'dashboard', 'plugins' ), true ) ) { return true; } return str_contains( $screen_id, Plugin::MENU_SLUG ); } /** * Ein toter WP-Cron ist der haeufigste Supportfall ueberhaupt. * * @return void */ private static function stalled_cron(): void { if ( array() === ( new JobRepository() )->all() ) { return; } $reference = max( Settings::last_run(), Settings::activated_at() ); if ( 0 !== $reference && ( time() - $reference ) <= self::RUN_OVERDUE ) { return; } self::show( 'warning', 0 === Settings::last_run() ? __( 'Aivor Content Import has not fetched any articles yet. WordPress runs scheduled tasks when someone visits the website; on websites without visitors they stand still.', 'aivor-content-import' ) : __( 'Aivor Content Import has not run for more than 24 hours. WordPress runs scheduled tasks when someone visits the website; on websites without visitors they stand still.', 'aivor-content-import' ), __( 'View status', 'aivor-content-import' ), Plugin::MENU_SLUG ); } /** * Ein Job im Fehlerzustand holt nichts mehr ab. * * @return void */ private static function job_errors(): void { if ( ! ( new JobRepository() )->has_errors() ) { return; } self::show( 'error', __( 'Aivor Content Import: at least one content job reports an error.', 'aivor-content-import' ), __( 'View content jobs', 'aivor-content-import' ), JobsPage::SLUG ); } /** * Ohne HTTPS lehnt Aivor jede Rueckmeldung ab. * * @return void */ private static function insecure_home_url(): void { if ( PostTypeTarget::site_is_https() ) { return; } self::show( 'error', __( 'Aivor Content Import: this website does not use https. Articles are imported, but Aivor only accepts https addresses, so it cannot link your cluster articles with each other.', 'aivor-content-import' ), '', '' ); } /** * Aivor konnte eine gemeldete URL nicht der Site zuordnen. * * @return void */ private static function unverified_url(): void { if ( ! DraftMapping::has_unverified_url() ) { return; } self::show( 'warning', __( 'Aivor Content Import: Aivor could not match a reported address to the website stored in Aivor. Check the website address of the cluster in Aivor; until then the articles are not linked with each other.', 'aivor-content-import' ), __( 'View import log', 'aivor-content-import' ), LogPage::SLUG ); } /** * Gibt einen Hinweis aus. * * @param string $type info, warning oder error. * @param string $message Der Hinweistext. * @param string $link_label Beschriftung des Links, leer fuer keinen Link. * @param string $page Ziel-Slug im Backend. * @return void */ private static function show( string $type, string $message, string $link_label, string $page ): void { $link = ''; if ( '' !== $link_label && '' !== $page ) { $link = sprintf( ' %s', esc_url( add_query_arg( array( 'page' => $page ), admin_url( 'admin.php' ) ) ), esc_html( $link_label ) ); } printf( '
%s%s