Plugin Directory


Ignore:
Timestamp:
11/25/2026 08:29:31 AM (10 days ago)
Author:
foldrocket
Message:

Release FoldRocket 1.5.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • foldrocket/trunk/src/Domain/Collections/CollectionRepository.php

    r3804677 r3822302  
    120120        /** @return array<string, mixed>|null */
    121121        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 {
    122128                global $wpdb;
    123129                $row = $wpdb->get_row(
    … …  
    130136                        ARRAY_A
    131137                );
    132                 return $row ? $this->with_count( $this->hydrate( $row ) ) : null;
     138                return $row ? $this->hydrate( $row ) : null;
    133139        }
    134140
    … …  
    164170                        array(
    165171                                '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() )
    169175                                ),
    170176                                'filters' => array( 'min_size' => PluginSettings::large_file_min_bytes() ),
    … …  
    225231                $name     = (string) $row['name'];
    226232
    227                 // Keep large-file smart views aligned with Settings → large_file_mb.
     233                // Keep large-file smart views aligned with Settings → large_file_kb.
    228234                if ( $is_smart && isset( $filters['min_size'] ) ) {
    229                         $mb                    = PluginSettings::large_file_mb();
     235                        $kb                    = PluginSettings::large_file_kb();
    230236                        $filters['min_size']   = PluginSettings::large_file_min_bytes();
    231237                        $name                  = sprintf(
    232                                 /* translators: %d: size threshold in megabytes */
    233                                 __( 'Large files (>%dMB)', 'foldrocket' ),
    234                                 $mb
     238                                /* translators: %s: size threshold in megabytes */
     239                                __( 'Large files (>%s MB)', 'foldrocket' ),
     240                                self::format_large_file_threshold_mb( $kb )
    235241                        );
    236242                }
    … …  
    245251                );
    246252        }
     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        }
    247271}
Note: See TracChangeset for help on using the changeset viewer.