PluginProbe
Code Snippets / trunk
Code Snippets vtrunk
4.0.0-beta.2 3.10.2 3.10.1 3.10.0 3.10.0-beta.2 3.10.0-beta.1 4.0.0-beta.1 3.9.6 trunk 2.10.0 2.10.1 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 2.14.0 2.14.1 2.14.2 2.14.3 2.14.4 2.14.5 2.14.6 3.0.0 All 65 releases
← All changes | php/Admin/Menus/Manage/Manage_Menu_Assets.php +35 -9 3.10.0-beta.1 → trunk View file →
@@ -2,9 +2,11 @@
2 2
3 3 namespace Code_Snippets\Admin\Menus\Manage;
4 4
5 5 use Code_Snippets\Integration\Evaluate_Functions;
6 +use Code_Snippets\Model\Snippet;
6 7 use function Code_Snippets\code_snippets;
8 +use function Code_Snippets\get_snippet_author;
7 9 use function Code_Snippets\get_snippets;
8 10 use function Code_Snippets\Settings\get_setting;
9 11 use function Code_Snippets\Utils\enqueue_code_preview_editor;
10 12 use const Code_Snippets\PLUGIN_FILE;
@@ -88,32 +90,56 @@
88 90 enqueue_code_preview_editor( 'php' );
89 91 wp_set_script_translations( self::JS_HANDLE, 'code-snippets' );
90 92 code_snippets()->localize_script( self::JS_HANDLE );
91 93
94 + $snippets_per_page = Manage_Menu::get_snippets_per_page();
95 +
92 96 $localized = [
93 97 'hasNetworkCap' => current_user_can( code_snippets()->get_network_cap_name() ),
94 98 'hiddenColumns' => $this->screen_options->get_hidden_columns(),
95 99 'truncateRowValues' => (int) $this->screen_options->should_truncate_rows(),
96 - 'snippetsPerPage' => Manage_Menu::get_snippets_per_page(),
100 + 'snippetsPerPage' => $snippets_per_page,
97 101 'cloudSearchPerPage' => Manage_Menu::get_cloud_search_per_page(),
98 102 'isSafeModeActive' => Evaluate_Functions::is_safe_mode_active(),
99 103 'bulkDownloadNonce' => wp_create_nonce( 'code_snippets_bulk_download' ),
104 + 'runOnceNonce' => wp_create_nonce( Manage_Menu::RUN_ONCE_NONCE ),
100 105 'supportsZipDownloads' => class_exists( 'ZipArchive' ),
101 106 'editorTheme' => get_setting( 'editor', 'theme' ),
102 107 'typeCounts' => $this->get_snippet_type_counts(),
108 + 'listOrder' => get_setting( 'general', 'list_order' ),
103 109 ];
104 110
105 111 if ( $this->screen_options->is_manage_table_view() ) {
106 - $snippets = get_snippets();
107 - $inline_limit = max( 0, intval( apply_filters( 'code_snippets/manage/inline_snippets_limit', 100 ) ) );
112 + // Full code bodies make this payload grow with the size of the snippet library.
113 + $snippets = array_map(
114 + function ( Snippet $snippet ) {
115 + $fields = $snippet->get_fields();
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 ) );
108 119
109 - // Full code bodies make this payload grow with the size of the snippet library.
110 - if ( 0 < $inline_limit && count( $snippets ) <= $inline_limit ) {
111 - $localized['snippetsList'] = array_map(
112 - fn( $snippet ) => $snippet->get_fields(),
113 - $snippets
114 - );
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;
123 + return $fields;
124 + },
125 + get_snippets()
126 + );
127 +
128 + $inline_limit = apply_filters( 'code_snippets/manage/inline_snippets_limit', min( $snippets_per_page, 100 ) );
129 + $inline_limit = max( 0, intval( $inline_limit ) );
130 +
131 + if ( $inline_limit > 0 ) {
132 + $localized['snippetsList'] = array_slice( $snippets, 0, $inline_limit );
115 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 + ];
116 142 }
117 143
118 144 wp_localize_script( self::JS_HANDLE, 'CODE_SNIPPETS_MANAGE', $localized );
119 145 }