0 ) { Lltxt_Versions::pin( $id, false ); } Lltxt_Cache::set_mode( $route, Lltxt_Cache::MODE_PLUGIN ); $notice = 'vc_unpinned'; } elseif ( 'pin' === $action ) { $id = isset( $_POST['lltxt_version_id'] ) ? (int) $_POST['lltxt_version_id'] : 0; if ( $id > 0 && Lltxt_Versions::pin( $id, true ) ) { Lltxt_Cache::set_mode( $route, Lltxt_Cache::MODE_PINNED ); $notice = 'vc_pinned'; } else { $notice = 'vc_pin_err'; } } $url = add_query_arg( 'route', rawurlencode( $route ), Lltxt_Admin_Page::redirect_url( 'version-control', $notice ) ); wp_safe_redirect( $url ); exit; } /** * Restore + pin a version from the local store. * * @param string $route Route. * @param int $id Row id. * @return bool */ private static function do_restore( $route, $id ) { if ( $id <= 0 ) { return false; } $body = Lltxt_Versions::read_body( $id ); if ( null === $body ) { return false; } $res = Lltxt_Cache::write( $route, $body, true ); if ( is_wp_error( $res ) ) { return false; } Lltxt_Versions::pin( $id, true ); Lltxt_Cache::set_mode( $route, Lltxt_Cache::MODE_PINNED ); // Record the restored body itself as a version so the audit trail is complete. Lltxt_Versions::insert( $route, $body, 'restored' ); return true; } /** * Render the tab. * * @return void */ public static function render() { self::notice(); $route = isset( $_GET['route'] ) ? sanitize_text_field( wp_unslash( $_GET['route'] ) ) : 'llms.txt'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $routes = array_values( Lltxt_Router::routes() ); if ( ! in_array( $route, $routes, true ) ) { $route = 'llms.txt'; } ?>

' . esc_html__( 'No versions yet. They\'ll appear here after the first refresh.', 'agentic-commerce-llms-txt' ) . '

'; return; } $local_mode = Lltxt_Cache::get_mode( $route ); ?>

$reason ) { if ( 'pinned' === $reason ) { $pinned[] = '/' . $path; } else { $merchant[] = '/' . $path; } } $lines = array( __( 'Refresh ran, but these files were left alone:', 'agentic-commerce-llms-txt' ) ); if ( $pinned ) { $lines[] = sprintf( /* translators: %s: comma-separated file paths. */ __( 'Pinned (unpin a row below to resume refresh): %s', 'agentic-commerce-llms-txt' ), implode( ', ', $pinned ) ); } if ( $merchant ) { $lines[] = sprintf( /* translators: %s: comma-separated file paths. */ __( 'Merchant-managed (use "Take over this file" on the Files tab): %s', 'agentic-commerce-llms-txt' ), implode( ', ', $merchant ) ); } return implode( ' ', $lines ); } /** * Render the action notice. * * @return void */ private static function notice() { $code = isset( $_GET['lltxt_notice'] ) ? sanitize_key( wp_unslash( $_GET['lltxt_notice'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! $code ) { return; } $map = array( 'vc_sync_ok' => array( 'success', __( 'Refresh complete. New versions added to your local history.', 'agentic-commerce-llms-txt' ) ), 'vc_sync_skipped' => array( 'warning', self::vc_skip_notice_text() ), 'vc_sync_partial' => array( 'warning', __( 'Refresh ran with some emitter errors — see Diagnostics.', 'agentic-commerce-llms-txt' ) ), 'vc_restored' => array( 'success', __( 'Restored. Refresh paused for this route — unpin in Version Control to resume.', 'agentic-commerce-llms-txt' ) ), 'vc_restore_err' => array( 'error', __( 'Could not restore that version.', 'agentic-commerce-llms-txt' ) ), 'vc_unpinned' => array( 'success', __( 'Resumed daily refresh for this route.', 'agentic-commerce-llms-txt' ) ), 'vc_pinned' => array( 'success', __( 'Pinned. Daily refresh is paused for this route.', 'agentic-commerce-llms-txt' ) ), 'vc_pin_err' => array( 'error', __( 'Could not pin.', 'agentic-commerce-llms-txt' ) ), ); if ( ! isset( $map[ $code ] ) ) { return; } printf( '

%s

', esc_attr( $map[ $code ][0] ), esc_html( $map[ $code ][1] ) ); } }