Skip to content

Commit

Permalink
Fix validation on drafts (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcbelletre committed Nov 2, 2023
1 parent 17d6388 commit 884047e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 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.3.1.1
Version: 1.3.2
Author: Marc Bellêtre
Author URI: https://pixelparfait.fr
License: MIT
Expand Down Expand Up @@ -44,7 +44,7 @@ public function __construct()
// Settings
// - these will be passed into the field class.
$this->settings = [
'version' => '1.3.1.1',
'version' => '1.3.2',
'url' => plugin_dir_url(__FILE__),
'path' => plugin_dir_path(__FILE__),
];
Expand Down
25 changes: 25 additions & 0 deletions fields/class-acf-field-rrule.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,21 +810,46 @@ public function update_value($value, $post_id, $field)

switch ($value['frequency']) {
case 'WEEKLY':
// Bail early if weekdays are not set
if (!isset($value['weekdays'])) {
return $value;
}

$rule->setByDay($value['weekdays']);

break;

case 'MONTHLY':
// Bail early if monthly_by is not set
if (!isset($value['monthly_by'])) {
return $value;
}

if ($value['monthly_by'] == 'monthdays') {
// Bail early if monthdays are not set
if (!isset($value['monthdays'])) {
return $value;
}

$rule->setByMonthDay($value['monthdays']);
} else {
// Bail early if bysetpost & byweekday are not set
if (!(isset($value['bysetpos']) && isset($value['byweekday']))) {
return $value;
}

$rule->setBySetPosition($value['bysetpos']);
$rule->setByDay($value['byweekday']);
}

break;

case 'YEARLY':
// Bail early if months are not set
if (!isset($value['months'])) {
return $value;
}

$rule->setByMonth($value['months']);

break;
Expand Down
5 changes: 4 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: 6.3
Requires PHP: 7.2
Stable tag: 1.3.1.1
Stable tag: 1.3.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 1.3.2 =
* Fix validation on drafts

= 1.3.1.1 =
* Upload new tag for wpackagist

Expand Down

0 comments on commit 884047e

Please sign in to comment.