Skip to content

Commit

Permalink
gw-conditional-logic-entry-meta.php: Use provided filter choices in…
Browse files Browse the repository at this point in the history
… registered meta if present.
  • Loading branch information
claygriffiths committed Dec 13, 2024
1 parent 214bb71 commit 6acf0e1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions gravity-forms/gw-conditional-logic-entry-meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*
* Supports all registered meta and as well as the "Payment Status" standard meta.
* Handles enabling conditional logic evaluation on send for GP Notification Scheduler when notification
* contains a conditioanl rule for "payment_status".
* contains a conditional rule for "payment_status".
*
* Requires Gravity Forms 2.6.2.
*
* Plugin Name: GF Conditional Logic: Entry Meta
* Plugin URI: https://gravitywiz.com/
* Description: Use the entry meta in conditional logic (e.g. payment status, approval status, etc).
* Author: Gravity Wiz
* Version: 0.3
* Version: 0.3.1
* Author URI: https://gravitywiz.com
*/
class GW_CL_Entry_Meta {
Expand Down Expand Up @@ -150,7 +150,21 @@ public function get_conditional_logic_options() {
'isnot' => 'isNot',
),
);
$_choices = rgar( $choices_by_key, $key );

$_choices = rgar( $choices_by_key, $key );

/*
* Use choices by key if exists, otherwise, attempt to pull from $meta/filter/choices, which contains
* array{ text: string, value: string }[]
*/
if ( empty( $_choices ) ) {
$filter_choices = rgars( $meta, 'filter/choices' );

if ( ! empty( $filter_choices ) ) {
$_choices = wp_list_pluck( $filter_choices, 'text', 'value' );
}
}

if ( ! empty( $_choices ) ) {
$choices = array();
foreach ( $_choices as $value => $text ) {
Expand Down

0 comments on commit 6acf0e1

Please sign in to comment.