← All changes
|
php/Admin/Menus/Manage/Manage_Menu_Assets.php
+17
-0
3.10.0
→
4.0.0-beta.2
View file →
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | use Code_Snippets\Integration\Evaluate_Functions; |
| 6 | 6 | use Code_Snippets\Model\Snippet; |
| 7 | 7 | use function Code_Snippets\code_snippets; |
| 8 | +use function Code_Snippets\get_snippet_author; | |
| 8 | 9 | use function Code_Snippets\get_snippets; |
| 9 | 10 | use function Code_Snippets\Settings\get_setting; |
| 10 | 11 | use function Code_Snippets\Utils\enqueue_code_preview_editor; |
| 11 | 12 | use const Code_Snippets\PLUGIN_FILE; |
| @@ -99,11 +100,13 @@ | ||
| 99 | 100 | 'snippetsPerPage' => $snippets_per_page, |
| 100 | 101 | 'cloudSearchPerPage' => Manage_Menu::get_cloud_search_per_page(), |
| 101 | 102 | 'isSafeModeActive' => Evaluate_Functions::is_safe_mode_active(), |
| 102 | 103 | 'bulkDownloadNonce' => wp_create_nonce( 'code_snippets_bulk_download' ), |
| 104 | + 'runOnceNonce' => wp_create_nonce( Manage_Menu::RUN_ONCE_NONCE ), | |
| 103 | 105 | 'supportsZipDownloads' => class_exists( 'ZipArchive' ), |
| 104 | 106 | 'editorTheme' => get_setting( 'editor', 'theme' ), |
| 105 | 107 | 'typeCounts' => $this->get_snippet_type_counts(), |
| 108 | + 'listOrder' => get_setting( 'general', 'list_order' ), | |
| 106 | 109 | ]; |
| 107 | 110 | |
| 108 | 111 | if ( $this->screen_options->is_manage_table_view() ) { |
| 109 | 112 | // Full code bodies make this payload grow with the size of the snippet library. |
| @@ -110,8 +113,14 @@ | ||
| 110 | 113 | $snippets = array_map( |
| 111 | 114 | function ( Snippet $snippet ) { |
| 112 | 115 | $fields = $snippet->get_fields(); |
| 113 | 116 | $fields['code'] = ''; |
| 117 | + $fields['created_by'] = get_snippet_author( (int) ( $snippet->created_by ?? 0 ) ); | |
| 118 | + $fields['updated_by'] = get_snippet_author( (int) ( $snippet->updated_by ?? 0 ) ); | |
| 119 | + | |
| 120 | + // Match the REST response: a UTC value with no offset is read | |
| 121 | + // as local time by the browser. | |
| 122 | + $fields['modified'] = $snippet->modified_iso; | |
| 114 | 123 | return $fields; |
| 115 | 124 | }, |
| 116 | 125 | get_snippets() |
| 117 | 126 | ); |
| @@ -121,8 +130,16 @@ | ||
| 121 | 130 | |
| 122 | 131 | if ( $inline_limit > 0 ) { |
| 123 | 132 | $localized['snippetsList'] = array_slice( $snippets, 0, $inline_limit ); |
| 124 | 133 | } |
| 134 | + } | |
| 135 | + | |
| 136 | + if ( $this->screen_options->is_ai_agent_view() ) { | |
| 137 | + // The AI Agent demo writes the site name into the snippet it builds, | |
| 138 | + // so the walkthrough reads as though it were written for this site. | |
| 139 | + $localized['aiDemo'] = [ | |
| 140 | + 'siteName' => get_bloginfo( 'name' ), | |
| 141 | + ]; | |
| 125 | 142 | } |
| 126 | 143 | |
| 127 | 144 | wp_localize_script( self::JS_HANDLE, 'CODE_SNIPPETS_MANAGE', $localized ); |
| 128 | 145 | } |