';
$data_intro .= $introtext;
@@ -1150,13 +1150,13 @@ public function render($data = null){
}
}
- if($icon_position == 'left') {
- $button = (esc_attr($btn_icon_list)) ? '
' . esc_attr($button_text).' ' : '
' . esc_attr($button_text). ' ';
+ if ( $icon_position == 'left' ) {
+ $button = ( esc_attr($btn_icon_list ) ) ? '
' . esc_attr($button_text).' ' : '
' . esc_attr($button_text). ' ';
} else {
- $button = (esc_attr($btn_icon_list)) ? '
' . esc_attr($button_text) . ' ' : esc_attr($button_text).' ';
+ $button = ( esc_attr( $btn_icon_list ) ) ? '
' . esc_attr($button_text) . ' ' : esc_attr($button_text).' ';
}
- if( !empty($button_link['link']) ){
+ if ( ! empty( $button_link['link'] ) ) {
$btntarget = !empty($button_link['window']) ? 'target=_blank' : 'target=_self';
$btnnofolow = !empty($button_link['nofolow']) ? 'rel=nofolow' : "";
$btndata = '
' . $button . ' ';
diff --git a/addons/flip_box/flip_box.php b/addons/flip_box/flip_box.php
index 1d83a3a..69d2a5b 100644
--- a/addons/flip_box/flip_box.php
+++ b/addons/flip_box/flip_box.php
@@ -1010,77 +1010,77 @@ public function get_settings() {
public function render($data = null){
$settings = $data['settings'];
- $front_title = isset($settings['front_title']) ? $settings['front_title'] : '';
- $front_heading_selector = isset($settings["front_heading_selector"]) ? $settings["front_heading_selector"] : '';
- $front_introtext = isset($settings['front_introtext']) ? $settings['front_introtext'] : '';
- $front_show_icon = isset($settings['front_show_icon']) ? $settings['front_show_icon'] : '';
- $front_icon_list = isset($settings['front_icon_list']) ? $settings['front_icon_list'] : '';
+ $front_title = isset($settings['front_title']) ? sanitize_text_field( $settings['front_title'] ) : '';
+ $front_heading_selector = isset($settings["front_heading_selector"]) ? sanitize_text_field( $settings["front_heading_selector"] ) : '';
+ $front_introtext = isset($settings['front_introtext']) ? sanitize_text_field( $settings['front_introtext'] ) : '';
+ $front_show_icon = isset($settings['front_show_icon']) ? sanitize_text_field( $settings['front_show_icon'] ) : '';
+ $front_icon_list = isset($settings['front_icon_list']) ? sanitize_text_field( $settings['front_icon_list'] ) : '';
$front_image_upload = isset($settings['front_image_upload']) ? $settings['front_image_upload'] : array();
- $front_image_alt = isset($settings['front_image_alt']) ? $settings['front_image_alt'] : '';
+ $front_image_alt = isset($settings['front_image_alt']) ? sanitize_text_field( $settings['front_image_alt'] ) : '';
- $back_title = isset($settings['back_title']) ? $settings['back_title'] : '';
- $back_heading_selector = isset($settings["back_heading_selector"]) ? $settings["back_heading_selector"] : '';
- $back_introtext = isset($settings['back_introtext']) ? $settings['back_introtext'] : '';
- $back_button_text = isset($settings['back_button_text']) ? $settings['back_button_text'] : '';
+ $back_title = isset($settings['back_title']) ? sanitize_text_field( $settings['back_title'] ) : '';
+ $back_heading_selector = isset($settings["back_heading_selector"]) ? sanitize_text_field( $settings["back_heading_selector"] ) : '';
+ $back_introtext = isset($settings['back_introtext']) ? sanitize_text_field( $settings['back_introtext'] ) : '';
+ $back_button_text = isset($settings['back_button_text']) ? sanitize_text_field( $settings['back_button_text'] ) : '';
$back_btn_link = isset($settings['back_btn_link']) ? $settings['back_btn_link'] : array();
- $back_show_icon = isset($settings['back_show_icon']) ? $settings['back_show_icon'] : '';
- $back_icon_list = isset($settings['back_icon_list']) ? $settings['back_icon_list'] : '';
+ $back_show_icon = isset($settings['back_show_icon']) ? sanitize_text_field( $settings['back_show_icon'] ) : '';
+ $back_icon_list = isset($settings['back_icon_list']) ? sanitize_text_field( $settings['back_icon_list'] ) : '';
$back_image_upload = isset($settings['back_image_upload']) ? $settings['back_image_upload'] : array();
- $back_image_alt = isset($settings['back_image_alt']) ? $settings['back_image_alt'] : '';
+ $back_image_alt = isset($settings['back_image_alt']) ? sanitize_text_field( $settings['back_image_alt'] ) : '';
- $flip_bhave = isset($settings['flip_bhave']) ? $settings['flip_bhave'] : '';
- $flip_style = isset($settings['flip_style']) ? $settings['flip_style'] : 'rotate_style';
- $flip_direction = isset($settings['flip_direction']) ? $settings['flip_direction'] : '';
+ $flip_bhave = isset($settings['flip_bhave']) ? sanitize_text_field( $settings['flip_bhave'] ) : '';
+ $flip_style = isset($settings['flip_style']) ? sanitize_text_field( $settings['flip_style'] ) : 'rotate_style';
+ $flip_direction = isset($settings['flip_direction']) ? sanitize_text_field( $settings['flip_direction'] ) : '';
$output = $img_front_url = $img_back_url = $data_front_title = $data_front_intro = $data_back_title = $data_back_intro = $data_back_button = $data_front_media = $data_back_media = '' ;
- if( !empty( $front_title ) ){
- $data_front_title .= '<' .esc_attr($front_heading_selector). ' class="wppb-flip-front-title">' . wp_kses_post($front_title) .'' . esc_attr($front_heading_selector) . '>';
+ if ( ! empty( $front_title ) ) {
+ $data_front_title .= '<' .esc_attr($front_heading_selector). ' class="wppb-flip-front-title">' . wp_kses_post( $front_title ) .'' . esc_attr($front_heading_selector) . '>';
}
- if( !empty( $front_introtext ) ){
- $data_front_intro .= '
' . wp_kses_post($front_introtext) .'
';
+ if ( ! empty( $front_introtext ) ) {
+ $data_front_intro .= '
' . wp_kses_post( $front_introtext ) .'
';
}
- if($front_show_icon == 1) {
- if( !empty( $front_icon_list ) ){
+ if ( $front_show_icon == 1 ) {
+ if ( ! empty( $front_icon_list ) ) {
$data_front_media .= '
';
- $data_front_media .= ' ';
+ $data_front_media .= ' ';
$data_front_media .= '
';
}
} else {
- if ( ! empty($front_image_upload['url']) ) {
+ if ( ! empty( $front_image_upload['url'] ) ) {
$img_front_url = $front_image_upload['url'];
$data_front_media .= '
';
- $data_front_media .= '
';
+ $data_front_media .= '
';
$data_front_media .= '
';
}
}
- if( !empty( $back_title ) ){
- $data_back_title .= '<' .esc_attr($back_heading_selector). ' class="wppb-flip-back-title">' . wp_kses_post($back_title) .'' . esc_attr($back_heading_selector) . '>';
+ if ( ! empty( $back_title ) ) {
+ $data_back_title .= '<' . esc_attr( $back_heading_selector ) . ' class="wppb-flip-back-title">' . wp_kses_post($back_title) .'' . esc_attr($back_heading_selector) . '>';
}
- if( !empty( $back_introtext ) ){
+ if ( ! empty( $back_introtext ) ) {
$data_back_intro .= '
' . wp_kses_post($back_introtext) .'
';
}
- if( !empty($back_btn_link['link']) ){
+ if ( ! empty( $back_btn_link['link'] ) ) {
$btntarget = $back_btn_link['window'] ? 'target=_blank' : 'target=_self';
$btnnofolow = $back_btn_link['nofolow'] ? 'rel=nofolow' : "";
- $data_back_button = '
' . $back_button_text . ' ';
+ $data_back_button = '
' . $back_button_text . ' ';
}
- if($back_show_icon == 1) {
- if( !empty( $back_icon_list ) ){
+ if ( $back_show_icon == 1 ) {
+ if ( ! empty( $back_icon_list ) ) {
$data_back_media .= '
';
- $data_back_media .= ' ';
+ $data_back_media .= ' ';
$data_back_media .= '
';
}
} else {
- if ( ! empty($back_image_upload['url']) ) {
+ if ( ! empty( $back_image_upload['url'] ) ) {
$img_back_url = $back_image_upload['url'];
$data_back_media .= '
';
- $data_back_media .= '
';
+ $data_back_media .= '
';
$data_back_media .= '
';
}
}
diff --git a/addons/form/assets/js/main.js b/addons/form/assets/js/main.js
index b3e8c8c..77be92e 100644
--- a/addons/form/assets/js/main.js
+++ b/addons/form/assets/js/main.js
@@ -1,44 +1,46 @@
'use strict';
-;(function ($) {
+(function ($) {
'use strict';
- $(document).on('submit', '.wppb-global-form-addon form', function(e){
+ $(document).on('submit', '.wppb-global-form-addon form', function (e) {
e.preventDefault();
var $form = $(this);
- var $formData = $form.serialize()+'&action=wppb_form_process';
- var $formErrors = { msg : '', requiredFields : [] };
+ var $formData = $form.serialize() + '&action=wppb_form_process';
+ var $formErrors = { msg: '', requiredFields: [] };
- $('[data-required="true"]').each(function(index, element){
+ const targetForm = e.target;
+
+ $(targetForm.querySelectorAll('[data-required="true"]')).each(function (index, element) {
var $field = $(this);
var field_type = $field[0].type;
var $closestDiv = $field.closest('.wppb-form-field-wrap');
- if (field_type === 'switch' || field_type === 'radio'){
+ if (field_type === 'switch' || field_type === 'radio') {
$closestDiv.addClass('has-multi-input');
- }else{
- if (!$field.val()){
+ } else {
+ if (!$field.val()) {
$field.addClass('wppb-form-field-has-error');
$formErrors.requiredFields.push($field.data('label'));
- }else {
- if (field_type === 'email' && ! wppbFormValidateEmail($field.val()) ){
+ } else {
+ if (field_type === 'email' && !wppbFormValidateEmail($field.val())) {
$field.addClass('wppb-form-field-has-error');
$formErrors.requiredFields.push($field.data('label'));
- }else {
+ } else {
$field.removeClass('wppb-form-field-has-error');
}
}
}
});
- if ($('.has-multi-input').length){
- $('.has-multi-input').each(function(index, element){
+ if ($('.has-multi-input').length) {
+ $('.has-multi-input').each(function (index, element) {
var $that = $(this);
var $firstField = $that.find('input').first();
- if (! $that.find('input:checked').length){
+ if (!$that.find('input:checked').length) {
$formErrors.requiredFields.push($firstField.data('label'));
$that.addClass('wppb-form-field-has-error');
- }else {
+ } else {
var newIndex = $formErrors.requiredFields.indexOf($firstField.data('label'));
if (newIndex > -1) {
$formErrors.requiredFields.splice(newIndex, 1);
@@ -48,13 +50,13 @@
});
}
var ErrorMsg = '
';
-
- if ($formErrors.requiredFields.length){
+
+ if ($formErrors.requiredFields.length) {
ErrorMsg += 'Please, fill in the following fields:';
ErrorMsg += '
';
- $.each($formErrors.requiredFields, function(errorIndex, error ) {
- ErrorMsg += ''+error+' ';
+ $.each($formErrors.requiredFields, function (errorIndex, error) {
+ ErrorMsg += '' + error + ' ';
});
ErrorMsg += ' ';
@@ -70,37 +72,41 @@
$form.find('.wppb-form-msg').html('');
$form.find('.wppb-btn-forms').append('
');
},
- error: function(jqXHR, textStatus, errorThrown){
- $form.find('.wppb_form_response').html("
"+ textStatus+"("+jqXHR.status+")" +" : "+ errorThrown + "
");
+ error: function (jqXHR, textStatus, errorThrown) {
+ $form
+ .find('.wppb_form_response')
+ .html("
" + textStatus + '(' + jqXHR.status + ')' + ' : ' + errorThrown + '
');
},
- success: function (data, textStatus, jqXHR ) {
+ success: function (data, textStatus, jqXHR) {
if (data.data) {
if (data.success) {
$form.find('.wppb_form_response').html('
' + data.data.msg + '
');
- setTimeout(function(){
+ setTimeout(function () {
$form.find('.wppb_form_response').html('');
+ $form.find('.fa-spinner').remove();
}, 2000);
$form[0].reset();
if (data.data.enable_redirect_url) {
location.href = data.data.redirect_url;
}
- }else{
- $form.find('.wppb-form-msg').html('
'+data.data.msg+'
');
+ } else {
+ $form.find('.wppb-form-msg').html('
' + data.data.msg + '
');
}
}
},
- complete: function(jqXHR, textStatus){
+ complete: function (jqXHR, textStatus) {
$form.find('.fa.fa-spin.wppb-font-sync').remove();
- if (typeof grecaptcha !== 'undefined'){
+ if (typeof grecaptcha !== 'undefined') {
grecaptcha.reset();
}
- }
+ },
});
});
})(jQuery);
function wppbFormValidateEmail(email) {
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ var re =
+ /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());
}
\ No newline at end of file
diff --git a/addons/form/fields/checkbox.php b/addons/form/fields/checkbox.php
index 2d9c2a2..c11fcc4 100644
--- a/addons/form/fields/checkbox.php
+++ b/addons/form/fields/checkbox.php
@@ -7,12 +7,12 @@
$options = $field['checkbox_field_options'];
if (count($options)){
foreach ($options as $key => $option){
- $label_value = isset($option['label']) ? $option['label'] : '';
+ $label_value = isset($option['label']) ? sanitize_text_field( $option['label'] ) : '';
$label_name = 'wppb_default_form['.$fieldIndex.']['.$key.']';
?>
- >
-
+ >
+
- >
+ >
$option){
?>
-
+
diff --git a/addons/form/form.php b/addons/form/form.php
index d1362dc..56436e5 100644
--- a/addons/form/form.php
+++ b/addons/form/form.php
@@ -881,12 +881,12 @@ public function get_compatible_plugins(){
public function generateDefaultForm($data = array()){
$settings = $data['settings'];
$classlist = '';
- $form_type = isset($settings["form_type"]) ? $settings["form_type"] : '';
- $button_text = isset($settings["button_text"]) ? $settings["button_text"] : 'Submit Form';
- $icon_list = isset($settings["icon_list"]) ? $settings["icon_list"] : '';
- $icon_position = isset($settings["icon_position"]) ? $settings["icon_position"] : '';
- $textarea_resize = isset($settings["textarea_resize"]) ? $settings["textarea_resize"] : '';
- $fullwidth_button = isset($settings["fullwidth_button"]) ? $settings["fullwidth_button"] : '';
+ $form_type = isset($settings["form_type"]) ? sanitize_text_field( $settings["form_type"] ) : '';
+ $button_text = isset($settings["button_text"]) ? sanitize_text_field( $settings["button_text"] ) : 'Submit Form';
+ $icon_list = isset($settings["icon_list"]) ? sanitize_text_field( $settings["icon_list"] ) : '';
+ $icon_position = isset($settings["icon_position"]) ? sanitize_text_field( $settings["icon_position"] ) : '';
+ $textarea_resize = isset($settings["textarea_resize"]) ? sanitize_text_field( $settings["textarea_resize"] ) : '';
+ $fullwidth_button = isset($settings["fullwidth_button"]) ? sanitize_text_field( $settings["fullwidth_button"] ) : '';
$classlist .= (isset($fullwidth_button) && $fullwidth_button) ? ' wppb-btn-' . $fullwidth_button : '';
@@ -907,7 +907,7 @@ public function generateDefaultForm($data = array()){
ob_start();
if (is_array($input_items) && count($input_items)){
?>
-