diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b0e65f9..8d8719d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: [7.4] + php: [8.2] steps: - name: Checkout code @@ -26,7 +26,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache dependencies - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ffdbfa6..fb30d3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## v3.8.3 +- Fix: Restore default expiration dates feature + +## v3.8.3 + - Chore: Revert to wp-packagist version of 10up/elasticpress due to psr/container conflicts ## v3.8.2 diff --git a/openpub-base.php b/openpub-base.php index 5e983ea..1406dcf 100644 --- a/openpub-base.php +++ b/openpub-base.php @@ -4,7 +4,7 @@ * Plugin Name: Yard | OpenPub Base * Plugin URI: https://www.openwebconcept.nl/ * Description: Acts as foundation for other OpenPub related content plugins. This plugin implements actions to allow for other plugins to add and/or change Custom Posttypes, Metaboxes, Taxonomies, en Posts 2 posts relations. - * Version: 3.8.3 + * Version: 3.8.4 * Author: Yard | Digital Agency * Author URI: https://www.yard.nl/ * License: GPL-3.0 diff --git a/src/Base/Foundation/Plugin.php b/src/Base/Foundation/Plugin.php index c779b44..622cebe 100644 --- a/src/Base/Foundation/Plugin.php +++ b/src/Base/Foundation/Plugin.php @@ -8,7 +8,7 @@ class Plugin { public const NAME = 'openpub-base'; - public const VERSION = '3.8.3'; + public const VERSION = '3.8.4'; protected string $rootPath; public Config $config; diff --git a/src/Base/Metabox/MetaboxServiceProvider.php b/src/Base/Metabox/MetaboxServiceProvider.php index e28af25..5236c14 100644 --- a/src/Base/Metabox/MetaboxServiceProvider.php +++ b/src/Base/Metabox/MetaboxServiceProvider.php @@ -94,8 +94,13 @@ protected function registerMetaboxFields(CMB2 $metabox, array $fields): void protected function addExpirationDefaultValue(array $configMetaboxes): array { - $configMetaboxes['base']['fields']['general']['expiration']['std'] = (new \DateTime('now', new \DateTimeZone('Europe/Amsterdam')))->modify('+' . $this->plugin->settings->expireAfter() . ' days')->format('Y-m-d H:i'); - $configMetaboxes['base']['fields']['general']['expiration']['desc'] = __('Items with an expiration date will be excluded from the search results and on news overview page from this date forward.', 'openpub-base'); + $configMetaboxes['base']['fields']['general']['expiration']['default_cb'] = function( $field_args, $field ) { + $post = get_post( $field->object_id ); + if ( ! $post || $post->post_status !== 'auto-draft' ) { + return ''; + } + return strtotime( 'midnight', strtotime( '+' . $this->plugin->settings->expireAfter() . ' days' ) ); + }; return $configMetaboxes; }