Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Fix #15
- Fix #16
  • Loading branch information
marcbelletre committed Nov 11, 2021
1 parent 24b8b8a commit 07c9a51
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
4 changes: 2 additions & 2 deletions acf-rrule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin Name: ACF RRule Field
Plugin URI: https://github.com/marcbelletre/acf-rrule
Description: Create recurring rules with a single ACF field
Version: 1.2.2
Version: 1.2.3
Author: Marc Bellêtre
Author URI: https://pixelparfait.fr
License: MIT
Expand Down Expand Up @@ -44,7 +44,7 @@ function __construct() {
// Settings
// - these will be passed into the field class.
$this->settings = array(
'version' => '1.2.2',
'version' => '1.2.3',
'url' => plugin_dir_url( __FILE__ ),
'path' => plugin_dir_path( __FILE__ )
);
Expand Down
13 changes: 7 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions fields/class-acf-field-rrule.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ function render_field( $field ) {
$selected = false;

if (is_array($field['value']) && is_array($field['value']['bysetpos'])) {
$selected = in_array($key, $field['value']['bysetpos'], true);
$selected = in_array((string) $key, $field['value']['bysetpos'], true);
}
?>

Expand Down Expand Up @@ -674,16 +674,6 @@ function load_value( $value, $post_id, $field ) {
}
}

if ($rule->getUntil()) {
$new_value['end_type'] = 'date';
$new_value['end_date'] = $rule->getUntil()->format('Ymd');
} else if ($rule->getCount()) {
$new_value['end_type'] = 'count';
$new_value['occurrence_count'] = $rule->getCount();
} else {
$new_value['end_type'] = 'none';
}

$locale = explode('_', get_locale());

$transformer = new \Recurr\Transformer\ArrayTransformer();
Expand All @@ -697,6 +687,21 @@ function load_value( $value, $post_id, $field ) {
$new_value['dates_collection'][] = $recurrence->getStart();
}

if ($rule->getUntil()) {
$end_date = $rule->getUntil();

$new_value['end_type'] = 'date';
} elseif ($rule->getCount()) {
$end_date = end($new_value['dates_collection']);

$new_value['end_type'] = 'count';
$new_value['occurrence_count'] = $rule->getCount();
} else {
$new_value['end_type'] = 'none';
}

$new_value['end_date'] = $end_date ? $end_date->format('Ymd') : null;

$new_value['text'] = $textTransformer->transform($rule);
} catch (\Exception $e) {
//
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: acf, rrule, recurrence, date, calendar
Requires at least: 4.7
Tested up to: 5.8
Requires PHP: 5.6
Stable tag: 1.2.2
Stable tag: 1.2.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -31,6 +31,10 @@ This plugin requires ACF or ACF Pro to work.

== Changelog ==

= 1.2.3 =
* Fix checkboxes selection not showing up
* Fix end date not being set when using the count option

= 1.2.2 =
* Improve field validation
* Fix spelling
Expand Down

0 comments on commit 07c9a51

Please sign in to comment.