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(); ?>
' . esc_html( Settings::masked_api_key() ) . '' ); ?>
| 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