Last active
May 21, 2019 09:33
-
-
Save danielpost/7ee3f1eb48a7c2f9aad9aab599a2c519 to your computer and use it in GitHub Desktop.
WordPress Form Plugins: Get list of all available forms
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
<?php | |
$forms = get_posts(['post_type' => 'wpcf7_contact_form', 'posts_per_page' => -1]); | |
if (empty($forms)) { | |
return []; | |
} | |
return array_combine(wp_list_pluck($forms, 'ID'), wp_list_pluck($forms, 'post_title')); |
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
<?php | |
if (!class_exists('GFAPI')) { | |
return []; | |
} | |
$forms = GFAPI::get_forms(); | |
if (empty($forms)) { | |
return []; | |
} | |
return array_combine(wp_list_pluck($forms, 'id'), wp_list_pluck($forms, 'title')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment