isset( $_POST['default_author_id'] ) ? absint( wp_unslash( $_POST['default_author_id'] ) ) : 0, 'weekly_limit' => isset( $_POST['weekly_limit'] ) ? max( 1, min( Settings::MAX_WEEKLY_LIMIT, absint( wp_unslash( $_POST['weekly_limit'] ) ) ) ) : Settings::DEFAULT_WEEKLY_LIMIT, 'ai_notice_mode' => in_array( $mode, array( Settings::AI_NOTICE_AUTO, Settings::AI_NOTICE_ALWAYS, Settings::AI_NOTICE_NEVER ), true ) ? $mode : Settings::AI_NOTICE_AUTO, 'ai_notice_text' => isset( $_POST['ai_notice_text'] ) ? mb_substr( sanitize_text_field( wp_unslash( $_POST['ai_notice_text'] ) ), 0, 300 ) : '', 'purge_on_uninstall' => ! empty( $_POST['purge_on_uninstall'] ), ); $key_changed = false; if ( ! Settings::api_key_is_constant() ) { if ( ! empty( $_POST['delete_api_key'] ) ) { $values['api_key'] = ''; } else { $submitted = isset( $_POST['api_key'] ) ? trim( sanitize_text_field( wp_unslash( $_POST['api_key'] ) ) ) : ''; if ( '' !== $submitted ) { $values['api_key'] = $submitted; $key_changed = true; } } } Settings::update( $values ); // Wer einen Key eintraegt, will wissen, ob er funktioniert. if ( $key_changed ) { ConnectionCheck::run(); self::redirect( 'saved_checked' ); } self::redirect( 'saved' ); } /** * Gibt die Seite aus. * * @return void */ public static function render(): void { if ( ! current_user_can( Plugin::CAPABILITY ) ) { wp_die( esc_html__( 'You are not allowed to do this.', 'aivor-content-import' ) ); } self::render_notice(); ?>

all(); if ( $has_key && $has_jobs ) { return; } $jobs_url = add_query_arg( array( 'page' => JobsPage::SLUG, 'action' => 'new', ), admin_url( 'admin.php' ) ); $steps = array( array( 'done' => $has_key, 'html' => sprintf( /* translators: 1: link to the Aivor registration, 2: link to the API key page in Aivor */ __( 'Connect Aivor. %1$s (it is free and comes with starter credits), then create an API key under %2$s and paste it below.', 'aivor-content-import' ), // Die Parameter ordnen ein neues Konto auf aivor.ai dem Plugin zu; das Plugin // selbst sendet dafuer nichts. '' . esc_html__( 'Create an Aivor account', 'aivor-content-import' ) . '', '' . esc_html__( 'Profile → API keys', 'aivor-content-import' ) . '' ), ), array( 'done' => false, 'html' => sprintf( /* translators: %s: link to the cluster planning in Aivor */ __( 'Plan your topics in Aivor. %s: add this website, let Aivor analyse it and confirm a topic cluster with a publishing rhythm.', 'aivor-content-import' ), '' . esc_html__( 'Open Content in Aivor', 'aivor-content-import' ) . '' ), ), array( 'done' => $has_jobs, 'html' => sprintf( /* translators: %s: link to the form for a new content job */ __( 'Connect the cluster. Copy its import job ID and %s. Articles then arrive as drafts for you to review.', 'aivor-content-import' ), '' . esc_html__( 'add a content job', 'aivor-content-import' ) . '' ), ), ); $allowed = array( 'a' => array( 'href' => array(), 'target' => array(), 'rel' => array(), ), 'strong' => array(), ); ?>

'notice-success', ConnectionCheck::STATE_WARNING => 'notice-warning', ConnectionCheck::STATE_ERROR => 'notice-error', ); $state = (string) ( $last['state'] ?? ConnectionCheck::STATE_ERROR ); ?>


' . esc_html( Settings::masked_api_key() ) . '' ); ?>

all() ); ?>

label() ); ?>

__( 'article text for link planning', 'aivor-content-import' ), Capabilities::PATCH => __( 'internal link updates', 'aivor-content-import' ), Capabilities::HUB => __( 'cluster overview in the pillar article', 'aivor-content-import' ), Capabilities::REPLACE => __( 'extended versions of existing articles, saved as a revision for your review', 'aivor-content-import' ), ); return array_values( array_intersect_key( $labels, array_flip( Capabilities::all() ) ) ); } /** * Uebersetzte Bezeichnung eines Laufergebnisses. * * @param string $status Einer der Settings::STATUS_-Werte. * @return string */ private static function status_label( string $status ): string { switch ( $status ) { case Settings::STATUS_OK: return __( 'finished without errors', 'aivor-content-import' ); case Settings::STATUS_SKIPPED: return __( 'nothing to do', 'aivor-content-import' ); case Settings::STATUS_ERROR: return __( 'finished with errors, see the import log', 'aivor-content-import' ); default: return __( 'unknown', 'aivor-content-import' ); } } /** * Zeigt die Rueckmeldung nach dem Absenden. * * @return void */ private static function render_notice(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nur Anzeige einer Rueckmeldung. $notice = isset( $_GET['aivor_notice'] ) ? sanitize_key( wp_unslash( $_GET['aivor_notice'] ) ) : ''; $messages = array( 'saved' => __( 'Settings saved.', 'aivor-content-import' ), 'saved_checked' => __( 'Settings saved and connection checked.', 'aivor-content-import' ), 'checked' => __( 'Connection checked.', 'aivor-content-import' ), 'ran' => __( 'Run finished. The result is in the import log.', 'aivor-content-import' ), 'busy' => __( 'A run is already in progress. Try again in a few minutes.', 'aivor-content-import' ), ); if ( isset( $messages[ $notice ] ) ) { printf( '

%s

', esc_html( $messages[ $notice ] ) ); } } /** * Leitet nach der Verarbeitung zurueck auf die Seite. * * @param string $notice Schluessel der Rueckmeldung. * @return void */ private static function redirect( string $notice ): void { wp_safe_redirect( add_query_arg( array( 'page' => Plugin::MENU_SLUG, 'aivor_notice' => $notice, ), admin_url( 'admin.php' ) ) ); exit; } }