- Timestamp:
- 11/25/2026 08:29:31 AM (10 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
foldrocket/trunk/src/Domain/Collections/CollectionRepository.php
r3804677 r3822302 120 120 /** @return array<string, mixed>|null */ 121 121 public function find( int $id ): ?array { 122 $item = $this->find_definition( $id ); 123 return $item ? $this->with_count( $item ) : null; 124 } 125 126 /** Return collection filters without running their aggregate count query. */ 127 public function find_definition( int $id ): ?array { 122 128 global $wpdb; 123 129 $row = $wpdb->get_row( … … 130 136 ARRAY_A 131 137 ); 132 return $row ? $this-> with_count( $this->hydrate( $row )) : null;138 return $row ? $this->hydrate( $row ) : null; 133 139 } 134 140 … … 164 170 array( 165 171 'name' => sprintf( 166 /* translators: % d: size threshold in megabytes */167 __( 'Large files (>% dMB)', 'foldrocket' ),168 PluginSettings::large_file_mb()172 /* translators: %s: size threshold in megabytes */ 173 __( 'Large files (>%s MB)', 'foldrocket' ), 174 self::format_large_file_threshold_mb( PluginSettings::large_file_kb() ) 169 175 ), 170 176 'filters' => array( 'min_size' => PluginSettings::large_file_min_bytes() ), … … 225 231 $name = (string) $row['name']; 226 232 227 // Keep large-file smart views aligned with Settings → large_file_ mb.233 // Keep large-file smart views aligned with Settings → large_file_kb. 228 234 if ( $is_smart && isset( $filters['min_size'] ) ) { 229 $ mb = PluginSettings::large_file_mb();235 $kb = PluginSettings::large_file_kb(); 230 236 $filters['min_size'] = PluginSettings::large_file_min_bytes(); 231 237 $name = sprintf( 232 /* translators: % d: size threshold in megabytes */233 __( 'Large files (>% dMB)', 'foldrocket' ),234 $mb238 /* translators: %s: size threshold in megabytes */ 239 __( 'Large files (>%s MB)', 'foldrocket' ), 240 self::format_large_file_threshold_mb( $kb ) 235 241 ); 236 242 } … … 245 251 ); 246 252 } 253 254 private static function format_large_file_threshold_mb( int $kb ): string { 255 $mb = max( 1, $kb ) / 1024; 256 $rounded = round( $mb, 3 ); 257 $decimals = 3; 258 259 if ( floor( $rounded ) === $rounded ) { 260 $decimals = 0; 261 } elseif ( floor( $rounded * 10 ) === $rounded * 10 ) { 262 $decimals = 1; 263 } elseif ( floor( $rounded * 100 ) === $rounded * 100 ) { 264 $decimals = 2; 265 } 266 267 return function_exists( 'number_format_i18n' ) 268 ? number_format_i18n( $rounded, $decimals ) 269 : number_format( $rounded, $decimals, '.', '' ); 270 } 247 271 }
Note:
See TracChangeset
for help on using the changeset viewer.