$source, 'language' => $language ) ); } function render_visitor_checks( int $source_id, string $language ): void { $source = get_post( $source_id ); $target_id = $source && polylang_ready() ? translation_target_id( $source_id, $language ) : 0; $target = $target_id ? get_post( $target_id ) : null; echo '

' . esc_html__( 'Back to content', 'uruvo' ) . '

'; if ( ! $source || ! current_user_can( 'edit_post', $source_id ) || ! $target || ! current_user_can( 'edit_post', $target_id ) ) { echo '

' . esc_html__( 'Choose a linked translation first', 'uruvo' ) . '

'; return; } $names = translation_language_names(); /* translators: %s: name of the translation language. */ echo '

' . esc_html( sprintf( __( 'Visitor view: %s', 'uruvo' ), $names[ $language ] ?? $language ) ) . '

'; echo '

' . esc_html( get_the_title( $source ) ) . '

'; $public = 'publish' === $target->post_status && '' === $target->post_password; $url = $public ? get_permalink( $target ) : get_preview_post_link( $target ); $edit = builder_editor_link( $target ) ?: get_edit_post_link( $target, 'raw' ); echo '
'; printf( '%s', esc_url( $url ), esc_html( $public ? __( 'Open visitor view', 'uruvo' ) : __( 'Preview draft', 'uruvo' ) ) ); printf( '%s', esc_url( $edit ), esc_html__( 'Open page editor', 'uruvo' ) ); echo '
'; if ( $public && 'publish' === $source->post_status && '' === $source->post_password ) { $menu = current_user_can( 'edit_theme_options' ) ? admin_url( wp_is_block_theme() ? 'site-editor.php?p=/navigation' : 'nav-menus.php' ) : ''; $templates = get_post_type_object( 'elementor_library' ); $header = $templates && current_user_can( $templates->cap->edit_posts ) ? admin_url( 'edit.php?post_type=elementor_library' ) : ( current_user_can( 'edit_theme_options' ) && wp_is_block_theme() ? admin_url( 'site-editor.php?p=/pattern' ) : '' ); printf( '
', esc_url( get_permalink( $source ) ), esc_url( $url ), esc_attr( locale_for( $language ) ), esc_url( $edit ), esc_url( $menu ), esc_url( $header ) ); echo '

' . esc_html__( 'Check the page as a signed-out visitor', 'uruvo' ) . '

' . esc_html__( 'Look for labels that still match the original in menus, headers, footers, buttons, and forms. Some wording, such as a brand name, can stay the same.', 'uruvo' ) . '

'; echo '

'; } else { echo '

' . esc_html__( 'Open the draft to check the layout. Signed-out checks become available after publishing, including on a public staging site.', 'uruvo' ) . '

'; } if ( current_user_can( 'manage_options' ) ) { render_migration_preview( $public ? $url : '', $names[ $language ] ?? $language, get_the_title( $source ) ); } echo ''; } function render_migration_preview( string $staging_url, string $language, string $title ): void { printf( '
', esc_attr( $language ), esc_attr( $title ) ); echo '' . esc_html__( 'Prepare a migration preview for a customer', 'uruvo' ) . ''; echo '

' . esc_html__( 'Use one important page to show what will carry over. Add a note about anything your customer should check with you before switching.', 'uruvo' ) . '

'; echo '
'; $fields = array( 'original' => array( __( 'Current public URL', 'uruvo' ), '' ), 'staging' => array( __( 'Shareable staging preview URL', 'uruvo' ), $staging_url ), 'final' => array( __( 'Planned public URL after the switch', 'uruvo' ), '' ), ); foreach ( $fields as $key => list( $label, $value ) ) { printf( '', esc_html( $label ), esc_attr( $key ), esc_attr( $value ) ); } echo ''; echo ''; echo '
'; echo '
'; }