str_replace("/","",str_replace(basename(__FILE__),"",plugin_basename( __FILE__)))) * @param string $pluginID the pluginID of the plugin (probably $this->pluginID) * @return SLFramework_Feedback the SLFramework_Feedback object */ function SLFramework_Feedback($plugin, $pluginID) { $this->plugin = $plugin ; $this->pluginID = $pluginID ; } /** ==================================================================================================================================================== * Display the feedback form * Please note that the users will send you their comments/feedback at the email used is in the header of the main file of your plugin Author Email : name@domain.tld * * @return void */ public function enable_feedback() { $_POST['plugin'] = $this->plugin ; $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR."/".$this->plugin."/".$this->plugin.".php") ; if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\.[a-z]{2,4}$#",$info_file['Email'])) { ?>

".__("Feedback form",'SL_framework')."" ; echo "

".__('This form is an easy way to contact the author and to discuss issues/incompatibilities/etc. with him', "SL_framework")."

" ; echo "
" ; if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\.[a-z]{2,4}$#",$info_file['Email'])) { $table = new SLFramework_Table() ; $table->title(array(__("Contact the author", "SL_framework"), "") ) ; // Name $cel1 = new adminCell("

".__('Your name:', 'SL_framework')."*

") ; $cel2 = new adminCell("

") ; $table->add_line(array($cel1, $cel2), '1') ; // Email $cel1 = new adminCell("

".__('Your email:', 'SL_framework')."*

".__('Useful... so that the author will be able to anwser you.', 'SL_framework')."

") ; $cel2 = new adminCell("

") ; $table->add_line(array($cel1, $cel2), '1') ; // Comment $cel1 = new adminCell("

".__('Your comments:', 'SL_framework')."*

".__('Please note that additional information on your wordpress installation will be sent to the author in order to help the debugging if needed (such as : the wordpress version, the installed plugins, etc.)', 'SL_framework')."

") ; $cel2 = new adminCell("

") ; $table->add_line(array($cel1, $cel2), '1') ; echo $table->flush() ; echo "

" ; $x = plugin_dir_url("/").'/'.str_replace(basename(__FILE__),"",plugin_basename(__FILE__)) ; echo "" ; } else { echo "

".__('No email have been provided for the author of this plugin. Therefore, the feedback is impossible', 'SL_framework')."

" ; } echo "
" ; } /** ==================================================================================================================================================== * Send the feedback form * * @access private * @return void */ public function send_feedback() { // We sanitize the entries $plugin = preg_replace("/[^a-zA-Z0-9_-]/","",$_POST['plugin']) ; $pluginID = preg_replace("/[^a-zA-Z0-9_]/","",$_POST['pluginID']) ; $name = strip_tags($_POST['name']) ; $mail = preg_replace("/[^:\/a-z0-9@A-Z_.-]/","",$_POST['mail']) ; $comment = strip_tags($_POST['comment']) ; // If applicable, we select the log file $logfile = SLFramework_Debug::get_log_path() ; $info_file = pluginSedLex::get_plugins_data(WP_PLUGIN_DIR."/".$plugin."/".$plugin.".php") ; $to = $info_file['Email'] ; $subject = "[".ucfirst($plugin)."] Feedback of ".$name ; $message = "" ; $message .= "From $name (".$mail.")\n\n\n" ; $message .= $comment."\n\n\n" ; $message .= "* Accounts \n" ; $message .= "**************************************** \n" ; $admin = get_userdata(1); $message .= "Admin User Name: " . $admin->display_name ."\n" ; $message .= "Admin User Login: " . $admin->user_login."\n" ; $message .= "Admin User Mail: " . $admin->user_email."\n" ; $current_user = wp_get_current_user(); $message .= "Logged User Name: " . $current_user->display_name ."\n" ; $message .= "Logged User Login: " . $current_user->user_login."\n" ; $message .= "Logged User Mail: " . $current_user->user_email."\n" ; $message .= "\n\n\n" ; $message .= "* Information \n" ; $message .= "**************************************** \n" ; $message .= "Plugin: ".$plugin."\n" ; $message .= "Plugin Version: ".$info_file['Version']."\n" ; $message .= "Wordpress Version: ".get_bloginfo('version')."\n" ; $message .= "URL (home): ".home_url('/')."\n" ; $message .= "URL (site): ".site_url('/')."\n" ; $message .= "Language: ".get_bloginfo('language')."\n" ; $message .= "Charset: ".get_bloginfo('charset')."\n" ; $message .= "\n\n\n" ; $message .= "* Configuration of the plugin \n" ; $message .= "**************************************** \n" ; $options = get_option($pluginID.'_options'); // mask the password $new_option = array() ; $new_plugin_copy = call_user_func(array($pluginID, 'getInstance')); foreach ($options as $o=>$v) { if ($new_plugin_copy->get_default_option($o)!=="[password]") { $new_option[$o] = $v ; } else { $new_option[$o] = "********** (masked)" ; } } ob_start() ; print_r($new_option) ; $message .= ob_get_clean() ; $message .= "\n\n\n" ; $message .= "* Activated plugins \n" ; $message .= "**************************************** \n" ; $plugins = get_plugins() ; $active = get_option('active_plugins') ; foreach($plugins as $file=>$p){ if (array_search($file, $active)!==false) { $message .= $p['Name']."(".$p['Version'].") => ".$p['PluginURI']."\n" ; } } $headers = "" ; if (preg_match("#^[a-z0-9-_.]+@[a-z0-9-_.]{2,}\.[a-z]{2,4}$#",$mail)) { $headers = "Reply-To: $mail\n". "Return-Path: $mail" ; } $attachments = array($logfile); // send the email if (wp_mail( $to, $subject, $message, $headers, $attachments )) { echo "
" ; echo "

".__("The feedback has been sent", 'SL_framework')."

" ; echo "
" ; SLFramework_Debug::log(get_class(), "A feedback mail has been sent.", 4) ; } else { echo "
" ; echo "

".__("An error occured sending the email.", 'SL_framework')."

".__("Make sure that your wordpress is able to send email.", 'SL_framework')."

" ; echo "
" ; SLFramework_Debug::log(get_class(), "A feedback mail has failed to be sent.", 2) ; } //Die in order to avoid the 0 character to be printed at the end die() ; } } } ?>