Last active
February 16, 2021 01:21
-
-
Save MikeGillihan/9215fc621fa24c83b71ae0e0fd021b2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
/** | |
* Get all GiveWP donation forms | |
* | |
* @return array List of GiveWP forms | |
*/ | |
public function list_forms() { | |
$list = array( '' => __( 'Select a Form', GoodModules::$text_domain ) ); | |
$forms = get_posts( array( | |
'post_type' => 'give_forms', | |
'posts_per_page' => - 1, | |
) ); | |
foreach ( $forms as $form ) { | |
$list[ $form->ID ] = $form->post_title; | |
} | |
return $list; | |
} | |
/** | |
* Build array of conditional settings. | |
* | |
* @return array settings applied to the toggle setting in register_module | |
*/ | |
public function toggle_fields() { | |
$toggle = array(); | |
$form_ID = $this->settings->select_form_field; | |
if ( GiveUtils::isLegacyForm( $form_ID ) ) { | |
$toggle = array( | |
$form_ID => array( | |
'sections' => array( | |
'form_settings', | |
), | |
), | |
); | |
} | |
return $toggle; | |
} | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$give_forms = new CLGM_Give_Forms(); | |
/** | |
* Register the module and its form settings. | |
*/ | |
FLBuilder::register_module( 'CLGM_Give_Forms', array( | |
'form' => array( // Tab | |
'title' => __( 'General', GoodModules::$text_domain ), // Tab title | |
'sections' => array( // Tab Sections | |
'select_form' => array( // Section | |
'title' => '', // Section Title | |
'fields' => array( // Section Fields | |
'select_form_field' => array( | |
'type' => 'select', | |
'label' => __( 'Select Form', GoodModules::$text_domain ), | |
'default' => '', | |
'options' => $give_forms->list_forms(), | |
'toggle' => $give_forms->toggle_fields(), | |
), | |
), | |
), | |
'form_settings' => array( // Section | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment