-
-
Save jasondavis/89f6a5c40739723f7fa754f643995232 to your computer and use it in GitHub Desktop.
Get Forms List for Ninja Forms, Gravity Forms and Contact Form 7 WordPress Plugins
This file contains hidden or 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
| <?php | |
| /** Ninja Forms */ | |
| function delight_ninja_forms() { | |
| if ( function_exists('ninja_forms_get_all_forms') ) { | |
| $nfs = ninja_forms_get_all_forms(); | |
| } | |
| $nforms = array( '' => __('Select a Form', 'TEXT-DOMAIN') ); | |
| if( !empty( $nfs ) ) { | |
| foreach($nfs as $form){ | |
| $title = $form['data']['form_title']; | |
| $id = $form['id']; | |
| $nforms[$id] = strip_tags($title); | |
| } | |
| } | |
| return $nforms; | |
| } | |
| /** Gravity Forms */ | |
| function delight_gravity_forms() { | |
| if( class_exists('RGFormsModel') ) { | |
| $gfs = GFFormsModel::get_forms(); | |
| } | |
| $gforms = array( '' => __('Select a Form', 'TEXT-DOMAIN') ); | |
| if( !empty( $gfs ) ) { | |
| foreach ($gfs as $form) { | |
| $title = $form->title; | |
| $id = $form->id; | |
| $gforms[$id] = strip_tags($title); | |
| } | |
| } | |
| return $gforms; | |
| } | |
| /** Contact Form 7 Forms */ | |
| function delight_cf7_forms() { | |
| if ( function_exists('wpcf7') ) { | |
| $cfs = get_posts(array( | |
| 'post_type' => 'wpcf7_contact_form', | |
| 'posts_per_page' => -1, | |
| 'post_status' => 'publish', | |
| 'order' => 'ASC', | |
| 'orderby' => 'title' | |
| ) | |
| ); | |
| } | |
| $cf7_forms = array( '' => __('Select a Form', 'TEXT-DOMAIN') ); | |
| if( !empty( $cfs ) ) { | |
| foreach ( $cfs as $cf ) { | |
| $cf7_forms[absint( $cf->ID )] = strip_tags($cf->post_title); | |
| } | |
| } | |
| return $cf7_forms; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment