| @@ -67,16 +67,20 @@ | ||
| 67 | 67 | |
| 68 | 68 | usort( |
| 69 | 69 | $results, |
| 70 | 70 | function( $a, $b ) { |
| 71 | - $pos_a = isset( $a['position'] ) ? (int) $a['position'] : 10; | |
| 72 | - $pos_b = isset( $b['position'] ) ? (int) $b['position'] : 10; | |
| 71 | + $date_a = strtotime( (string) ( $a['modified_date'] ?? '' ) ); | |
| 72 | + $date_b = strtotime( (string) ( $b['modified_date'] ?? '' ) ); | |
| 73 | + $date_a = false === $date_a ? 0 : (int) $date_a; | |
| 74 | + $date_b = false === $date_b ? 0 : (int) $date_b; | |
| 75 | + $day_a = $date_a > 0 ? date( 'Y-m-d', $date_a ) : ''; | |
| 76 | + $day_b = $date_b > 0 ? date( 'Y-m-d', $date_b ) : ''; | |
| 73 | 77 | |
| 74 | - if ( $pos_a === $pos_b ) { | |
| 75 | - return strcmp( (string) ( $a['name'] ?? '' ), (string) ( $b['name'] ?? '' ) ); | |
| 78 | + if ( $day_a === $day_b ) { | |
| 79 | + return strnatcasecmp( (string) ( $a['name'] ?? '' ), (string) ( $b['name'] ?? '' ) ); | |
| 76 | 80 | } |
| 77 | 81 | |
| 78 | - return $pos_a - $pos_b; | |
| 82 | + return strcmp( $day_b, $day_a ); | |
| 79 | 83 | } |
| 80 | 84 | ); |
| 81 | 85 | |
| 82 | 86 | return $results; |
| @@ -83,9 +87,9 @@ | ||
| 83 | 87 | } |
| 84 | 88 | |
| 85 | 89 | /** |
| 86 | 90 | * Built-in + user-saved templates for the library modal. |
| 87 | - * Order: saved (newest first via DB query), then builtin (by position). | |
| 91 | + * Order: saved (newest first via DB query), then builtin (newest update first, then name). | |
| 88 | 92 | * |
| 89 | 93 | * @param string $email_type Email type slug. |
| 90 | 94 | * |
| 91 | 95 | * @return array[] |