#1
Posted 12 February 2012 - 11:56 AM
My site is located at kathyjf.com/Staging2 and I am using the latest version of Builder and Child theme Foundations Blank.
Thanks,
Kathy
The contactbuddy.php code:
<?php
/**
*
* Plugin Name: ContactBuddy
* Plugin URI: http://pluginbuddy.com/free-wordpress-plugins/contactbuddy/
* Description: A plugin that allows you to add a simple contact form anywhere in your site.
* Version: 1.0.8
* Author: Skyler Moore
* Author URI: http://unconformedmind.com
*
* Installation:
*
* 1. Download and unzip the latest release zip file.
* 2. If you use the WordPress plugin uploader to install this plugin skip to step 4.
* 3. Upload the entire ContactBuddy directory to your `/wp-content/plugins/` directory.
* 4. Activate the plugin through the 'Plugins' menu in WordPress Administration.
*
* Usage:
*
* 1. Navigate to the ContactBuddy menu in the Wordpress Administration Panel.
* 2. Go to the ContactBuddy Settings and add your information.
* 3. Add to your site using widgets or the shortcode button.
*
*/
if (!class_exists("contactbuddy")) {
class contactbuddy {
var $_version = '1.0.8';
var $_var = 'contactbuddy';
var $_name = 'ContactBuddy';
var $_timeformat = '%b %e, %Y, %l:%i%p'; // mysql time format
var $_timestamp = 'M j, Y, g:iA'; // php timestamp format
// Default constructor. This is run when the plugin first runs.
function contactbuddy() {
$this->_defaults['recipemail'] = get_option('admin_email');
$this->_defaults['subject'] = get_option('blogname');
$this->_defaults['recaptcha'] = '0';
$this->_defaults['defaultcss'] = 'on';
$this->_pluginPath = dirname( __FILE__ );
$this->_pluginRelativePath = ltrim( str_replace( '\\', '/', str_replace( rtrim( ABSPATH, '\\\/' ), '', $this->_pluginPath ) ), '\\\/' );
$this->_pluginURL = site_url() . '/' . $this->_pluginRelativePath;
if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) { $this->_pluginURL = str_replace( 'http://', 'https://' $this->_pluginURL ); }
$this->_selfLink = array_shift( explode( '?', $_SERVER['REQUEST_URI'] ) ) . '?page=' . $this->_var;
require_once( dirname( __FILE__ ) . '/classes/widget.php' );
if ( is_admin() ) { // Runs when an admin is in the dashboard.
require_once( $this->_pluginPath . '/classes/admin.php');
register_activation_hook( $this->_pluginPath, array( &$this, 'activate' ) ); // Run some code when plugin is activated in dashboard.
} else { // Runs when in non-dashboard parts of the site.
add_action( 'template_redirect', array( &$this, 'init_public') );
add_shortcode('contactbuddy', array( &$this, 'shortcode' ) );
add_action( $this->_var . '-widget', array( &$this, 'widget' ), 10, 2 ); // Add action to run widget function.
}
}
/**
* alert()
*
* Displays a message to the user at the top of the page when in the dashboard.
*
* $message string Message you want to display to the user.
* $error boolean OPTIONAL! true indicates this alert is an error and displays as red. Default: false
* $error_code int OPTIONAL! Error code number to use in linking in the wiki for easy reference.
*/
function alert( $message, $error = false, $error_code = '' ) {
echo '<div id="message" class="';
if ( $error == false ) {
echo 'updated fade';
} else {
echo 'error';
}
if ( $error_code != '' ) {
$message .= '<p><a href="http://ithemes.com/codex/page/' . $this->_name . ':_Error_Codes#' . $error_code . '" target="_new"><i>' . $this->_name . ' Error Code ' . $error_code . ' - Click for more details.</i></a></p>';
}
echo '"><p><strong>'.$message.'</strong></p></div>';
}
/**
* activate()
*
* Run on plugin activation. Useful for setting up initial stuff.
*
*/
function activate() {
}
/**
* init_public()
*
* Run on on public pages (non-dashboard).
*
*/
function init_public() {
require_once(dirname( __FILE__ ).'/classes/public.php');
}
// OPTIONS STORAGE //
function save() {
add_option($this->_var, $this->_options, '', 'no'); // 'No' prevents autoload if we wont always need the data loaded.
update_option($this->_var, $this->_options);
return true;
}
function load() {
$this->_options=get_option($this->_var);
$options = array_merge( $this->_defaults, (array)$this->_options );
if ( $options !== $this->_options ) {
// Defaults existed that werent already in the options so we need to update their settings to include some new options.
$this->_options = $options;
$this->save();
}
return true;
}
function shortcode() {
return $this->_insertCBform();
}
function widget() {
echo $this->_insertCBform();
}
function _insertCBform() {
$this->load();
$this->_instance++;
if ( (isset($this->_options['defaultcss'])) && ($this->_options['defaultcss'] == 'off')) {
} else {
if ( !wp_style_is('contactbuddy_css') ) {
if ( $this->_options['defaultcss'] == 'on' ) {
$stylesheet = 'contactbuddy';
} else {
$stylesheet = 'contact-' . $this->_options['defaultcss'];
}
wp_enqueue_style('contactbuddy_css', $this->_pluginURL . '/css/' . $stylesheet . '.css');
wp_print_styles('contactbuddy_css');
}
}
$return = '';
if ( !empty($_POST[$this->_var . '-submit']) ) {
if ($this->_instance == $_POST[$this->_var . '-instancenum']) {
$this->_sendEntry();
if( isset($this->_errors) ) {
$form['name'] = $_POST[$this->_var . '-name'];
$form['email'] = $_POST[$this->_var . '-email'];
$form['subject'] = $_POST[$this->_var . '-subject'];
$form['message'] = $_POST[$this->_var . '-message'];
if(in_array('name', $this->_errors)) { $cberror['name'] = 'fail'; }
if(in_array('email', $this->_errors)) { $cberror['email'] = 'fail'; }
if(in_array('subject', $this->_errors)) { $cberror['subject'] = 'fail'; }
if(in_array('message', $this->_errors)) { $cberror['message'] = 'fail'; }
if(in_array('recaptcha', $this->_errors)) { $cberror['recaptcha'] = 'fail'; }
}
if( isset($this->_success) ) {
$scsuccess['success'] = 'it works';
}
}
}
$return .= '<a name="' . $this->_var . '-' . $this->_instance . '"></a>';
$return .= '<form method="post" action="#' . $this->_var . '-' . $this->_instance . '" class="contactbuddy-form" id="contactbuddy-' . $this->_instance . '">';
$return .= '<input type="hidden" name="' . $this->_var . '-instancenum" value="' . $this->_instance . '" />';
$return .= '<ul>';
$return .= '<li class="contactbuddy-name-label"><label>Name: </label>';
if(isset($cberror['name'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['name'])){ $name = $form['name'];} else { $name = ''; }
$return .= '<li class="contactbuddy-name-input"><input type="text" class="cbfit" name="' . $this->_var . '-name" value="' . $name . '" /></li>';
$return .= '<li class="contactbuddy-email-label"><label>Email: </label>';
if(isset($cberror['email'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['email'])){ $email = $form['email'];} else { $email = ''; }
$return .= '<li class="contactbuddy-email-input"><input type="text" class="cbfit" name="' . $this->_var . '-email" value="' . $email . '" /></li>';
$return .= '<li class="contactbuddy-subject-label"><label>Subject: </label>';
if(isset($cberror['subject'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['subject'])){ $subject = $form['subject'];} else { $subject = '';}
$return .= '<li class="contactbuddy-subject-input"><input type="text" class="cbfit" name="' . $this->_var . '-subject" value="' . $subject . '" /></li>';
$return .= '<li class="contactbuddy-message-label"><label>Message: </label>';
if(isset($cberror['message'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['message'])){ $message = $form['message'];} else { $message = ''; }
$return .= '<li class="contactbuddy-message-input"><textarea class="cbfit" name="' . $this->_var . '-message" rows="8">' . $message . '</textarea></li>';
if($this->_options['recaptcha'] == '1'){
$return .= '<li class="contactbuddy-recaptcha-label"><label>reCAPTCHA: </label>';
if(isset($cberror['recaptcha'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
$return .= '<li class="contactbuddy-recaptcha-input">';
require_once('_recaptchalib.php');
$publickey = $this->_options['recaptcha-pubkey']; // public key from recaptcha.com
$return .= recaptcha_get_html($publickey);
$return .= '</li>';
}
$return .= '<li class="contactbuddy-submit"><input type="submit" name="' . $this->_var . '-submit" value="Submit" /></li>';
$return .= '</ul>';
$return .= '</form>';
if (isset($cberror)) {
$return .= '<span class="cberror"><strong>Please correct the above errors in order to send email.</strong></span>';
}
if (isset($scsuccess)) {
$return .= '<div><p class="cbstatus">Email sent successfully.</p></div>';
}
unset($scerror);
unset($form);
return $return;
}
function _sendEntry() {
$this->load();
foreach( $_POST as $key => $val) {
$pos = strpos( $key, $this->_var);
if(($pos !== false) && ($key != ($this->_var . '-submit'))) {
$label = str_replace($this->_var . '-', '', $key);
if ( empty($_POST[$key]) ) {
$this->_errors[] = $label;
}
}
}
// RECAPTCHA VALIDATION
require_once('_recaptchalib.php');
if ($this->_options['recaptcha'] == '1') {
$privatekey = $this->_options['recaptcha-privkey']; // private key from recaptcha.com
$resp = recaptcha_check_answer($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$this->_errors[] = 'recaptcha';
}
}
if ( isset( $this->_errors ) ) {
// fail
} else {
/* STORING CONTACT SUMISSIONS IN DATABASE
// Get index for new entry by adding 1 to the largest index currently in the entries. Put in $newID
if ( is_array( $this->_options['entries'] ) && !empty( $this->_options['entries'] ) ) {
$newID = max( array_keys( $this->_options['entries'] ) ) + 1;
} else {
$newID = 0;
}
$this->_options['entries'][$newID]['name'] = $_POST[$this->_var . '-name'];
$this->_options['entries'][$newID]['email'] = $_POST[$this->_var . '-email'];
$this->_options['entries'][$newID]['subject'] = $subject = $_POST[$this->_var . '-subject'];
$this->_options['entries'][$newID]['message'] = $_POST[$this->_var . '-message'];
$this->save();
*/
/* EMAIL FUNCTION */
$to = $this->_options['recipemail'];
$subject = $this->_options['subject'] . ':' . $_POST[$this->_var . '-subject'];
$message = $_POST[$this->_var . '-message'];
$headers = 'From: ' . $_POST[$this->_var . '-name'] . ' <' . $_POST[$this->_var . '-email'] . '>' . "\r\n";
wp_mail( $to, $subject, $message, $headers );
$_POST[$this->_var . '-name'] = '';
$_POST[$this->_var . '-email'] = '';
$_POST[$this->_var . '-subject'] = '';
$_POST[$this->_var . '-message'] = '';
$this->_success[] = 'success';
}
}
// PUBLIC DISPLAY OF MESSAGES ////////////////////////
function _showStatusMessage( $message ) {
echo '<div id="message" class="updated fade"><p><strong>'.$message.'</strong></p></div>';
}
function _showErrorMessage( $message ) {
echo '<div id="message" class="error"><p><strong>'.$message.'</strong></p></div>';
}
function _cbStatusMessage( $message ) {
return '<div><p class="cbstatus">' . $message . '</p></div>';
}
function _cbErrorMessage( $message ) {
return '<span class="cberror"><strong>' . $message . '</strong></span>';
}
} // End class
$contactbuddy = new contactbuddy(); // Create instance
//require_once( dirname( __FILE__ ) . '/classes/widget.php');
}
?>
#2
Posted 13 February 2012 - 07:20 AM
Add active gallery of images need to type this sitehttp://livedemo00.template-help.com/wordpress_37216/ I did not find the option.
I'm sad about it, the more I create a blog for my client have to leaveit enabled on my client's site? this complicated.
#3
Posted 13 February 2012 - 10:51 AM
thanks,
Ronald
Join the iThemes Builder Community on Google+.
To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.
When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.
#5
Posted 20 February 2012 - 12:22 PM
Thanks for posting this and following-up on it. I'm attaching my modified contactbuddy.php file with the actual label names pointed out with the word "haha" (random thing I inserted there so you can find the exact lines): (right click and save please, or you can click on this file name too)
contactbuddy.php 11.92K
119 downloadsBe sure to backup your original contactbuddy.php file.
Basically, these are lines 180, 186, 192, 198, 215. You can modify the labels around those words in any manner you wish (if I'm understanding you correctly). Example of those texts: http://bes.internal.ithemes.com/contactbuddy
Hope that helps!
Regards,
Bes
Add/Follow me on Twitter - G+ - Social Improve - The Reasoner - FB - LinkedIn - Google Search
#6
Posted 20 February 2012 - 02:18 PM
Thanks for your response but I am still having trouble figuring out how to fix the errors I am getting when trying to validate this form to be accessible for the visually impaired. Here are the exact errors I am getting when running the contact page through validation.
Each of the four labels Name, Email, Subject, and Message show the following error - "Orphaned Form Label: A form label is present, but it is not associated with any form <input>, <select>, or <textarea>".
Each of the four input areas, input area for name, input area for email, input area for subject, and input area for message show the following error - "Error:Form label missing, A form <input>, <select>, or <textarea> does not have a corresponding label. Note labels are not required for hidden, image, submit, reset or button form elements.
I am not very familiar with forms and do not have a clue what I need to add to fix this. Hope you can help.
Thanks,
Kathy
#7
Posted 22 February 2012 - 12:25 PM
Thanks for posting this. Hmmmm, eeeps! I think this is where I really am not sure how to validate the form easily without having the entire things (and multiple files) rewritten. I've added this as a feature suggestion and will let you know whenever there is an update on this OR we have instructions on how to get the forms validated for accessibility for the visually impaired.
In and around the above lines I showed, you could add labels to those input areas too. I think that can be a good start. Of course, you can always revert any changes you make with a saved version of the contactbuddy.php file you may have.
Regards,
Bes
Add/Follow me on Twitter - G+ - Social Improve - The Reasoner - FB - LinkedIn - Google Search
#8
Posted 04 March 2012 - 05:16 PM
I am still having problems adding the labels correctly. I have tried several things but just managed to break the plugin. I have it running again as I had kept a copy of the original but still need to figure out how to add the code I need.
Maybe this will make it clearer exactly what I am looking for -
This is what I need to add to each of the four elements name, email, subject,
and message:
<input type="???" name="???" value="???" id="???" />
<label for="???">???</label>
and this is where I think it needs to go for the name label -lines 176 to 184
from the file:
$return .= '<a name="' . $this->_var . '-' . $this->_instance . '"></a>';
$return .= '<form method="post" action="#' . $this->_var . '-' .
$this->_instance . '" class="contactbuddy-form" id="contactbuddy-' .
$this->_instance . '">';
$return .= '<input type="hidden" name="' . $this->_var . '-instancenum" value="'
. $this->_instance . '" />';
$return .= '<ul>';
$return .= '<li class="contactbuddy-name-label"><label>Name: </label>';
if(isset($cberror['name'])) { $return .= '<span
class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['name'])){ $name = $form['name'];} else { $name = ''; }
$return .= '<li class="contactbuddy-name-input"><input type="text" class="cbfit"
name="' . $this->_var . '-name" value="' . $name . '" /></li>';
I am not sure how to fill in the "???" or where in the code it should go. Any help with this will be greatly appreciated.
Kathy
#9
Posted 05 March 2012 - 04:07 PM
this is how the contactform is currently generated in html, can you, based on that code, indicate where you need to add what?
<form method="post" action="#contactbuddy-1" class="contactbuddy-form" id="contactbuddy-1"> <input type="hidden" name="contactbuddy-instancenum" value="1" /> <ul> <li class="contactbuddy-name-label"> <label>Name: </label> </li> <li class="contactbuddy-name-input"> <input type="text" class="cbfit" name="contactbuddy-name" value="" /> </li> <li class="contactbuddy-email-label"> <label>Email: </label> </li> <li class="contactbuddy-email-input"> <input type="text" class="cbfit" name="contactbuddy-email" value="" /> </li> <li class="contactbuddy-subject-label"> <label>Subject: </label> </li> <li class="contactbuddy-subject-input"> <input type="text" class="cbfit" name="contactbuddy-subject" value="" /> </li> <li class="contactbuddy-message-label"> <label>Message: </label> </li> <li class="contactbuddy-message-input"> <textarea class="cbfit" name="contactbuddy-message" rows="8"></textarea> </li> <li class="contactbuddy-submit"> <input type="submit" name="contactbuddy-submit" value="submit" /> </li> </ul> </form>
thanks,
Ronald
Join the iThemes Builder Community on Google+.
To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.
When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.
#10
Posted 05 March 2012 - 05:03 PM
Thanks for the reply. I think I have already solved this problem. The code below shows how I modified the contactbuddy.php file. Basically all I had to do is add the two code chunks to each of the four form elements.
label for="' . $this->_var . '-message"
and
" id="' . $this->_var . '-message"
I tested the form and was also able to accessibility-validate the page. I am including my modifications below in case they can be of help to someone else.
I know that form labels do not need to be named in this way to pass html validation but since they do need to be there for accessibility validation, it would be nice if the pluginBuddy plugins would include them:)
Thanks,
Kathy
NAME CODE W/LABELS
$return .= '<li class="contactbuddy-name-label"><label for="' . $this->_var . '-name" >Name: </label>';
if(isset($cberror['name'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['name'])){ $name = $form['name'];} else { $name = ''; }
$return .= '<li class="contactbuddy-name-input"><input type="text" class="cbfit" name="' . $this->_var . '-name" id="' . $this->_var . '-name" value="' . $name . '" /></li>';
NAME CODE ORIGINAL 180 through 184
$return .= '<li class="contactbuddy-name-label"><label>Name: </label>';
if(isset($cberror['name'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['name'])){ $name = $form['name'];} else { $name = ''; }
$return .= '<li class="contactbuddy-name-input"><input type="text" class="cbfit" name="' . $this->_var . '-name" value="' . $name . '" /></li>';
END NAME
EMAIL CODE w/LABELS
$return .= '<li class="contactbuddy-email-label"><label for="' . $this->_var . '-email">Email: </label>';
if(isset($cberror['email'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['email'])){ $email = $form['email'];} else { $email = ''; }
$return .= '<li class="contactbuddy-email-input"><input type="text" class="cbfit" name="' . $this->_var . '-email" id="' . $this->_var . '-email" value="' . $email . '" /></li>';
EMAIL CODE ORIGINAL
$return .= '<li class="contactbuddy-email-label"><label>Email: </label>';
if(isset($cberror['email'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['email'])){ $email = $form['email'];} else { $email = ''; }
$return .= '<li class="contactbuddy-email-input"><input type="text" class="cbfit" name="' . $this->_var . '-email" value="' . $email . '" /></li>';
END EMAIL
SUBJECT CODE w/LABELS
$return .= '<li class="contactbuddy-subject-label"><label for="' . $this->_var . '-subject" >Subject: </label>';
if(isset($cberror['subject'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['subject'])){ $subject = $form['subject'];} else { $subject = '';}
$return .= '<li class="contactbuddy-subject-input"><input type="text" class="cbfit" name="' . $this->_var . '- subject" id="' . $this->_var . '-subject" value="' . $subject . '" /></li>';
SUBJECT CODE ORIGINAL
$return .= '<li class="contactbuddy-subject-label"><label>Subject: </label>';
if(isset($cberror['subject'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['subject'])){ $subject = $form['subject'];} else { $subject = '';}
$return .= '<li class="contactbuddy-subject-input"><input type="text" class="cbfit" name="' . $this->_var . '- subject" value="' . $subject . '" /></li>';
END SUBJECT
MESSAGE CODE w/LABELS
$return .= '<li class="contactbuddy-message-label"><label for="' . $this->_var . '-message" >Message: </label>';
if(isset($cberror['message'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['message'])){ $message = $form['message'];} else { $message = ''; }
$return .= '<li class="contactbuddy-message-input"><textarea class="cbfit" name="' . $this->_var . '-message" id="' . $this->_var . '-message" rows="8">' . $message . '</textarea ></li>';
MESSAGE CODE ORIGINAL
$return .= '<li class="contactbuddy-message-label"><label>Message: </label>';
if(isset($cberror['message'])) { $return .= '<span class="cberror"><strong>required</strong></span>'; }
$return .= '</li>';
if (isset($form['message'])){ $message = $form['message'];} else { $message = ''; }
$return .= '<li class="contactbuddy-message-input"><textarea class="cbfit" name="' . $this->_var . '-message" rows="8">' . $message . '</textarea></li>';
END MESSAGE
END ALL CODE
#11
Posted 05 March 2012 - 05:22 PM
and if it works for you, we will mark this resolved ok?
Ronald
Join the iThemes Builder Community on Google+.
To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. Please also read the forum guidelines.
When asking your question/posting your request on the forum, please be as concise and specific as possible. The shorter your request, the more to the point, the more specific, the easier it will be for us to try and help out.
Reply to this Topic
ATTENTION
If this topic is marked RESOLVED or INFORMATION, or if you are NOT experiencing EXACTLY the same issue, please start a new topic to provide the details of your problem. If the solution provided doesn't work for you, you should start a new topic. If you feel this thread contains relevant information, you may include a link to it in your new topic. To ensure that we can process your support request efficiently, ALWAYS include a link to your site, and/or the page your request is related to. When posting your question or request on the forum, please be as concise and specific as possible. The shorter and more to the point you can make your request, the better.
For BackupBuddy related issues, be sure to include the status log from your most recent backup.
CLICK HERE to start a new topic in the ContactBuddy forum.
Also tagged with one or more of these keywords: resolved, in progress
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





