Conversation
…reen options handling
…reen options tests
| const getVisibleSelected = <T, K extends Key>(visibleItems: T[], getKey: (item: T) => K, selected: Set<K>): Set<K> => | ||
| new Set(visibleItems.map(getKey).filter(key => selected.has(key))) | ||
|
|
||
| const buildTableNavProps = <K extends Key>({ |
There was a problem hiding this comment.
What's the purpose of this function? It seems to just be passing values through directly.
There was a problem hiding this comment.
Removed the redundant pass-through helper and inlined the props construction.
Commit: 72b6b0db1
| <TableNav which="bottom" {...tableNavProps} /> | ||
| </> | ||
| ) | ||
| return <ListTableMarkup |
There was a problem hiding this comment.
What's the benefit in taking this out separately?
There was a problem hiding this comment.
removed the unnecessary extraction
Commit: 72b6b0db1
| ? 'asc' === sortDirection ? 'desc' : 'asc' | ||
| : column.defaultSortDirection ?? 'asc' | ||
| const classDirection = isCurrent ? sortDirection : 'asc' === nextSortDirection ? 'desc' : 'asc' | ||
| const ariaSort = isCurrent ? 'asc' === sortDirection ? 'ascending' : 'descending' : undefined |
|
|
||
| const TableCell = <T, >({ item, column }: TableCellProps<T>) => { | ||
| const className = `${column.id}-column column-${column.id}` | ||
| const className = [ `${column.id}-column`, `column-${column.id}`, column.isHidden ? 'hidden' : '' ] |
There was a problem hiding this comment.
Please use the classnames.classnames module for this sort of thing.
| id={`bulk-action-selector-${which}`} | ||
| value={selectedActionName} | ||
| onChange={event => { | ||
| setSelectedActionName(event.target.value) |
There was a problem hiding this comment.
It's a bit of a shame to lose the typing here – what's the benefit in this change vs what we are losing?
| return 'snippets_per_page' === $option ? $value : $status; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
This should be handled through the REST API, IMO.
| * @return void | ||
| */ | ||
| public function sync_active_shared_network_snippets_add( $option, $value ): void { | ||
| if ( 'active_shared_network_snippets' !== $option ) { |
There was a problem hiding this comment.
Rewrote the option handler with a clearer early-return guard style.
Commit: 0c70958f4
src/php/Flat_Files/Snippet_Files.php
Outdated
| */ | ||
| public static function get_hashed_table_name( string $table ): string { | ||
| return wp_hash( $table ); | ||
| return function_exists( 'wp_hash' ) ? wp_hash( $table ) : md5( $table ); |
There was a problem hiding this comment.
wp_hash has been around since 2.0.3 – do we really need to assume it may not exist? Or is it a contextual fill-in?
There was a problem hiding this comment.
it’s because of load order and namespacing, not as much about WP version support.
Plugin like LiteSpeed can trigger this path before pluggable functions are loaded, and in a namespace we must call \wp_hash. The guard/fallback is to avoid a fatal during early bootstrap; once WP is fully loaded we’ll use \wp_hash as normal.
Commit: b9ca72a66
| */ | ||
| protected static function resolve_field_name( string $field ): string { | ||
| return self::$field_aliases[ $field ] ?? $field; | ||
| return static::$field_aliases[ $field ] ?? $field; |
src/php/snippet-ops.php
Outdated
| @@ -755,6 +763,8 @@ function execute_snippet( string $code, int $id = 0, bool $force = false ) { | |||
| $result = eval( $code ); | |||
| } catch ( ParseError $parse_error ) { | |||
There was a problem hiding this comment.
We might as well remove the ParseError catch if we're going to be catching Throwable anyway.
There was a problem hiding this comment.
Removed redundant ParseError catches and the unused import.
Commit: c11d81954
|
@sheabunge REST downloads are possible (set Content-Disposition: attachment and return raw bytes), but in WP they tend to be more fragile in practice: REST is JSON-first, fetch won’t trigger a native browser download without extra client-side Blob/link work, and large ZIP streaming can run into buffering/memory edge cases. For Screen Options specifically, if we want the controls to live in WP’s native Screen Options flyout (columns/per-page), we’re constrained to core’s PHP hooks (add_screen_option, screen_settings, set-screen-option) and then have React consume/apply the persisted values; moving the UI itself “into React” would mean building and maintaining a separate custom settings UI rather than using native Screen Options. |
Summary
This branch fixes the beta issues reported for Code Snippets and includes a set of follow-up admin usability improvements that were discovered while validating those fixes.
Included Fixes
Snippet editor and snippet data
Save and Activatefor brand new snippets so activation works reliably on the first save.cs-backback link from the editor.Admin navigation fixes
idquery parameter.Edit Snippetsidebar item so it no longer navigates away from the current page:Export and download fixes
ExportandDownloadas separate actions:Exportproduces importable JSONDownloadproduces raw snippet filesDownloadaction for snippet code:ZipArchiveis availableApplyis disabled by default and whileBulk actionsis selectedApplyenables when a real action is selectedFlat Files compatibility
Manage Screen Improvements
Screen Options
Table Optionssection for snippets table behavior with a toggle for truncating long row values.snippetsview showsTable Options,Columns, andPaginationcloud-communityshows onlyPaginationTable behavior and markup
Community Cloud pagination
per_pagethrough the local REST layer and outbound cloud API request.per_pageat100even if the user’s screen option is higher (avoids api error messages)