Skip to content
Browse files

Allowed admin_bar form edit button to include all forms from a given …

…page or listing.
  • Loading branch information...
1 parent dda6675 commit c3f6324a23c95d3eb69b48e55c552b2c2036b5a5 @warkior warkior committed Oct 19, 2011
Showing with 119 additions and 15 deletions.
  1. +88 −14 formbuilder.php
  2. +19 −0 php/formbuilder_activation_script.inc.php
  3. +12 −1 readme.txt
View
102 formbuilder.php
@@ -4,7 +4,7 @@
Plugin URI: http://truthmedia.com/wordpress/formbuilder
Description: The FormBuilder plugin allows the administrator to create contact forms of a variety of types for use on their WordPress blog. The FormBuilder has built-in spam protection and can be further protected by installing the Akismet anti-spam plugin. Uninstall instructions can be found <a href="http://truthmedia.com/wordpress/formbuilder/documentation/uninstall/">here</a>. Forms can be included on your pages and posts either by selecting the appropriate form in the dropdown below the content editing box, or by adding them directly to the content with [formbuilder:#] where # is the ID number of the form to be included.
Author: TruthMedia Internet Group
-Version: 0.881
+Version: 0.89
Author URI: http://truthmedia.com/
Created by the TruthMedia Internet Group
@@ -28,7 +28,7 @@
*/
- define("FORMBUILDER_VERSION_NUM", "0.881");
+ define("FORMBUILDER_VERSION_NUM", "0.89");
// Define FormBuilder Related Tables
global $table_prefix;
@@ -816,6 +816,57 @@ function formbuilder_build_url($add = array(), $qvars = array())
}
/**
+ * Get a list of all forms on this page.
+ */
+ function formbuilder_get_all_forms()
+ {
+ global $wp_query, $wpdb;
+
+ $formIDs = array();
+
+ if(isset($wp_query))
+ {
+
+ echo "TESTING FOR FORMS..";
+ foreach($wp_query->posts as $post)
+ {
+ $content = $post->post_content;
+ $content_form_ids = formbuilder_check_content($content);
+
+ foreach($content_form_ids as $form_id)
+ {
+ $formIDs[] = $form_id['id'];
+ }
+
+ $post_id = $post->ID;
+
+ $sql = "SELECT form_id FROM " . FORMBUILDER_TABLE_PAGES . " WHERE post_id = '$post_id';";
+ $results = $wpdb->get_results($sql, ARRAY_A);
+
+ if($results)
+ {
+ $page = $results[0];
+ $formIDs[] = $page['form_id'];
+ }
+ }
+ }
+
+ var_dump($formIDs);
+
+ if(count($formIDs) > 0)
+ {
+ $insert = implode(',', $formIDs);
+ $sql = "SELECT * FROM " . FORMBUILDER_TABLE_FORMS . " WHERE id IN ({$insert});";
+ $results = $wpdb->get_results($sql, ARRAY_A);
+ return($results);
+ }
+ else
+ {
+ return(array());
+ }
+ }
+
+ /**
* Admin bar link. Code from:
* http://www.problogdesign.com/wordpress/add-useful-links-to-wordpress-admin-bar/
*/
@@ -824,21 +875,44 @@ function formbuilder_build_url($add = array(), $qvars = array())
* Adds links to the bar.
*/
function formbuilder_admin_bar_links() {
- global $wp_admin_bar;
+ global $wp_admin_bar, $formbuilder_formDisplayArray, $wpdb;
// Only show if there is a form attached to the page.
- $form = formbuilder_page_has_form();
+ $formIDs = array();
+ foreach($formbuilder_formDisplayArray as $formID=>$result)
+ {
+ $formIDs[] = $formID;
+ }
- if(!$form) return;
+ if(count($formIDs) > 0)
+ {
+ $insert = implode(',', $formIDs);
+ $sql = "SELECT * FROM " . FORMBUILDER_TABLE_FORMS . " WHERE id IN ({$insert});";
+ $forms = $wpdb->get_results($sql, ARRAY_A);
+
+ // Add the Parent link.
+ $url = get_admin_url(null, '/tools.php?page=formbuilder.php&fbaction=editForm&fbid=' . $form['id']);
+ $wp_admin_bar->add_menu( array(
+ 'title' => 'Edit Form',
+ 'id' => 'formbuilder_forms'
+ ));
+
+ foreach($formIDs as $id)
+ {
+ foreach($forms as $form)
+ {
+ if($form['id'] != $id) continue;
+ $url = get_admin_url(null, '/tools.php?page=formbuilder.php&fbaction=editForm&fbid=' . $form['id']);
+ $wp_admin_bar->add_menu( array(
+ 'parent' => 'formbuilder_forms',
+ 'title' => $form['name'],
+ 'href' => $url,
+ 'id' => 'formbuilder_form_' . $form['id']
+ ));
+ }
+ }
+ }
-
- // Add the Parent link.
- $url = get_admin_url(null, '/tools.php?page=formbuilder.php&fbaction=editForm&fbid=' . $form['id']);
- $wp_admin_bar->add_menu( array(
- 'title' => 'Edit Form',
- 'href' => $url,
- 'id' => 'formbuilder_forms'
- ));
}
@@ -851,7 +925,7 @@ function formbuilder_admin_bar_init() {
return;
// Good to go, lets do this!
- add_action('admin_bar_menu', 'formbuilder_admin_bar_links', 500);
+ add_action('admin_bar_menu', 'formbuilder_admin_bar_links', 35);
}
View
19 php/formbuilder_activation_script.inc.php
@@ -989,6 +989,25 @@ function formbuilder_activation() {
update_option('formbuilder_version', "0.88");
}
+
+
+ // Upgrade to version 0.89
+ if(get_option('formbuilder_version') < 0.89)
+ {
+ formbuilder_admin_alert("Upgraded FormBuilder to version 0.89", nl2br("
+* Feature: Allow ~variable~ fields in thankyou text.
+* Feature: Option to show all fields in autoresponder.
+* Bug Fix: Quotes in ThankYou text remain encoded which breaks HTML
+* Bug Fix: Name/Email matching was too broad.
+* Bug Fix: Fixed ability to create new forms.
+* Bug Fix: Form search lost when switching pages.
+* Bug Fix: Fixed forms not displaying / processing properly on some themes due to the_content being processed multiple times.
+* Bug Fix: Forms with followup_url fields now bounce straight to the followup url without re-showing the original page first.
+ "));
+
+ // update_option('formbuilder_version', "0.89");
+ }
+
View
13 readme.txt
@@ -4,7 +4,7 @@ Donate link: http://truthmedia.com/engage/giving
Tags: form, forms, email, comments, contact, input, spam, form to email, email form, contact form
Requires at least: 2.7
Tested up to: 3.2.1
-Stable tag: 0.881
+Stable tag: 0.89
Allows WordPress bloggers to easily create customised forms for use on pages or posts.
@@ -71,6 +71,17 @@ Programming and Design by [James Warkentin](http://www.warkensoft.com/about-me/)
== Changelog ==
+= 0.89 =
+* Feature: Allow ~variable~ fields in thankyou text.
+* Feature: Option to show all fields in autoresponder.
+* Bug Fix: Quotes in ThankYou text remain encoded which breaks HTML
+* Bug Fix: Name/Email matching was too broad.
+* Bug Fix: Fixed ability to create new forms.
+* Bug Fix: Form search lost when switching pages.
+* Bug Fix: Fixed forms not displaying / processing properly on some themes due to the_content being processed multiple times.
+* Bug Fix: Forms with followup_url fields now bounce straight to the followup url without re-showing the original page first.
+
+
= 0.881 =
* Bug Fix: Catchable fatal error in FormBuilder repaired.

0 comments on commit c3f6324

Please sign in to comment.
Something went wrong with that request. Please try again.