DateSaveFormat.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Acf\Service; |
| 6 | |
| 7 | use AC\Acf; |
| 8 | use AC\Registerable; |
| 9 | |
| 10 | class DateSaveFormat implements Registerable |
| 11 | { |
| 12 | public const DATE_FORMAT = 'Ymd'; |
| 13 | |
| 14 | public function register(): void |
| 15 | { |
| 16 | if (! Acf::is_active()) { |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | add_filter('ac/column/date_save_format/options', [$this, 'date_save_format_options']); |
| 21 | } |
| 22 | |
| 23 | public function date_save_format_options(array $options): array |
| 24 | { |
| 25 | $options[self::DATE_FORMAT] = sprintf( |
| 26 | 'ACF %s (%s)', |
| 27 | __('Date Format', 'codepress-admin-columns'), |
| 28 | 'Ymd' |
| 29 | ); |
| 30 | |
| 31 | return $options; |
| 32 | } |
| 33 | |
| 34 | } |
| 35 |