isset( $_POST['firm_name'] ) ? sanitize_text_field( wp_unslash( $_POST['firm_name'] ) ) : '', 'firm_logo_id' => isset( $_POST['firm_logo_id'] ) ? absint( $_POST['firm_logo_id'] ) : 0, ) ); // phpcs:enable DOCSINO_Admin::redirect( DOCSINO_Admin::page_url( 'docs-in-order-setup' ) . '#dio-setup-list', 'setup_branding_saved' ); } /** * Why the next step matters, shown in the "Next" line. * * @param string $key Check key. * @return string */ private function next_reason( $key ) { $reasons = array( 'branding' => __( 'so clients know who is asking for their documents.', 'docs-in-order' ), 'email' => __( 'so you know client emails will arrive.', 'docs-in-order' ), 'links' => __( 'so client links open DocsInOrder, not a "page not found" error.', 'docs-in-order' ), 'storage' => __( 'so client files can be saved.', 'docs-in-order' ), 'private' => __( 'so nobody can open client files from the web.', 'docs-in-order' ), 'https' => __( 'so documents travel over a secure connection.', 'docs-in-order' ), 'permalinks' => __( 'so client links look clean and work reliably.', 'docs-in-order' ), ); return isset( $reasons[ $key ] ) ? $reasons[ $key ] : ''; } /** * Test that a client link reaches DocsInOrder. */ public function handle_check_links() { DOCSINO_Admin::authorize( 'docsino_check_links', 'manage_options' ); DOCSINO_Portal::check_links(); DOCSINO_Admin::redirect( DOCSINO_Admin::page_url( 'docs-in-order-setup', array( 'docsino_done' => 1 ) ) . '#dio-setup-list' ); } /** * Open Setup once after the first activation. */ public function maybe_redirect_after_activation() { if ( ! get_transient( 'docsino_activation_redirect' ) ) { return; } delete_transient( 'docsino_activation_redirect' ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking how the plugin was activated. $bulk = isset( $_GET['activate-multi'] ); if ( $bulk || wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_options' ) ) { return; } wp_safe_redirect( DOCSINO_Admin::page_url( 'docs-in-order-setup' ) ); exit; } /** * Send a test email to the current user. */ public function handle_send_test_email() { DOCSINO_Admin::authorize( 'docsino_send_test_email', 'manage_options' ); $user = wp_get_current_user(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in authorize(). $to = isset( $_POST['send_to'] ) ? sanitize_email( wp_unslash( $_POST['send_to'] ) ) : ''; $sent = DOCSINO_Emails::send_test( is_email( $to ) ? $to : $user->user_email ); if ( is_email( $to ) ) { update_option( 'docsino_email_check_to', $to, false ); } $url = DOCSINO_Admin::page_url( 'docs-in-order-setup' ) . '#dio-check-email'; if ( is_wp_error( $sent ) ) { update_option( 'docsino_email_check', 'failed', false ); DOCSINO_Admin::fail( $sent->get_error_message(), $url ); } update_option( 'docsino_email_check', 'sent', false ); DOCSINO_Admin::redirect( $url, 'test_email_sent' ); } /** * Record whether the test email arrived. */ public function handle_confirm_email() { DOCSINO_Admin::authorize( 'docsino_confirm_email', 'manage_options' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in authorize(). $arrived = isset( $_POST['arrived'] ) && 'yes' === $_POST['arrived']; update_option( 'docsino_email_check', $arrived ? 'confirmed' : 'failed', false ); DOCSINO_Admin::redirect( $arrived ? DOCSINO_Admin::page_url( 'docs-in-order-setup', array( 'docsino_done' => 1 ) ) . '#dio-setup-list' : DOCSINO_Admin::page_url( 'docs-in-order-setup' ) . '#dio-check-email' ); } /** * Run the storage web-access check. */ public function handle_check_storage() { DOCSINO_Admin::authorize( 'docsino_check_storage', 'manage_options' ); DOCSINO_Storage::check_web_access(); DOCSINO_Admin::redirect( DOCSINO_Admin::page_url( 'docs-in-order-setup', array( 'docsino_done' => 1 ) ) . '#dio-setup-list' ); } /** * The checklist. */ public function render_page() { /** * Checks shown on the Setup screen (key => check). * * @param array $checks Checks. */ $checks = (array) apply_filters( 'docsino_setup_checks', DOCSINO_Health::checks() ); $done = DOCSINO_Health::passed( $checks ); $total = count( $checks ); $email = get_option( 'docsino_email_check' ); $next = ''; foreach ( $checks as $key => $check ) { if ( 'good' !== $check['status'] ) { $next = $key; // The first unfinished step is opened and highlighted. break; } } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only reading which notice to show. $just_did = ( isset( $_GET['docsino_notice'] ) && false !== strpos( sanitize_text_field( wp_unslash( $_GET['docsino_notice'] ) ), 'setup_branding_saved' ) ) || ! empty( $_GET['docsino_done'] ); ?>

→
    $check ) : ?> 0 ) : ?>
  1. next_reason( $key ) ); ?>
  2. ·

    render_action( isset( $check['action'] ) ? $check['action'] : '', $check['status'], $email, $is_next ); ?>
is_anonymous() ) : ?>

render_branding_form( 'good' !== $status || $open ); break; case 'email_test': if ( 'sent' === $email ) { $user = wp_get_current_user(); echo '

'; /* translators: %s: email address. */ echo esc_html( sprintf( __( 'We sent a test email to %s. Did it arrive? Check your spam folder too.', 'docs-in-order' ), $this->test_email_to() ) ); echo '

'; DOCSINO_Admin::form_open( 'docsino_confirm_email', 'docsino_confirm_email', array(), 'dio-button-row' ); echo ''; echo ''; echo ''; } DOCSINO_Admin::form_open( 'docsino_send_test_email', 'docsino_send_test_email', array(), 'dio-setup-form dio-setup-form--inline' ); echo ' '; echo ' '; echo ''; echo ''; break; case 'storage_check': DOCSINO_Admin::form_open( 'docsino_check_storage', 'docsino_check_storage', array(), 'dio-inline-form' ); echo ''; echo ''; break; case 'link_check': DOCSINO_Admin::form_open( 'docsino_check_links', 'docsino_check_links', array(), 'dio-inline-form' ); echo ''; echo ''; break; case 'permalinks': printf( '%2$s %3$s %4$s', esc_url( admin_url( 'options-permalink.php' ) ), esc_html__( 'Open permalink settings', 'docs-in-order' ), esc_html__( '(opens in a new tab)', 'docs-in-order' ), esc_html__( 'Choose "Post name", save, then come back to this tab. It updates by itself.', 'docs-in-order' ) ); break; } } /** * Where the test email goes: the address used last time, or the current user's. * * @return string */ private function test_email_to() { $to = (string) get_option( 'docsino_email_check_to' ); return is_email( $to ) ? $to : (string) wp_get_current_user()->user_email; } /** * Firm name and logo, edited right on the Setup screen. * * @param bool $open Show the form open (otherwise behind an "Edit" toggle). */ private function render_branding_form( $open ) { $s = DOCSINO_Settings::all(); $logo_id = (int) $s['firm_logo_id']; $logo = $logo_id ? wp_get_attachment_image_url( $logo_id, 'medium' ) : ''; $name = '' !== trim( (string) $s['firm_name'] ) ? $s['firm_name'] : wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); ?>
>

>

' . esc_html__( 'Settings', 'docs-in-order' ) . '' ); ?>