--- a/cf7-zendesk/cf7-zendesk.php
+++ b/cf7-zendesk/cf7-zendesk.php
@@ -2,7 +2,7 @@
/**
* Plugin Name: Contact Form 7 Zendesk
* Description: Integrates Contact Form 7, <a href="https://wordpress.org/plugins/contact-form-entries/">Contact Form Entries Plugin</a> and many other forms with Zendesk allowing form submissions to be automatically sent to your Zendesk account
-* Version: 1.1.5
+* Version: 1.1.6
* Requires at least: 3.8
* Author URI: https://www.crmperks.com
* Plugin URI: https://www.crmperks.com/plugins/contact-form-plugins/contact-form-zendesk-plugin/
@@ -24,7 +24,7 @@
public $crm_name = "zendesk";
public $id = "vxcf_zendesk";
public $domain = "vxcf-zendesk";
- public $version = "1.1.5";
+ public $version = "1.1.6";
public $update_id = "6000015";
public $min_cf_version = "1.0";
public $type = "vxcf_zendesk";
@@ -108,18 +108,7 @@
add_action('init', array($this,'init'));
//loading translations
load_plugin_textdomain('contact-form-zendesk-crm', FALSE, $this->plugin_dir_name(). '/languages/' );
-
- self::$db_version=get_option($this->type."_version");
- if(self::$db_version != $this->version && current_user_can( 'manage_options' )){
- $data=$this->get_data_object();
- $data->update_table();
- update_option($this->type."_version", $this->version);
- //add post permissions
- require_once(self::$path . "includes/install.php");
- $install=new vxcf_zendesk_install();
- $install->create_roles();
-
- }
+$this->maybe_install(true);
}
}
@@ -139,6 +128,31 @@
self::$plugin->instance();
}
} }
+ /**
+ * create tables and roles
+ *
+ */
+public function maybe_install($version_check=false){
+
+ if(current_user_can( 'manage_options' )){
+ self::$db_version=get_option($this->type."_version");
+ $do_install=false;
+ if($version_check == false){
+ $do_install=true;
+ }else if(self::$db_version != $this->version){
+ $do_install=true;
+ }
+ if($do_install){
+ $data=$this->get_data_object();
+ $data->update_table();
+ update_option($this->type."_version", $this->version);
+ //add post permissions
+ require_once(self::$path . "includes/install.php");
+ $install=new vxcf_zendesk_install();
+ $install->create_roles();
+ }
+ }
+}
public function form_submitted($form){
@@ -208,18 +222,17 @@
$val=$uploaded_files[$name];
}
- if( !empty($val) && isset($v['basetype']) && $v['basetype'] == 'mfile' && function_exists('dnd_get_upload_dir') ){
+ if( !empty($val) && isset($v['basetype']) && $v['basetype'] == 'mfile' && function_exists('dnd_get_upload_dir') ){
$dir=dnd_get_upload_dir();
$f_arr=array();
foreach($val as $file){
- $file_name=explode('/',$file);
+ $file_name=explode('/',$file);
if(count($file_name)>1){
- $f_arr[]=$dir['upload_url'].'/'.$file_name[1];
+ $f_arr[]=$dir['upload_url'].'/'.end($file_name);
}
- }
-
+ }
$val=$f_arr;
- }
+ }
if(!isset($uploaded_files[$name])){
$val=wp_unslash($val);
}
@@ -500,27 +513,6 @@
}
- /**
- * create tables and roles
- *
- */
- public function install(){
-
- if(current_user_can( 'manage_options' )){
- self::$db_version=get_option($this->type."_version");
- if(self::$db_version != $this->version){
- $data=$this->get_data_object();
- $data->update_table();
- update_option($this->type."_version", $this->version);
- //add post permissions
- require_once(self::$path . "includes/install.php");
- $install=new vxcf_zendesk_install();
- $install->create_roles();
-
- }
-
- }
- }
/**
* Contact Form status
*
@@ -1268,6 +1260,7 @@
*/
public function activate(){
$this->plugin_api(true);
+$this->maybe_install();
do_action('plugin_status_'.$this->type,'activate');
}
/**
@@ -1775,16 +1768,7 @@
if(!empty($v)){ //if value not empty
if($this->post('type',$v) == "value"){ //custom value
$value=trim($this->post('value',$v));
- //starts with { and ends } , any char in brackets except {
- preg_match_all('/{[^{]+}/',$value,$matches);
- if(!empty($matches[0])){
- $vals=array();
- foreach($matches[0] as $m){
- $m=trim($m,'{}');
- $vals['{'.$m.'}']=$this->verify_field_val($entry,$m);
- }
- $value=str_replace(array_keys($vals),array_values($vals),$value);
- }
+$value=$this->process_tags($entry,$value);
}else{ //general field
$field=$this->post('field',$v);
@@ -1941,6 +1925,22 @@
}
return array("msg"=>$notice,"class"=>$screen_msg_class);
}
+ public function process_tags($entry,$value){
+ //starts with { and ends } , any char in brackets except {
+ preg_match_all('/{[^{]+}/',$value,$matches);
+ if(!empty($matches[0])){
+ $vals=array();
+ foreach($matches[0] as $m){
+ $m=trim($m,'{}');
+ $val_cust=$this->verify_field_val($entry,$m);
+ if(is_array($val_cust)){ $val_cust=trim(implode(' ',$val_cust)); }
+ $vals['{'.$m.'}']=$val_cust;
+ }
+
+ $value=str_replace(array_keys($vals),array_values($vals),$value);
+ }
+ return $value;
+}
/**
* Send error email
--- a/cf7-zendesk/templates/log.php
+++ b/cf7-zendesk/templates/log.php
@@ -28,7 +28,7 @@
?>
<div class="entry_row">
<div class="entry_col1 vx_label"><span title="<?php echo esc_attr($k) ?>"><?php echo esc_html($label); ?></span></div>
-<div class="entry_col2"><?php echo is_array($value) ? json_encode($value) : $value ?></div>
+<div class="entry_col2"><?php echo is_array($value) ? esc_html(json_encode($value)) : esc_html($value) ?></div>
<div class="crm_clear"></div>
</div>
<?php