PluginProbe
Survey Maker by AYS / 5.2.2.7
Survey Maker by AYS v5.2.2.7
5.2.4.1 5.2.4.0 5.2.3.9 5.2.3.8 5.2.3.7 5.2.3.6 5.2.3.5 5.2.3.4 5.2.3.3 5.2.3.2 5.2.3.1 5.2.3.0 5.2.2.9 5.2.2.8 5.2.2.7 5.2.2.6 5.2.2.5 5.2.2.4 5.2.2.3 5.2.2.2 5.2.2.1 5.2.2.0 5.2.1.9 5.2.1.8 5.2.0.8 All 154 releases
survey-maker / includes / class-survey-maker-data.php

class-survey-maker-data.php in Survey Maker by AYS 5.2.2.7, at includes/class-survey-maker-data.php

2,743 lines 163.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The public-facing functionality of the plugin.
4 *
5 * @link http://ays-pro.com/
6 * @since 1.0.0
7 *
8 * @package Survey_Maker
9 * @subpackage Survey_Maker/includes
10 */
11
12 /**
13 * The public-facing functionality of the plugin.
14 *
15 * Defines the plugin name, version, and two examples hooks for how to
16 * enqueue the public-facing stylesheet and JavaScript.
17 *
18 * @package Survey_Maker
19 * @subpackage Survey_Maker/includes
20 * @author AYS Pro LLC <[email protected]>
21 */
22 class Survey_Maker_Data {
23
24 public static function get_survey_validated_data_from_array( $survey, $attr ){
25 global $wpdb;
26
27 // Array for survey validated options
28 $settings = array();
29 $name_prefix = 'survey_';
30
31 // ID
32 $id = ( isset($attr['id']) ) ? absint( intval( $attr['id'] ) ) : null;
33 $settings['id'] = $id;
34
35 // Survey options
36 $options = array();
37 if( isset( $survey->options ) && $survey->options != '' ){
38 $options = json_decode( $survey->options, true );
39 }
40
41 $settings[ 'options' ] = $options;
42
43 $survey_answers_alignment_grid_types = array(
44 "space_around",
45 "space_between",
46 );
47
48 // ======================= // ======================= // ======================= // ======================= // ======================= //
49
50
51 // =============================================================
52 // ====================== Styles Tab =====================
53 // ======================== START ========================
54
55
56 // Survey Theme
57 $settings[ $name_prefix . 'theme' ] = (isset($options[ $name_prefix . 'theme' ]) && $options[ $name_prefix . 'theme' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'theme' ] ) ) : 'classic_light';
58 $settings[ $name_prefix . 'is_minimal' ] = $settings[ $name_prefix . 'theme' ] == 'minimal' ? true : false;
59 $settings[ $name_prefix . 'is_modern' ] = $settings[ $name_prefix . 'theme' ] == 'modern' ? true : false;
60 $settings[ $name_prefix . 'is_business' ] = false;
61 $settings[ $name_prefix . 'is_elegant' ] = false;
62
63 // Survey Color
64 $settings[ $name_prefix . 'color' ] = (isset($options[ $name_prefix . 'color' ]) && $options[ $name_prefix . 'color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'color' ] ) ) : '#ff5722'; // '#673ab7'
65
66 // Background color
67 $settings[ $name_prefix . 'background_color' ] = (isset($options[ $name_prefix . 'background_color' ]) && $options[ $name_prefix . 'background_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'background_color' ] ) ) : '#fff';
68
69 // Text Color
70 $settings[ $name_prefix . 'text_color' ] = (isset($options[ $name_prefix . 'text_color' ]) && $options[ $name_prefix . 'text_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'text_color' ] ) ) : '#333';
71
72 // Loader Color
73 $settings[ $name_prefix . 'loader_color' ] = (isset($options[ $name_prefix . 'loader_color' ]) && $options[ $name_prefix . 'loader_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'loader_color' ] ) ) : $settings[ $name_prefix . 'text_color' ];
74
75 // Buttons text Color
76 $settings[ $name_prefix . 'buttons_text_color' ] = (isset($options[ $name_prefix . 'buttons_text_color' ]) && $options[ $name_prefix . 'buttons_text_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'buttons_text_color' ] ) ) : $settings[ $name_prefix . 'text_color' ];
77
78 // Width
79 $settings[ $name_prefix . 'width' ] = (isset($options[ $name_prefix . 'width' ]) && $options[ $name_prefix . 'width' ] != '') ? absint ( intval( $options[ $name_prefix . 'width' ] ) ) : '';
80
81 // Survey Width by percentage or pixels
82 $settings[ $name_prefix . 'width_by_percentage_px' ] = (isset($options[ $name_prefix . 'width_by_percentage_px' ]) && $options[ $name_prefix . 'width_by_percentage_px' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'width_by_percentage_px' ] ) ) : 'pixels';
83
84 // Mobile width
85 $settings[ $name_prefix . 'mobile_width' ] = (isset($options[ $name_prefix . 'mobile_width' ]) && $options[ $name_prefix . 'mobile_width' ] != '') ? absint ( intval( $options[ $name_prefix . 'mobile_width' ] ) ) : '';
86
87 // Survey mobile width by percentage or pixels
88 $settings[ $name_prefix . 'mobile_width_by_percent_px' ] = (isset($options[ $name_prefix . 'mobile_width_by_percent_px' ]) && $options[ $name_prefix . 'mobile_width_by_percent_px' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'mobile_width_by_percent_px' ] ) ) : 'pixels';
89
90 // Survey container max width
91 $settings[ $name_prefix . 'mobile_max_width' ] = (isset($options[ $name_prefix . 'mobile_max_width' ]) && $options[ $name_prefix . 'mobile_max_width' ] != '') ? absint ( intval( $options[ $name_prefix . 'mobile_max_width' ] ) ) : '';
92
93 // Custom class for survey container
94 $settings[ $name_prefix . 'custom_class' ] = (isset($options[ $name_prefix . 'custom_class' ]) && $options[ $name_prefix . 'custom_class' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'custom_class' ] ) ) : '';
95
96 // Custom CSS
97 $settings[ $name_prefix . 'custom_css' ] = (isset($options[ $name_prefix . 'custom_css' ]) && $options[ $name_prefix . 'custom_css' ] != '') ? stripslashes ( html_entity_decode( $options[ $name_prefix . 'custom_css' ] ) ) : '';
98
99 // Survey logo
100 $settings[ $name_prefix . 'logo' ] = (isset($options[ $name_prefix . 'logo' ]) && $options[ $name_prefix . 'logo' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'logo' ] ) ) : '';
101
102 // Survey logo position
103 $settings[ $name_prefix . 'logo_image_position' ] = (isset($options[ $name_prefix . 'logo_image_position' ]) && $options[ $name_prefix . 'logo_image_position' ] != '') ? esc_attr( $options[ $name_prefix . 'logo_image_position' ] ) : 'right';
104 // Survey logo position mobile
105 $options[ $name_prefix . 'logo_image_position_mobile' ] = isset($options[ $name_prefix . 'logo_image_position_mobile' ]) ? $options[ $name_prefix . 'logo_image_position_mobile' ] : $settings[ $name_prefix . 'logo_image_position' ];
106 $settings[ $name_prefix . 'logo_image_position_mobile' ] = (isset($options[ $name_prefix . 'logo_image_position_mobile' ]) && $options[ $name_prefix . 'logo_image_position_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'logo_image_position_mobile' ] ) : 'right';
107
108 // Survey logo title
109 $settings[ $name_prefix . 'logo_title' ] = (isset($options[ $name_prefix . 'logo_title' ]) && $options[ $name_prefix . 'logo_title' ] != '') ? esc_attr( $options[ $name_prefix . 'logo_title' ] ) : '';
110
111 // Survey cover photo
112 $settings[ $name_prefix . 'cover_photo' ] = (isset($options[ $name_prefix . 'cover_photo' ]) && $options[ $name_prefix . 'cover_photo' ] != '') ? stripslashes( esc_attr( $options[ $name_prefix . 'cover_photo' ] ) ) : '';
113
114 // Survey cover photo height
115 $settings[ $name_prefix . 'cover_photo_height' ] = (isset($options[ $name_prefix . 'cover_photo_height' ]) && $options[ $name_prefix . 'cover_photo_height' ] != '') ? esc_attr( $options[ $name_prefix . 'cover_photo_height' ] ) : 150;
116
117 // Survey cover photo mobile height
118 $settings[ $name_prefix . 'cover_photo_mobile_height' ] = (isset($options[ $name_prefix . 'cover_photo_mobile_height' ]) && $options[ $name_prefix . 'cover_photo_mobile_height' ] != '') ? esc_attr( $options[ $name_prefix . 'cover_photo_mobile_height' ] ) : $settings[ $name_prefix . 'cover_photo_height' ];
119
120 // Survey cover photo position
121 $settings[ $name_prefix . 'cover_photo_position' ] = (isset($options[ $name_prefix . 'cover_photo_position' ]) && $options[ $name_prefix . 'cover_photo_position' ] != '') ? esc_attr( $options[ $name_prefix . 'cover_photo_position' ] ) : "center_center";
122
123 // Survey cover photo object fit
124 $settings[ $name_prefix . 'cover_photo_object_fit' ] = (isset($options[ $name_prefix . 'cover_photo_object_fit' ]) && $options[ $name_prefix . 'cover_photo_object_fit' ] != '') ? esc_attr( $options[ $name_prefix . 'cover_photo_object_fit' ] ) : "cover";
125
126 // Survey cover only first section
127 $settings[ $name_prefix . 'cover_only_first_section' ] = (isset($options[ $name_prefix . 'cover_only_first_section' ]) && $options[ $name_prefix . 'cover_only_first_section' ] == 'on') ? true : false;
128
129 // Survey title alignment
130 $settings[ $name_prefix . 'title_alignment' ] = (isset( $options[ $name_prefix . 'title_alignment' ] ) && $options[ $name_prefix . 'title_alignment' ] != '') ? esc_attr( $options[ $name_prefix . 'title_alignment' ] ) : 'left';
131
132 // Survey title alignment mobile
133 $options[ $name_prefix . 'title_alignment_mobile' ] = isset( $options[ $name_prefix . 'title_alignment_mobile' ] ) ? $options[ $name_prefix . 'title_alignment_mobile' ] : $settings[ $name_prefix . 'title_alignment' ];
134 $settings[ $name_prefix . 'title_alignment_mobile' ] = (isset( $options[ $name_prefix . 'title_alignment_mobile' ] ) && $options[ $name_prefix . 'title_alignment_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'title_alignment_mobile' ] ) : 'left';
135
136 // Survey title font size
137 $settings[ $name_prefix . 'title_font_size' ] = (isset( $options[ $name_prefix . 'title_font_size' ] ) && $options[ $name_prefix . 'title_font_size' ] != '' && $options[ $name_prefix . 'title_font_size' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'title_font_size' ] ) : 30;
138
139 // Survey title letter spacing
140 $settings[ $name_prefix . 'title_letter_spacing' ] = (isset( $options[ $name_prefix . 'title_letter_spacing' ] ) && $options[ $name_prefix . 'title_letter_spacing' ] != '' && $options[ $name_prefix . 'title_letter_spacing' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'title_letter_spacing' ] ) : 0;
141
142 // Survey title letter spacing mobile
143 $settings[ $name_prefix . 'title_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'title_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'title_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'title_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'title_letter_spacing_mobile' ] ) : $settings[ $name_prefix . 'title_letter_spacing' ];
144
145 // Survey title font size mobile
146 $settings[ $name_prefix . 'title_font_size_for_mobile' ] = (isset( $options[ $name_prefix . 'title_font_size_for_mobile' ] ) && $options[ $name_prefix . 'title_font_size_for_mobile' ] != '' && $options[ $name_prefix . 'title_font_size_for_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'title_font_size_for_mobile' ] ) : 30;
147
148 // Survey title box shadow
149 $settings[ $name_prefix . 'title_box_shadow_enable' ] = (isset( $options[ $name_prefix . 'title_box_shadow_enable' ] ) && $options[ $name_prefix . 'title_box_shadow_enable' ] == 'on' ) ? true : false;
150
151 // === Survey title box shadow offsets start ===
152 // Survey title box shadow offset x
153 $settings[ $name_prefix . 'title_text_shadow_x_offset' ] = ( isset($options[ $name_prefix . 'title_text_shadow_x_offset' ] ) && $options[ $name_prefix . 'title_text_shadow_x_offset' ] != "") ? esc_attr($options[ $name_prefix . 'title_text_shadow_x_offset' ]) : 0;
154 // Survey title box shadow offset y
155 $settings[ $name_prefix . 'title_text_shadow_y_offset' ] = ( isset($options[ $name_prefix . 'title_text_shadow_y_offset' ] ) && $options[ $name_prefix . 'title_text_shadow_y_offset' ] != "") ? esc_attr($options[ $name_prefix . 'title_text_shadow_y_offset' ]) : 0;
156 // Survey title box shadow offset z
157 $settings[ $name_prefix . 'title_text_shadow_z_offset' ] = ( isset($options[ $name_prefix . 'title_text_shadow_z_offset' ] ) && $options[ $name_prefix . 'title_text_shadow_z_offset' ] != "") ? esc_attr($options[ $name_prefix . 'title_text_shadow_z_offset' ]) : 10;
158 // === Survey title box shadow offsets end ===
159
160 // Survey title box shadow color
161 $settings[ $name_prefix . 'title_box_shadow_color' ] = (isset( $options[ $name_prefix . 'title_box_shadow_color' ] ) && $options[ $name_prefix . 'title_box_shadow_color' ] != '' ) ? esc_attr( $options[ $name_prefix . 'title_box_shadow_color' ] ) : '#333';
162
163 // Survey section title font size PC
164 $settings[ $name_prefix . 'section_title_font_size' ] = (isset( $options[ $name_prefix . 'section_title_font_size' ] ) && $options[ $name_prefix . 'section_title_font_size' ] != '' && $options[ $name_prefix . 'section_title_font_size' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_title_font_size' ] ) : 32;
165 // Survey section title font size Mobile
166 $settings[ $name_prefix . 'section_title_font_size_mobile' ] = (isset( $options[ $name_prefix . 'section_title_font_size_mobile' ] ) && $options[ $name_prefix . 'section_title_font_size_mobile' ] != '' && $options[ $name_prefix . 'section_title_font_size_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_title_font_size_mobile' ] ) : 32;
167
168 // Survey section title alignment
169 $settings[ $name_prefix . 'section_title_alignment' ] = (isset( $options[ $name_prefix . 'section_title_alignment' ] ) && $options[ $name_prefix . 'section_title_alignment' ] != '') ? esc_attr( $options[ $name_prefix . 'section_title_alignment' ] ) : 'left';
170
171 // Survey section title alignment mobile
172 $options[ $name_prefix . 'section_title_alignment_mobile' ] = isset($options[ $name_prefix . 'section_title_alignment_mobile' ]) ? $options[ $name_prefix . 'section_title_alignment_mobile' ] : $settings[ $name_prefix . 'section_title_alignment' ];
173 $settings[ $name_prefix . 'section_title_alignment_mobile' ] = (isset( $options[ $name_prefix . 'section_title_alignment_mobile' ] ) && $options[ $name_prefix . 'section_title_alignment_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'section_title_alignment_mobile' ] ) : 'left';
174
175 // Survey section title letter spacing
176 $settings[ $name_prefix . 'section_title_letter_spacing' ] = (isset( $options[ $name_prefix . 'section_title_letter_spacing' ] ) && $options[ $name_prefix . 'section_title_letter_spacing' ] != '' && $options[ $name_prefix . 'section_title_letter_spacing' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_title_letter_spacing' ] ) : 0;
177
178 // Survey section title letter spacing mobile
179 $settings[ $name_prefix . 'section_title_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'section_title_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'section_title_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'section_title_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_title_letter_spacing_mobile' ] ) : $settings[ $name_prefix . 'section_title_letter_spacing' ];
180
181 // Survey section description alignment
182 $settings[ $name_prefix . 'section_description_alignment' ] = (isset( $options[ $name_prefix . 'section_description_alignment' ] ) && $options[ $name_prefix . 'section_description_alignment' ] != '') ? esc_attr( $options[ $name_prefix . 'section_description_alignment' ] ) : 'left';
183 // Survey section description alignment mobile
184 $options[ $name_prefix . 'section_description_alignment_mobile' ] = isset($options[ $name_prefix . 'section_description_alignment_mobile' ]) ? $options[ $name_prefix . 'section_description_alignment_mobile' ] : $settings[ $name_prefix . 'section_description_alignment' ];
185 $settings[ $name_prefix . 'section_description_alignment_mobile' ] = (isset( $options[ $name_prefix . 'section_description_alignment_mobile' ] ) && $options[ $name_prefix . 'section_description_alignment_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'section_description_alignment_mobile' ] ) : 'left';
186
187 // Survey section description font size
188 $settings[ $name_prefix . 'section_description_font_size' ] = (isset( $options[ $name_prefix . 'section_description_font_size' ] ) && $options[ $name_prefix . 'section_description_font_size' ] != '' && $options[ $name_prefix . 'section_description_font_size' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_description_font_size' ] ) : 14;
189
190 // Survey section description font size mobile
191 $settings[ $name_prefix . 'section_description_font_size_mobile' ] = (isset( $options[ $name_prefix . 'section_description_font_size_mobile' ] ) && $options[ $name_prefix . 'section_description_font_size_mobile' ] != '' && $options[ $name_prefix . 'section_description_font_size_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_description_font_size_mobile' ] ) : 14;
192
193 // Survey section description letter spacing
194 $settings[ $name_prefix . 'section_description_letter_spacing' ] = (isset( $options[ $name_prefix . 'section_description_letter_spacing' ] ) && $options[ $name_prefix . 'section_description_letter_spacing' ] != '' && $options[ $name_prefix . 'section_description_letter_spacing' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_description_letter_spacing' ] ) : 0;
195
196 // Survey section description letter spacing mobile
197 $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] = isset($options[ $name_prefix . 'section_description_letter_spacing_mobile' ]) ? $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] : $settings[ $name_prefix . 'section_description_letter_spacing' ];
198 $settings[ $name_prefix . 'section_description_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'section_description_letter_spacing_mobile' ] ) : 0;
199
200 // =========== Questions Styles Start ===========
201
202 // Question font size
203 $settings[ $name_prefix . 'question_font_size' ] = (isset($options[ $name_prefix . 'question_font_size' ]) && $options[ $name_prefix . 'question_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_font_size' ] ) ) : 16;
204
205 // Question font size mobile
206 $settings[ $name_prefix . 'question_font_size_mobile' ] = (isset($options[ $name_prefix . 'question_font_size_mobile' ]) && $options[ $name_prefix . 'question_font_size_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_font_size_mobile' ] ) ) : 16;
207
208 // Question title alignment
209 $settings[ $name_prefix . 'question_title_alignment' ] = (isset($options[ $name_prefix . 'question_title_alignment' ]) && $options[ $name_prefix . 'question_title_alignment' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_title_alignment' ] ) ) : 'left';
210
211 // Question Image Width
212 $settings[ $name_prefix . 'question_image_width' ] = (isset($options[ $name_prefix . 'question_image_width' ]) && $options[ $name_prefix . 'question_image_width' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_image_width' ] ) ) : '';
213 // Question Image Width mobile
214 $options[ $name_prefix . 'question_image_width_mobile' ] = isset($options[ $name_prefix . 'question_image_width_mobile' ]) ? $options[ $name_prefix . 'question_image_width_mobile' ] : $settings[ $name_prefix . 'question_image_width' ];
215 $settings[ $name_prefix . 'question_image_width_mobile' ] = (isset($options[ $name_prefix . 'question_image_width_mobile' ]) && $options[ $name_prefix . 'question_image_width_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_image_width_mobile' ] ) ) : '';
216
217 // Question Image Height
218 $settings[ $name_prefix . 'question_image_height' ] = (isset($options[ $name_prefix . 'question_image_height' ]) && $options[ $name_prefix . 'question_image_height' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_image_height' ] ) ) : '';
219 // Question Image Height mobile
220 $options[ $name_prefix . 'question_image_height_mobile' ] = isset($options[ $name_prefix . 'question_image_height_mobile' ]) ? $options[ $name_prefix . 'question_image_height_mobile' ] : $settings[ $name_prefix . 'question_image_height' ];
221 $settings[ $name_prefix . 'question_image_height_mobile' ] = (isset($options[ $name_prefix . 'question_image_height_mobile' ]) && $options[ $name_prefix . 'question_image_height_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_image_height_mobile' ] ) ) : '';
222
223 // Question Image sizing
224 $settings[ $name_prefix . 'question_image_sizing' ] = (isset($options[ $name_prefix . 'question_image_sizing' ]) && $options[ $name_prefix . 'question_image_sizing' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_image_sizing' ] ) ) : 'cover';
225 // Question Image sizing mobile
226 $options[ $name_prefix . 'question_image_sizing_mobile' ] = isset($options[ $name_prefix . 'question_image_sizing_mobile' ]) ? $options[ $name_prefix . 'question_image_sizing_mobile' ] : $settings[ $name_prefix . 'question_image_sizing' ];
227 $settings[ $name_prefix . 'question_image_sizing_mobile' ] = (isset($options[ $name_prefix . 'question_image_sizing_mobile' ]) && $options[ $name_prefix . 'question_image_sizing_mobile' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_image_sizing_mobile' ] ) ) : 'cover';
228
229 // Question padding
230 $settings[ $name_prefix . 'question_padding' ] = (isset($options[ $name_prefix . 'question_padding' ]) && $options[ $name_prefix . 'question_padding' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_padding' ] ) ) : 24;
231
232 // Question padding mobile
233 $options[ $name_prefix . 'question_padding_mobile' ] = isset($options[ $name_prefix . 'question_padding_mobile' ]) ? $options[ $name_prefix . 'question_padding_mobile' ] : $settings[ $name_prefix . 'question_padding' ];
234 $settings[ $name_prefix . 'question_padding_mobile' ] = (isset($options[ $name_prefix . 'question_padding_mobile' ]) && $options[ $name_prefix . 'question_padding_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_padding_mobile' ] ) ) : 24;
235
236 // Question border radius
237 $settings[ $name_prefix . 'question_border_radius' ] = (isset($options[ $name_prefix . 'question_border_radius' ]) && $options[ $name_prefix . 'question_border_radius' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_border_radius' ] ) ) : 8;
238
239 // Question border radius mobile
240 $options[ $name_prefix . 'question_border_radius_mobile' ] = isset($options[ $name_prefix . 'question_border_radius_mobile' ]) ? $options[ $name_prefix . 'question_border_radius_mobile' ] : $settings[ $name_prefix . 'question_border_radius' ];
241 $settings[ $name_prefix . 'question_border_radius_mobile' ] = (isset($options[ $name_prefix . 'question_border_radius_mobile' ]) && $options[ $name_prefix . 'question_border_radius_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_border_radius_mobile' ] ) ) : 8;
242
243 // Question caption text color
244 $settings[ $name_prefix . 'question_caption_text_color' ] = (isset($options[ $name_prefix . 'question_caption_text_color' ]) && $options[ $name_prefix . 'question_caption_text_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_caption_text_color' ] ) ) : $settings[ $name_prefix . 'text_color' ];
245 // Question caption text color mobile
246 $options[ $name_prefix . 'question_caption_text_color_mobile' ] = (isset($options[ $name_prefix . 'question_caption_text_color_mobile' ])) ? $options[ $name_prefix . 'question_caption_text_color_mobile' ] : $settings[ $name_prefix . 'question_caption_text_color' ];
247 $settings[ $name_prefix . 'question_caption_text_color_mobile' ] = (isset($options[ $name_prefix . 'question_caption_text_color_mobile' ]) && $options[ $name_prefix . 'question_caption_text_color_mobile' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_caption_text_color_mobile' ] ) ) : $settings[ $name_prefix . 'text_color' ];
248
249 // Question caption text alignment
250 $settings[ $name_prefix . 'question_caption_text_alignment' ] = (isset($options[ $name_prefix . 'question_caption_text_alignment' ]) && $options[ $name_prefix . 'question_caption_text_alignment' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_caption_text_alignment' ] ) ) : 'center';
251
252 // Question caption text alignment on mobile
253 $options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ] = isset($options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ]) ? $options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ] : $settings[ $name_prefix . 'question_caption_text_alignment' ];
254 $settings[ $name_prefix . 'question_caption_text_alignment_on_mobile' ] = (isset($options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ]) && $options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'question_caption_text_alignment_on_mobile' ] ) ) : 'center';
255
256 // Question caption font size
257 $settings[ $name_prefix . 'question_caption_font_size' ] = (isset($options[ $name_prefix . 'question_caption_font_size' ]) && $options[ $name_prefix . 'question_caption_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_caption_font_size' ] ) ) : 16;
258
259 // Question caption font size on mobile
260 $options[ $name_prefix . 'question_caption_font_size_on_mobile' ] = isset($options[ $name_prefix . 'question_caption_font_size_on_mobile' ]) ? $options[ $name_prefix . 'question_caption_font_size_on_mobile' ] : $settings[ $name_prefix . 'question_caption_font_size' ];
261 $settings[ $name_prefix . 'question_caption_font_size_on_mobile' ] = (isset($options[ $name_prefix . 'question_caption_font_size_on_mobile' ]) && $options[ $name_prefix . 'question_caption_font_size_on_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_caption_font_size_on_mobile' ] ) ) : 16;
262
263 // Question caption text transform
264 $settings[ $name_prefix . 'question_caption_text_transform' ] = (isset($options[ $name_prefix . 'question_caption_text_transform' ]) && $options[ $name_prefix . 'question_caption_text_transform' ] != '') ? esc_attr ( $options[ $name_prefix . 'question_caption_text_transform' ] ) : 'none';
265 // Question caption text transform mobile
266 $options[ $name_prefix . 'question_caption_text_transform_mobile' ] = isset($options[ $name_prefix . 'question_caption_text_transform_mobile' ]) ? $options[ $name_prefix . 'question_caption_text_transform_mobile' ] : $settings[ $name_prefix . 'question_caption_text_transform' ];
267 $settings[ $name_prefix . 'question_caption_text_transform_mobile' ] = (isset($options[ $name_prefix . 'question_caption_text_transform_mobile' ]) && $options[ $name_prefix . 'question_caption_text_transform_mobile' ] != '') ? esc_attr ( $options[ $name_prefix . 'question_caption_text_transform_mobile' ] ) : 'none';
268
269 // Question caption letter spacing
270 $settings[ $name_prefix . 'question_caption_letter_spacing' ] = (isset($options[ $name_prefix . 'question_caption_letter_spacing' ]) && $options[ $name_prefix . 'question_caption_letter_spacing' ] != '') ? absint ( intval( $options[ $name_prefix . 'question_caption_letter_spacing' ] ) ) : 0;
271
272 // Question caption letter spacing mobile
273 $settings[ $name_prefix . 'question_caption_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'question_caption_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'question_caption_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'question_caption_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'question_caption_letter_spacing_mobile' ] ) : $settings[ $name_prefix . 'question_caption_letter_spacing' ];
274
275 // Question caption hide on mobile
276 $settings[ $name_prefix . 'question_caption_hide_on_mobile' ] = (isset($options[ $name_prefix . 'question_caption_hide_on_mobile' ]) && $options[ $name_prefix . 'question_caption_hide_on_mobile' ] == 'on') ? true : false;
277
278 // =========== Questions Styles End ===========
279
280
281 // =========== Answers Styles Start ===========
282
283 // Answer font size
284 $settings[ $name_prefix . 'answer_font_size' ] = (isset($options[ $name_prefix . 'answer_font_size' ]) && $options[ $name_prefix . 'answer_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'answer_font_size' ] ) ) : 15;
285
286 // Answer font size mobile
287 $settings[ $name_prefix . 'answer_font_size_on_mobile' ] = (isset($options[ $name_prefix . 'answer_font_size_on_mobile' ]) && $options[ $name_prefix . 'answer_font_size_on_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'answer_font_size_on_mobile' ] ) ) : 15;
288
289 // Answer letter spacing
290 $settings[ $name_prefix . 'answer_letter_spacing' ] = (isset($options[ $name_prefix . 'answer_letter_spacing' ]) && $options[ $name_prefix . 'answer_letter_spacing' ] != '') ? absint ( intval( $options[ $name_prefix . 'answer_letter_spacing' ] ) ) : 0;
291
292 // Answer letter spacing mobile
293 $options[ $name_prefix . 'answer_letter_spacing_mobile' ] = isset($options[ $name_prefix . 'answer_letter_spacing_mobile' ]) ? $options[ $name_prefix . 'answer_letter_spacing_mobile' ] : $settings[ $name_prefix . 'answer_letter_spacing' ];
294 $settings[ $name_prefix . 'answer_letter_spacing_mobile' ] = (isset($options[ $name_prefix . 'answer_letter_spacing_mobile' ]) && $options[ $name_prefix . 'answer_letter_spacing_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'answer_letter_spacing_mobile' ] ) ) : 0;
295
296 // Answer view
297 $settings[ $name_prefix . 'answers_view' ] = (isset($options[ $name_prefix . 'answers_view' ]) && $options[ $name_prefix . 'answers_view' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'answers_view' ] ) ) : 'list';
298
299 // Answer view alignment
300 $settings[ $name_prefix . 'answers_view_alignment' ] = (isset($options[ $name_prefix . 'answers_view_alignment' ]) && $options[ $name_prefix . 'answers_view_alignment' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'answers_view_alignment' ] ) ) : 'space-around';
301 $settings[ $name_prefix . 'answers_view_alignment' ] = ($settings[ $name_prefix . 'answers_view' ] == 'list' && in_array($settings[ $name_prefix . 'answers_view_alignment' ] , $survey_answers_alignment_grid_types)) ? 'flex-start' : $settings[ $name_prefix . 'answers_view_alignment' ];
302
303 // Answer object-fit
304 $settings[ $name_prefix . 'answers_object_fit' ] = (isset($options[ $name_prefix . 'answers_object_fit' ]) && $options[ $name_prefix . 'answers_object_fit' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'answers_object_fit' ] ) ) : 'cover';
305 // Answer object-fit
306 $settings[ $name_prefix . 'answers_object_fit_mobile' ] = (isset($options[ $name_prefix . 'answers_object_fit_mobile' ]) && $options[ $name_prefix . 'answers_object_fit_mobile' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'answers_object_fit_mobile' ] ) ) : 'cover';
307
308 // Answer padding
309 $settings[ $name_prefix . 'answers_padding' ] = (isset($options[ $name_prefix . 'answers_padding' ]) && $options[ $name_prefix . 'answers_padding' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_padding' ] ) ) : 8;
310
311 // Answer padding mobile
312 $options[ $name_prefix . 'answers_padding_mobile' ] = isset($options[ $name_prefix . 'answers_padding_mobile' ]) ? $options[ $name_prefix . 'answers_padding_mobile' ] : $settings[ $name_prefix . 'answers_padding' ];
313 $settings[ $name_prefix . 'answers_padding_mobile' ] = (isset($options[ $name_prefix . 'answers_padding_mobile' ]) && $options[ $name_prefix . 'answers_padding_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_padding_mobile' ] ) ) : 8;
314
315 // Answer Gap
316 $settings[ $name_prefix . 'answers_gap' ] = (isset($options[ $name_prefix . 'answers_gap' ]) && $options[ $name_prefix . 'answers_gap' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_gap' ] ) ) : 0;
317
318 // Answer Gap mobile
319 $options[ $name_prefix . 'answers_gap_mobile' ] = isset($options[ $name_prefix . 'answers_gap_mobile' ]) ? $options[ $name_prefix . 'answers_gap_mobile' ] : $options[ $name_prefix . 'answers_gap' ];
320 $settings[ $name_prefix . 'answers_gap_mobile' ] = (isset($options[ $name_prefix . 'answers_gap_mobile' ]) && $options[ $name_prefix . 'answers_gap_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_gap_mobile' ] ) ) : 0;
321
322 // Answer image size
323 $settings[ $name_prefix . 'answers_image_size' ] = (isset($options[ $name_prefix . 'answers_image_size' ]) && $options[ $name_prefix . 'answers_image_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_image_size' ] ) ) : 195;
324 // Answer image size mobile
325 $settings[ $name_prefix . 'answers_image_size_mobile' ] = (isset($options[ $name_prefix . 'answers_image_size_mobile' ]) && $options[ $name_prefix . 'answers_image_size_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'answers_image_size_mobile' ] ) ) : 195;
326
327
328 // =========== Answers Styles End ===========
329
330
331 // =========== Buttons Styles Start ===========
332
333 // Buttons background color
334 $settings[ $name_prefix . 'buttons_bg_color' ] = (isset($options[ $name_prefix . 'buttons_bg_color' ]) && $options[ $name_prefix . 'buttons_bg_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'buttons_bg_color' ] ) ) : '#fff';
335
336 // Buttons size
337 $settings[ $name_prefix . 'buttons_size' ] = (isset($options[ $name_prefix . 'buttons_size' ]) && $options[ $name_prefix . 'buttons_size' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'buttons_size' ] ) ) : 'medium';
338
339 // Buttons font size
340 $settings[ $name_prefix . 'buttons_font_size' ] = (isset($options[ $name_prefix . 'buttons_font_size' ]) && $options[ $name_prefix . 'buttons_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_font_size' ] ) ) : 14;
341
342 // Buttons mobile font size
343 $settings[ $name_prefix . 'buttons_mobile_font_size' ] = (isset($options[ $name_prefix . 'buttons_mobile_font_size' ]) && $options[ $name_prefix . 'buttons_mobile_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_mobile_font_size' ] ) ) : $settings[ $name_prefix . 'buttons_font_size' ];
344
345 // Buttons Left / Right padding
346 $settings[ $name_prefix . 'buttons_left_right_padding' ] = (isset($options[ $name_prefix . 'buttons_left_right_padding' ]) && $options[ $name_prefix . 'buttons_left_right_padding' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_left_right_padding' ] ) ) : 24;
347
348 // Buttons Top / Bottom padding
349 $settings[ $name_prefix . 'buttons_top_bottom_padding' ] = (isset($options[ $name_prefix . 'buttons_top_bottom_padding' ]) && $options[ $name_prefix . 'buttons_top_bottom_padding' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_top_bottom_padding' ] ) ) : 0;
350
351 // Buttons border radius
352 $settings[ $name_prefix . 'buttons_border_radius' ] = (isset($options[ $name_prefix . 'buttons_border_radius' ]) && $options[ $name_prefix . 'buttons_border_radius' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_border_radius' ] ) ) : 4;
353 // Buttons border radius mobile
354 $options[ $name_prefix . 'buttons_border_radius_mobile' ] = isset($options[ $name_prefix . 'buttons_border_radius_mobile' ]) ? $options[ $name_prefix . 'buttons_border_radius_mobile' ] : $settings[ $name_prefix . 'buttons_border_radius' ];
355 $settings[ $name_prefix . 'buttons_border_radius_mobile' ] = (isset($options[ $name_prefix . 'buttons_border_radius_mobile' ]) && $options[ $name_prefix . 'buttons_border_radius_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_border_radius_mobile' ] ) ) : 4;
356
357 // Buttons alignment
358 $settings[ $name_prefix . 'buttons_alignment' ] = (isset($options[ $name_prefix . 'buttons_alignment' ]) && $options[ $name_prefix . 'buttons_alignment' ] != '') ? esc_attr( $options[ $name_prefix . 'buttons_alignment' ] ) : 'left';
359 // Buttons alignment mobile
360 $options[ $name_prefix . 'buttons_alignment_mobile' ] = isset($options[ $name_prefix . 'buttons_alignment_mobile' ]) ? $options[ $name_prefix . 'buttons_alignment_mobile' ] : $settings[ $name_prefix . 'buttons_alignment' ];
361 $settings[ $name_prefix . 'buttons_alignment_mobile' ] = (isset($options[ $name_prefix . 'buttons_alignment_mobile' ]) && $options[ $name_prefix . 'buttons_alignment_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'buttons_alignment_mobile' ] ) : 'left';
362
363 // Buttons top distance
364 $settings[ $name_prefix . 'buttons_top_distance' ] = (isset($options[ $name_prefix . 'buttons_top_distance' ]) && $options[ $name_prefix . 'buttons_top_distance' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_top_distance' ] ) ) : 10;
365 // Buttons top distance mobile
366 $options[ $name_prefix . 'buttons_top_distance_mobile' ] = isset($options[ $name_prefix . 'buttons_top_distance_mobile' ]) ? $options[ $name_prefix . 'buttons_top_distance_mobile' ] : $settings[ $name_prefix . 'buttons_top_distance' ];
367 $settings[ $name_prefix . 'buttons_top_distance_mobile' ] = (isset($options[ $name_prefix . 'buttons_top_distance_mobile' ]) && $options[ $name_prefix . 'buttons_top_distance_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'buttons_top_distance_mobile' ] ) ) : 10;
368
369 // Buttons text letter spacing
370 $settings[ $name_prefix . 'buttons_text_letter_spacing' ] = (isset( $options[ $name_prefix . 'buttons_text_letter_spacing' ] ) && $options[ $name_prefix . 'buttons_text_letter_spacing' ] != '' && $options[ $name_prefix . 'buttons_text_letter_spacing' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'buttons_text_letter_spacing' ] ) : 0;
371
372 // Buttons text letter spacing mobile
373 $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] = isset( $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] ) ? $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] : $settings[ $name_prefix . 'buttons_text_letter_spacing' ];
374 $settings[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'buttons_text_letter_spacing_mobile' ] ) : 0;
375
376 // =========== Buttons Styles End ===========
377
378
379 // =============================================================
380 // ====================== Styles Tab =====================
381 // ======================== END ========================
382
383
384 // ======================= // ======================= // ======================= // ======================= // ======================= //
385
386 // =============================================================
387 // ===================== Start page Tab ======================
388 // ======================== START =========================
389
390
391 // Enable start page
392 $options[ $name_prefix . 'enable_start_page' ] = isset($options[ $name_prefix . 'enable_start_page' ]) ? $options[ $name_prefix . 'enable_start_page' ] : 'off';
393 $settings[ $name_prefix . 'enable_start_page' ] = (isset($options[ $name_prefix . 'enable_start_page' ]) && $options[ $name_prefix . 'enable_start_page' ] == 'on') ? true : false;
394
395 // Start page title
396 $settings[ $name_prefix . 'start_page_title' ] = (isset($options[ $name_prefix . 'start_page_title' ]) && $options[ $name_prefix . 'start_page_title' ] != '') ? stripslashes( $options[ $name_prefix . 'start_page_title' ] ) : '';
397
398 // Start page title position
399 $settings[ $name_prefix . 'start_page_title_pos' ] = (isset($options[ $name_prefix . 'start_page_title_pos' ]) && $options[ $name_prefix . 'start_page_title_pos' ] != '') ? stripslashes( $options[ $name_prefix . 'start_page_title_pos' ] ) : 'center';
400 // Start button position mobile
401 $options[ $name_prefix . 'start_page_title_pos_mobile' ] = isset($options[ $name_prefix . 'start_page_title_pos_mobile' ]) ? $options[ $name_prefix . 'start_page_title_pos_mobile' ] : $settings[ $name_prefix . 'start_page_title_pos' ];
402 $settings[ $name_prefix . 'start_page_title_pos_mobile' ] = (isset($options[ $name_prefix . 'start_page_title_pos_mobile' ]) && $options[ $name_prefix . 'start_page_title_pos_mobile' ] != '') ? stripslashes( $options[ $name_prefix . 'start_page_title_pos_mobile' ] ) : 'center';
403
404 // Start page description
405 $settings[ $name_prefix . 'start_page_description' ] = (isset($options[ $name_prefix . 'start_page_description' ]) && $options[ $name_prefix . 'start_page_description' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'start_page_description' ] ) ) : '';
406
407 // Start button position
408 $settings[ $name_prefix . 'start_page_button_pos' ] = (isset($options[ $name_prefix . 'start_page_button_pos' ]) && $options[ $name_prefix . 'start_page_button_pos' ] != '') ? stripslashes( $options[ $name_prefix . 'start_page_button_pos' ] ) : 'left';
409 // Start button position mobile
410 $options[ $name_prefix . 'start_page_button_pos_mobile' ] = isset($options[ $name_prefix . 'start_page_button_pos_mobile' ]) ? $options[ $name_prefix . 'start_page_button_pos_mobile' ] : $settings[ $name_prefix . 'start_page_button_pos' ];
411 $settings[ $name_prefix . 'start_page_button_pos_mobile' ] = (isset($options[ $name_prefix . 'start_page_button_pos_mobile' ]) && $options[ $name_prefix . 'start_page_button_pos_mobile' ] != '') ? stripslashes( $options[ $name_prefix . 'start_page_button_pos_mobile' ] ) : 'left';
412
413 // Start page Background color
414 $settings[ $name_prefix . 'start_page_background_color' ] = (isset($options[ $name_prefix . 'start_page_background_color' ]) && $options[ $name_prefix . 'start_page_background_color' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'start_page_background_color' ] ) ) : '#fff';
415
416 // Start page Text Color
417 $settings[ $name_prefix . 'start_page_text_color' ] = (isset($options[ $name_prefix . 'start_page_text_color' ]) && $options[ $name_prefix . 'start_page_text_color' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'start_page_text_color' ] ) ) : '#333';
418
419 // Custom class for Start page container
420 $settings[ $name_prefix . 'start_page_custom_class' ] = (isset($options[ $name_prefix . 'start_page_custom_class' ]) && $options[ $name_prefix . 'start_page_custom_class' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'start_page_custom_class' ] ) ) : '';
421
422
423 // =============================================================
424 // ===================== Start page Tab ======================
425 // ======================== END ========================
426
427
428 // =============================================================
429 // ====================== Settings Tab =======================
430 // ======================== START =========================
431
432 // Show survey title
433 $options[ $name_prefix . 'show_title' ] = isset($options[ $name_prefix . 'show_title' ]) ? $options[ $name_prefix . 'show_title' ] : 'on';
434 $settings[ $name_prefix . 'show_title' ] = (isset($options[ $name_prefix . 'show_title' ]) && $options[ $name_prefix . 'show_title' ] == 'on') ? true : false;
435
436 // Show survey section header
437 $options[ $name_prefix . 'show_section_header' ] = isset($options[ $name_prefix . 'show_section_header' ]) ? $options[ $name_prefix . 'show_section_header' ] : 'on';
438 $settings[ $name_prefix . 'show_section_header' ] = (isset($options[ $name_prefix . 'show_section_header' ]) && $options[ $name_prefix . 'show_section_header' ] == 'on') ? true : false;
439
440 // Enable randomize answers
441 $options[ $name_prefix . 'enable_randomize_answers' ] = isset($options[ $name_prefix . 'enable_randomize_answers' ]) ? $options[ $name_prefix . 'enable_randomize_answers' ] : 'off';
442 $settings[ $name_prefix . 'enable_randomize_answers' ] = (isset($options[ $name_prefix . 'enable_randomize_answers' ]) && $options[ $name_prefix . 'enable_randomize_answers' ] == 'on') ? true : false;
443
444 // Enable randomize questions
445 $options[ $name_prefix . 'enable_randomize_questions' ] = isset($options[ $name_prefix . 'enable_randomize_questions' ]) ? $options[ $name_prefix . 'enable_randomize_questions' ] : 'off';
446 $settings[ $name_prefix . 'enable_randomize_questions' ] = (isset($options[ $name_prefix . 'enable_randomize_questions' ]) && $options[ $name_prefix . 'enable_randomize_questions' ] == 'on') ? true : false;
447
448 // Enable rtl direction
449 $options[ $name_prefix . 'enable_rtl_direction' ] = isset($options[ $name_prefix . 'enable_rtl_direction' ]) ? $options[ $name_prefix . 'enable_rtl_direction' ] : 'off';
450 $settings[ $name_prefix . 'enable_rtl_direction' ] = (isset($options[ $name_prefix . 'enable_rtl_direction' ]) && $options[ $name_prefix . 'enable_rtl_direction' ] == 'on') ? true : false;
451
452 // Enable clear answer button
453 $options[ $name_prefix . 'enable_clear_answer' ] = isset($options[ $name_prefix . 'enable_clear_answer' ]) ? $options[ $name_prefix . 'enable_clear_answer' ] : 'off';
454 $settings[ $name_prefix . 'enable_clear_answer' ] = (isset($options[ $name_prefix . 'enable_clear_answer' ]) && $options[ $name_prefix . 'enable_clear_answer' ] == 'on') ? true : false;
455
456 // Enable previous button
457 $options[ $name_prefix . 'enable_previous_button' ] = isset($options[ $name_prefix . 'enable_previous_button' ]) ? $options[ $name_prefix . 'enable_previous_button' ] : 'off';
458 $settings[ $name_prefix . 'enable_previous_button' ] = (isset($options[ $name_prefix . 'enable_previous_button' ]) && $options[ $name_prefix . 'enable_previous_button' ] == 'on') ? true : false;
459
460 // Disable next button
461 $options[ $name_prefix . 'disable_next_button' ] = isset($options[ $name_prefix . 'disable_next_button' ]) ? $options[ $name_prefix . 'disable_next_button' ] : 'off';
462 $settings[ $name_prefix . 'disable_next_button' ] = (isset($options[ $name_prefix . 'disable_next_button' ]) && $options[ $name_prefix . 'disable_next_button' ] == 'on') ? true : false;
463
464 // Enable Survey Start loader
465 $options[ $name_prefix . 'enable_survey_start_loader' ] = isset($options[ $name_prefix . 'enable_survey_start_loader' ]) ? $options[ $name_prefix . 'enable_survey_start_loader' ] : 'on';
466 $settings[ $name_prefix . 'enable_survey_start_loader' ] = (isset($options[ $name_prefix . 'enable_survey_start_loader' ]) && $options[ $name_prefix . 'enable_survey_start_loader' ] == 'on') ? true : false;
467 $settings[ $name_prefix . 'before_start_loader' ] = (isset($options[ $name_prefix . 'before_start_loader' ]) && $options[ $name_prefix . 'before_start_loader' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'before_start_loader' ] ) ) : 'default';
468
469 // Allow HTML in answers
470 $options[ $name_prefix . 'allow_html_in_answers' ] = isset($options[ $name_prefix . 'allow_html_in_answers' ]) ? $options[ $name_prefix . 'allow_html_in_answers' ] : 'off';
471 $settings[ $name_prefix . 'allow_html_in_answers' ] = (isset($options[ $name_prefix . 'allow_html_in_answers' ]) && $options[ $name_prefix . 'allow_html_in_answers' ] == 'on') ? true : false;
472
473 //---- Schedule Start ---- //
474
475 // Schedule the Survey
476 $options[ $name_prefix . 'enable_schedule' ] = isset($options[ $name_prefix . 'enable_schedule' ]) ? $options[ $name_prefix . 'enable_schedule' ] : 'off';
477 $settings[ $name_prefix . 'enable_schedule' ] = (isset($options[ $name_prefix . 'enable_schedule' ]) && $options[ $name_prefix . 'enable_schedule' ] == 'on') ? true : false;
478
479 if ( $settings[ $name_prefix . 'enable_schedule' ] ) {
480 $activateTimeVal = (isset($options[ $name_prefix . 'schedule_active' ]) && $options[ $name_prefix . 'schedule_active' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'schedule_active' ] ) ) : current_time( 'mysql' );
481 $deactivateTimeVal = (isset($options[ $name_prefix . 'schedule_deactive' ]) && $options[ $name_prefix . 'schedule_deactive' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'schedule_deactive' ] ) ) : current_time( 'mysql' );
482
483 $activateTime = strtotime($activateTimeVal);
484 $settings[ $name_prefix . 'schedule_active' ] = date('Y-m-d H:i:s', $activateTime);
485
486 $deactivateTime = strtotime($deactivateTimeVal);
487 $settings[ $name_prefix . 'schedule_deactive' ] = date('Y-m-d H:i:s', $deactivateTime);
488 } else {
489 $settings[ $name_prefix . 'schedule_active' ] = current_time( 'mysql' );
490 $settings[ $name_prefix . 'schedule_deactive' ] = current_time( 'mysql' );
491 }
492
493 // Show timer
494 $options[ $name_prefix . 'schedule_show_timer' ] = isset($options[ $name_prefix . 'schedule_show_timer' ]) ? $options[ $name_prefix . 'schedule_show_timer' ] : 'off';
495 $settings[ $name_prefix . 'schedule_show_timer' ] = (isset($options[ $name_prefix . 'schedule_show_timer' ]) && $options[ $name_prefix . 'schedule_show_timer' ] == 'on') ? true : false;
496
497 // Show countdown / start date
498 $settings[ $name_prefix . 'show_timer_type' ] = (isset($options[ $name_prefix . 'show_timer_type' ]) && $options[ $name_prefix . 'show_timer_type' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'show_timer_type' ] ) ) : 'countdown';
499
500 // Pre start message
501 $settings[ $name_prefix . 'schedule_pre_start_message' ] = (isset($options[ $name_prefix . 'schedule_pre_start_message' ]) && $options[ $name_prefix . 'schedule_pre_start_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'schedule_pre_start_message' ] ) ) : __("The survey will be available soon!", "survey-maker");
502
503 // Expiration message
504 $settings[ $name_prefix . 'schedule_expiration_message' ] = (isset($options[ $name_prefix . 'schedule_expiration_message' ]) && $options[ $name_prefix . 'schedule_expiration_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'schedule_expiration_message' ] ) ) : __("This survey has expired!", "survey-maker");
505
506 // Expiration message
507 $settings[ $name_prefix . 'dont_show_survey_container' ] = (isset($options[ $name_prefix . 'dont_show_survey_container' ]) && $options[ $name_prefix . 'dont_show_survey_container' ] == 'on') ? true : false;
508 //---- Schedule End ---- //
509
510 // ---- Buttons settings Start ---- //
511 // Finish button text
512 $settings[ $name_prefix . 'finish_button_each_text' ] = (isset($options[ $name_prefix . 'finish_button_each_text' ]) && $options[ $name_prefix . 'finish_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'finish_button_each_text' ]) ) : '';
513 // Next button text
514 $settings[ $name_prefix . 'next_button_each_text' ] = (isset($options[ $name_prefix . 'next_button_each_text' ]) && $options[ $name_prefix . 'next_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'next_button_each_text' ]) ) : '';
515 // Previous button text
516 $settings[ $name_prefix . 'previous_button_each_text' ] = (isset($options[ $name_prefix . 'previous_button_each_text' ]) && $options[ $name_prefix . 'previous_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'previous_button_each_text' ]) ) : '';
517 // Restart button text
518 $settings[ $name_prefix . 'restart_button_each_text' ] = (isset($options[ $name_prefix . 'restart_button_each_text' ]) && $options[ $name_prefix . 'restart_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'restart_button_each_text' ]) ) : '';
519 // Exit button text
520 $settings[ $name_prefix . 'exit_button_each_text' ] = (isset($options[ $name_prefix . 'exit_button_each_text' ]) && $options[ $name_prefix . 'exit_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'exit_button_each_text' ]) ) : '';
521 // Clear selection button text
522 $settings[ $name_prefix . 'clear_selection_button_each_text' ] = (isset($options[ $name_prefix . 'clear_selection_button_each_text' ]) && $options[ $name_prefix . 'clear_selection_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'clear_selection_button_each_text' ]) ) : '';
523 // Start button text
524 $settings[ $name_prefix . 'start_button_each_text' ] = (isset($options[ $name_prefix . 'start_button_each_text' ]) && $options[ $name_prefix . 'start_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'start_button_each_text' ]) ) : '';
525 // Login button text
526 $settings[ $name_prefix . 'login_button_each_text' ] = (isset($options[ $name_prefix . 'login_button_each_text' ]) && $options[ $name_prefix . 'login_button_each_text' ] != '') ? stripslashes( esc_attr($options[ $name_prefix . 'login_button_each_text' ]) ) : '';
527 // ---- Buttons settings End ---- //
528
529 // Allow HTML in section description
530 $options[ $name_prefix . 'allow_html_in_section_description' ] = isset($options[ $name_prefix . 'allow_html_in_section_description' ]) ? $options[ $name_prefix . 'allow_html_in_section_description' ] : 'off';
531 $settings[ $name_prefix . 'allow_html_in_section_description' ] = (isset($options[ $name_prefix . 'allow_html_in_section_description' ]) && $options[ $name_prefix . 'allow_html_in_section_description' ] == 'on') ? true : false;
532
533 // Enable confirmation box for leaving the page
534 $options[ $name_prefix . 'enable_leave_page' ] = isset($options[ $name_prefix . 'enable_leave_page' ]) ? $options[ $name_prefix . 'enable_leave_page' ] : 'on';
535 $settings[ $name_prefix . 'enable_leave_page' ] = (isset($options[ $name_prefix . 'enable_leave_page' ]) && $options[ $name_prefix . 'enable_leave_page' ] == 'on') ? true : false;
536
537 // Full screen mode
538 $settings[ $name_prefix . 'full_screen_mode' ] = ( isset( $options[ $name_prefix . 'full_screen_mode' ] ) && $options[ $name_prefix . 'full_screen_mode' ] == "on" ) ? true : false;
539 $options[ $name_prefix . 'full_screen_button_color' ] = isset($options[ $name_prefix . 'full_screen_button_color' ]) ? $options[ $name_prefix . 'full_screen_button_color' ] : $options[ $name_prefix . 'text_color' ];
540 $settings[ $name_prefix . 'full_screen_button_color' ] = (isset($options[ $name_prefix . 'full_screen_button_color' ]) && $options[ $name_prefix . 'full_screen_button_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'full_screen_button_color' ] ) ) : '#fff';
541
542 // Survey progress bar
543 $settings[ $name_prefix . 'enable_progress_bar' ] = ( isset( $options[ $name_prefix . 'enable_progress_bar' ] ) && $options[ $name_prefix . 'enable_progress_bar' ] == "on" ) ? "on" : "off";
544 $settings[ $name_prefix . 'hide_section_pagination_text' ] = ( isset( $options[ $name_prefix . 'hide_section_pagination_text' ] ) && $options[ $name_prefix . 'hide_section_pagination_text' ] == "on" ) ? true : false;
545 $settings[ $name_prefix . 'pagination_positioning' ] = ( isset( $options[ $name_prefix . 'pagination_positioning' ] ) && $options[ $name_prefix . 'pagination_positioning' ] != "" ) ? esc_attr($options[ $name_prefix . 'pagination_positioning' ]) : "none";
546 $options[ $name_prefix . 'pagination_positioning_mobile' ] = isset($options[ $name_prefix . 'pagination_positioning_mobile' ]) ? $options[ $name_prefix . 'pagination_positioning_mobile' ] : $settings[ $name_prefix . 'pagination_positioning' ];
547 $settings[ $name_prefix . 'pagination_positioning_mobile' ] = ( isset( $options[ $name_prefix . 'pagination_positioning_mobile' ] ) && $options[ $name_prefix . 'pagination_positioning_mobile' ] != "" ) ? esc_attr($options[ $name_prefix . 'pagination_positioning_mobile' ]) : "none";
548 $settings[ $name_prefix . 'hide_section_bar' ] = ( isset( $options[ $name_prefix . 'hide_section_bar' ] ) && $options[ $name_prefix . 'hide_section_bar' ] == "on" ) ? true : false;
549 $settings[ $name_prefix . 'progress_bar_text' ] = ( isset( $options[ $name_prefix . 'progress_bar_text' ] ) && $options[ $name_prefix . 'progress_bar_text' ] != "" ) ? stripslashes(esc_attr($options[ $name_prefix . 'progress_bar_text' ])) : 'Page';
550 $settings[ $name_prefix . 'progress_bar_text_letter_spacing' ] = (isset( $options[ $name_prefix . 'progress_bar_text_letter_spacing' ] ) && $options[ $name_prefix . 'progress_bar_text_letter_spacing' ] != '' && $options[ $name_prefix . 'progress_bar_text_letter_spacing' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'progress_bar_text_letter_spacing' ] ) : 0;
551
552 $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] = !isset( $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] ) ? $settings[ $name_prefix . 'progress_bar_text_letter_spacing' ] : $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ];
553 $settings[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] = (isset( $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] ) && $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] != '' && $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] != '0' ) ? esc_attr( $options[ $name_prefix . 'progress_bar_text_letter_spacing_mobile' ] ) : 0;
554
555 $options[ $name_prefix . 'pagination_text_color' ] = isset($options[ $name_prefix . 'pagination_text_color' ]) ? $options[ $name_prefix . 'pagination_text_color' ] : $options[ $name_prefix . 'text_color' ];
556 $settings[ $name_prefix . 'pagination_text_color' ] = (isset($options[ $name_prefix . 'pagination_text_color' ]) && $options[ $name_prefix . 'pagination_text_color' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'pagination_text_color' ] ) ) : '#fff';
557 $options[ $name_prefix . 'pagination_text_color_mobile' ] = isset($options[ $name_prefix . 'pagination_text_color_mobile' ]) ? $options[ $name_prefix . 'pagination_text_color_mobile' ] : $settings[ $name_prefix . 'pagination_text_color' ];
558 $settings[ $name_prefix . 'pagination_text_color_mobile' ] = (isset($options[ $name_prefix . 'pagination_text_color_mobile' ]) && $options[ $name_prefix . 'pagination_text_color_mobile' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'pagination_text_color_mobile' ] ) ) : '#fff';
559 $options[ $name_prefix . 'progress_bar_text_font_size' ] = isset($options[ $name_prefix . 'progress_bar_text_font_size' ]) ? $options[ $name_prefix . 'progress_bar_text_font_size' ] : $options[ $name_prefix . 'answer_font_size' ];
560 $settings[ $name_prefix . 'progress_bar_text_font_size' ] = (isset($options[ $name_prefix . 'progress_bar_text_font_size' ]) && $options[ $name_prefix . 'progress_bar_text_font_size' ] != '') ? absint ( intval( $options[ $name_prefix . 'progress_bar_text_font_size' ] ) ) : 15;
561 $options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ] = isset($options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ]) ? $options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ] : $settings[ $name_prefix . 'progress_bar_text_font_size' ];
562 $settings[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ] = (isset($options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ]) && $options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ] != '') ? absint ( intval( $options[ $name_prefix . 'progress_bar_text_font_size_on_mobile' ] ) ) : 15;
563 $settings[ $name_prefix . 'progress_bar_text_transform' ] = (isset($options[ $name_prefix . 'progress_bar_text_transform' ]) && $options[ $name_prefix . 'progress_bar_text_transform' ] != '') ? esc_attr( $options[ $name_prefix . 'progress_bar_text_transform' ] ) : 'none';
564 $options[ $name_prefix . 'progress_bar_text_transform_mobile' ] = isset($options[ $name_prefix . 'progress_bar_text_transform_mobile' ]) ? $options[ $name_prefix . 'progress_bar_text_transform_mobile' ] : $settings[ $name_prefix . 'progress_bar_text_transform' ];
565 $settings[ $name_prefix . 'progress_bar_text_transform_mobile' ] = (isset($options[ $name_prefix . 'progress_bar_text_transform_mobile' ]) && $options[ $name_prefix . 'progress_bar_text_transform_mobile' ] != '') ? esc_attr( $options[ $name_prefix . 'progress_bar_text_transform_mobile' ] ) : 'none';
566
567 // Survey show sections questions count
568 $options[ $name_prefix . 'show_sections_questions_count' ] = ( isset( $options[ $name_prefix . 'show_sections_questions_count' ] ) ) ? $options[ $name_prefix . 'show_sections_questions_count' ] : "off";
569 $settings[ $name_prefix . 'show_sections_questions_count' ] = ( isset( $options[ $name_prefix . 'show_sections_questions_count' ] ) && $options[ $name_prefix . 'show_sections_questions_count' ] == "on" ) ? true : false;
570
571 // Survey required questions message
572 $options[ $name_prefix . 'required_questions_message' ] = ( isset( $options[ $name_prefix . 'required_questions_message' ] ) ) ? $options[ $name_prefix . 'required_questions_message' ] : "This is a required question";
573 $settings[ $name_prefix . 'required_questions_message' ] = ( isset( $options[ $name_prefix . 'required_questions_message' ] ) && $options[ $name_prefix . 'required_questions_message' ] != "" ) ? stripslashes(esc_attr($options[ $name_prefix . 'required_questions_message' ])) : '';
574
575 // Auto numbering questions
576 $settings[ $name_prefix . 'auto_numbering_questions' ] = (isset($options[ $name_prefix . 'auto_numbering_questions' ]) && $options[ $name_prefix . 'auto_numbering_questions' ] != '') ? stripslashes( $options[ $name_prefix . 'auto_numbering_questions' ] ) : 'none';
577
578 // Enable terms and conditions
579 $options[ $name_prefix . 'enable_terms_and_conditions' ] = isset($options[ $name_prefix . 'enable_terms_and_conditions' ]) ? esc_attr($options[ $name_prefix . 'enable_terms_and_conditions' ]) : 'off';
580 $settings[ $name_prefix . 'enable_terms_and_conditions' ] = (isset($options[ $name_prefix . 'enable_terms_and_conditions' ]) && $options[ $name_prefix . 'enable_terms_and_conditions' ] == 'on') ? true : false;
581 $settings[ $name_prefix . 'terms_and_conditions_data' ] = (isset($options[ $name_prefix . 'terms_and_conditions_data' ]) && !empty($options[ $name_prefix . 'terms_and_conditions_data' ])) ? $options[ $name_prefix . 'terms_and_conditions_data' ] : array();
582
583 //Terms and conditions required message
584 $options[ $name_prefix . 'enable_terms_and_conditions_required_message' ] = (isset($options[ 'enable_terms_and_conditions_required_message' ]) && $options['enable_terms_and_conditions_required_message' ] != '') ? $options['enable_terms_and_conditions_required_message' ] : 'off';
585 $settings['enable_terms_and_conditions_required_message' ] = (isset($options['enable_terms_and_conditions_required_message' ]) && $options['enable_terms_and_conditions_required_message' ] == 'on') ? true : false;
586
587 // =============================================================
588 // =================== Results Settings Tab ===================
589 // ======================== START =========================
590
591
592 // Redirect after submit
593 $options[ $name_prefix . 'redirect_after_submit' ] = isset($options[ $name_prefix . 'redirect_after_submit' ]) ? $options[ $name_prefix . 'redirect_after_submit' ] : 'off';
594 $settings[ $name_prefix . 'redirect_after_submit' ] = (isset($options[ $name_prefix . 'redirect_after_submit' ]) && $options[ $name_prefix . 'redirect_after_submit' ] == 'on') ? true : false;
595
596 // Redirect URL
597 $settings[ $name_prefix . 'submit_redirect_url' ] = (isset($options[ $name_prefix . 'submit_redirect_url' ]) && $options[ $name_prefix . 'submit_redirect_url' ] != '') ? stripslashes ( esc_url( $options[ $name_prefix . 'submit_redirect_url' ] ) ) : '';
598
599 // Redirect delay (sec)
600 $settings[ $name_prefix . 'submit_redirect_delay' ] = (isset($options[ $name_prefix . 'submit_redirect_delay' ]) && $options[ $name_prefix . 'submit_redirect_delay' ] != '') ? absint ( intval( $options[ $name_prefix . 'submit_redirect_delay' ] ) ) : '';
601
602 // Redirect in new tab
603 $settings[ $name_prefix . 'submit_redirect_new_tab' ] = (isset($options[ $name_prefix . 'submit_redirect_new_tab' ]) && $options[ $name_prefix . 'submit_redirect_new_tab' ] == 'on') ? true : false;
604
605 // Enable EXIT button
606 $options[ $name_prefix . 'enable_exit_button' ] = isset($options[ $name_prefix . 'enable_exit_button' ]) ? $options[ $name_prefix . 'enable_exit_button' ] : 'off';
607 $settings[ $name_prefix . 'enable_exit_button' ] = (isset($options[ $name_prefix . 'enable_exit_button' ]) && $options[ $name_prefix . 'enable_exit_button' ] == 'on') ? true : false;
608
609 // Redirect URL
610 $settings[ $name_prefix . 'exit_redirect_url' ] = (isset($options[ $name_prefix . 'exit_redirect_url' ]) && $options[ $name_prefix . 'exit_redirect_url' ] != '') ? stripslashes ( esc_url( $options[ $name_prefix . 'exit_redirect_url' ] ) ) : '';
611
612 // Enable EXIT button
613 $options[ $name_prefix . 'enable_restart_button' ] = isset($options[ $name_prefix . 'enable_restart_button' ]) ? $options[ $name_prefix . 'enable_restart_button' ] : 'off';
614 $settings[ $name_prefix . 'enable_restart_button' ] = (isset($options[ $name_prefix . 'enable_restart_button' ]) && $options[ $name_prefix . 'enable_restart_button' ] == 'on') ? true : false;
615
616 // Thank you message
617 $settings[ $name_prefix . 'final_result_text' ] = (isset($options[ $name_prefix . 'final_result_text' ]) && $options[ $name_prefix . 'final_result_text' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'final_result_text' ] ) ) : '';
618
619 // Select survey loader
620 $settings[ $name_prefix . 'loader' ] = (isset($options[ $name_prefix . 'loader' ]) && $options[ $name_prefix . 'loader' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'loader' ] ) ) : 'default';
621
622 // Social share buttons
623 $options[ $name_prefix . 'social_buttons' ] = ( isset( $options[ $name_prefix . 'social_buttons' ] ) && $options[ $name_prefix . 'social_buttons' ] == 'on' ) ? true : false;
624 $settings[ $name_prefix . 'social_buttons' ] = ( isset( $options[ $name_prefix . 'social_buttons' ] ) && $options[ $name_prefix . 'social_buttons' ] ) ? true : false;
625 // Social share buttons heading message
626 $settings[ $name_prefix . 'social_buttons_heading' ] = ( isset( $options[ $name_prefix . 'social_buttons_heading' ] ) && $options[ $name_prefix . 'social_buttons_heading' ] != '' ) ? stripslashes( wpautop( $options[ $name_prefix . 'social_buttons_heading' ] ) ) : '';
627 // Linkedin
628 $options[ $name_prefix . 'social_button_ln' ] = ( isset( $options[ $name_prefix . 'social_button_ln' ] ) && $options[ $name_prefix . 'social_button_ln' ] == 'on' ) ? true : false;
629 $settings[ $name_prefix . 'social_button_ln' ] = ( isset( $options[ $name_prefix . 'social_button_ln' ] ) && $options[ $name_prefix . 'social_button_ln' ] == 'on' ) ? true : false;
630 // Facebook
631 $options[ $name_prefix . 'social_button_fb' ] = ( isset( $options[ $name_prefix . 'social_button_fb' ] ) && $options[ $name_prefix . 'social_button_fb' ] == 'on' ) ? true : false;
632 $settings[ $name_prefix . 'social_button_fb' ] = ( isset( $options[ $name_prefix . 'social_button_fb' ] ) && $options[ $name_prefix . 'social_button_fb' ] ) ? true : false;
633 // Twitter
634 $options[ $name_prefix . 'social_button_tr' ] = ( isset( $options[ $name_prefix . 'social_button_tr' ] ) && $options[ $name_prefix . 'social_button_tr' ] == 'on' ) ? true : false;
635 $settings[ $name_prefix . 'social_button_tr' ] = ( isset( $options[ $name_prefix . 'social_button_tr' ] ) && $options[ $name_prefix . 'social_button_tr' ] ) ? true : false;
636 // Vk
637 $options[ $name_prefix . 'social_button_vk' ] = ( isset( $options[ $name_prefix . 'social_button_vk' ] ) && $options[ $name_prefix . 'social_button_vk' ] == 'on' ) ? true : false;
638 $settings[ $name_prefix . 'social_button_vk' ] = ( isset( $options[ $name_prefix . 'social_button_vk' ] ) && $options[ $name_prefix . 'social_button_vk' ] ) ? true : false;
639
640 // =============================================================
641 // =================== Results Settings Tab ===================
642 // ======================== END ==========================
643
644
645
646 // ======================= // ======================= // ======================= // ======================= // ======================= //
647
648
649
650 // =============================================================
651 // =================== Limitation Tab ===================
652 // ======================== START =========================
653
654 // Maximum number of attempts per user
655 $options[ $name_prefix . 'limit_users' ] = isset($options[ $name_prefix . 'limit_users' ]) ? $options[ $name_prefix . 'limit_users' ] : 'off';
656 $settings[ $name_prefix . 'limit_users' ] = (isset($options[ $name_prefix . 'limit_users' ]) && $options[ $name_prefix . 'limit_users' ] == 'on') ? true : false;
657
658 // Detects users by IP / ID
659 $settings[ $name_prefix . 'limit_users_by' ] = (isset($options[ $name_prefix . 'limit_users_by' ]) && $options[ $name_prefix . 'limit_users_by' ] != '') ? stripslashes ( sanitize_text_field( $options[ $name_prefix . 'limit_users_by' ] ) ) : 'ip';
660
661 // Attempts count
662 $settings[ $name_prefix . 'max_pass_count' ] = (isset($options[ $name_prefix . 'max_pass_count' ]) && $options[ $name_prefix . 'max_pass_count' ] != '') ? absint ( intval( $options[ $name_prefix . 'max_pass_count' ] ) ) : 1;
663
664 // Limitation Message
665 $settings[ $name_prefix . 'limitation_message' ] = (isset($options[ $name_prefix . 'limitation_message' ]) && $options[ $name_prefix . 'limitation_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'limitation_message' ] ) ) : '';
666
667 // Redirect Url
668 $settings[ $name_prefix . 'redirect_url' ] = (isset($options[ $name_prefix . 'redirect_url' ]) && $options[ $name_prefix . 'redirect_url' ] != '') ? $options[ $name_prefix . 'redirect_url' ] : '';
669
670 // Redirect delay
671 $settings[ $name_prefix . 'redirect_delay' ] = (isset($options[ $name_prefix . 'redirect_delay' ]) && $options[ $name_prefix . 'redirect_delay' ] != '') ? absint ( intval( $options[ $name_prefix . 'redirect_delay' ] ) ) : 1;
672
673 // Only for logged in users
674 $options[ $name_prefix . 'enable_logged_users' ] = isset($options[ $name_prefix . 'enable_logged_users' ]) ? $options[ $name_prefix . 'enable_logged_users' ] : 'off';
675 $settings[ $name_prefix . 'enable_logged_users' ] = (isset($options[ $name_prefix . 'enable_logged_users' ]) && $options[ $name_prefix . 'enable_logged_users' ] == 'on') ? true : false;
676
677 // Message - Only for logged in users
678 $settings[ $name_prefix . 'logged_in_message' ] = (isset($options[ $name_prefix . 'logged_in_message' ]) && $options[ $name_prefix . 'logged_in_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'logged_in_message' ] ) ) : '';
679
680 // Show login form
681 $options[ $name_prefix . 'show_login_form' ] = isset($options[ $name_prefix . 'show_login_form' ]) ? $options[ $name_prefix . 'show_login_form' ] : 'off';
682 $settings[ $name_prefix . 'show_login_form' ] = (isset($options[ $name_prefix . 'show_login_form' ]) && $options[ $name_prefix . 'show_login_form' ] == 'on') ? true : false;
683
684 // =============================================================
685 // =================== Limitation Tab ===================
686 // ======================== END ==========================
687
688
689
690 // ======================= // ======================= // ======================= // ======================= // ======================= //
691
692
693
694 // =============================================================
695 // ===================== E-Mail Tab =====================
696 // ======================== START =========================
697
698
699 // Send Mail To User
700 $options[ $name_prefix . 'enable_mail_user' ] = isset($options[ $name_prefix . 'enable_mail_user' ]) ? $options[ $name_prefix . 'enable_mail_user' ] : 'off';
701 $settings[ $name_prefix . 'enable_mail_user' ] = (isset($options[ $name_prefix . 'enable_mail_user' ]) && $options[ $name_prefix . 'enable_mail_user' ] == 'on') ? true : false;
702
703 // Email message
704 $settings[ $name_prefix . 'mail_message' ] = (isset($options[ $name_prefix . 'mail_message' ]) && $options[ $name_prefix . 'mail_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'mail_message' ] ) ) : '';
705
706 // Send email to admin
707 $options[ $name_prefix . 'enable_mail_admin' ] = isset($options[ $name_prefix . 'enable_mail_admin' ]) ? $options[ $name_prefix . 'enable_mail_admin' ] : 'off';
708 $settings[ $name_prefix . 'enable_mail_admin' ] = (isset($options[ $name_prefix . 'enable_mail_admin' ]) && $options[ $name_prefix . 'enable_mail_admin' ] == 'on') ? true : false;
709
710 // Send email to site admin ( SuperAdmin )
711 $options[ $name_prefix . 'send_mail_to_site_admin' ] = isset($options[ $name_prefix . 'send_mail_to_site_admin' ]) ? $options[ $name_prefix . 'send_mail_to_site_admin' ] : 'on';
712 $settings[ $name_prefix . 'send_mail_to_site_admin' ] = (isset($options[ $name_prefix . 'send_mail_to_site_admin' ]) && $options[ $name_prefix . 'send_mail_to_site_admin' ] == 'on') ? true : false;
713
714 // Additional emails
715 $settings[ $name_prefix . 'additional_emails' ] = (isset($options[ $name_prefix . 'additional_emails' ]) && $options[ $name_prefix . 'additional_emails' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'additional_emails' ] ) ) : '';
716
717 // Email message
718 $settings[ $name_prefix . 'mail_message_admin' ] = (isset($options[ $name_prefix . 'mail_message_admin' ]) && $options[ $name_prefix . 'mail_message_admin' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'mail_message_admin' ] ) ) : '';
719
720 //---- Email configuration Start ---- //
721
722 // From email
723 $settings[ $name_prefix . 'email_configuration_from_email' ] = (isset($options[ $name_prefix . 'email_configuration_from_email' ]) && $options[ $name_prefix . 'email_configuration_from_email' ] != '') ? stripslashes( sanitize_email( $options[ $name_prefix . 'email_configuration_from_email' ] ) ) : '';
724
725 // From name
726 $settings[ $name_prefix . 'email_configuration_from_name' ] = (isset($options[ $name_prefix . 'email_configuration_from_name' ]) && $options[ $name_prefix . 'email_configuration_from_name' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'email_configuration_from_name' ] ) ) : '';
727
728 // Subject
729 $settings[ $name_prefix . 'email_configuration_from_subject' ] = (isset($options[ $name_prefix . 'email_configuration_from_subject' ]) && $options[ $name_prefix . 'email_configuration_from_subject' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'email_configuration_from_subject' ] ) ) : '';
730
731 // Reply to email
732 $settings[ $name_prefix . 'email_configuration_replyto_email' ] = (isset($options[ $name_prefix . 'email_configuration_replyto_email' ]) && $options[ $name_prefix . 'email_configuration_replyto_email' ] != '') ? stripslashes( sanitize_email( $options[ $name_prefix . 'email_configuration_replyto_email' ] ) ) : '';
733
734 // Reply to name
735 $settings[ $name_prefix . 'email_configuration_replyto_name' ] = (isset($options[ $name_prefix . 'email_configuration_replyto_name' ]) && $options[ $name_prefix . 'email_configuration_replyto_name' ] != '') ? stripslashes ( esc_attr( $options[ $name_prefix . 'email_configuration_replyto_name' ] ) ) : '';
736
737 //---- Email configuration End ---- //
738
739
740 // =============================================================
741 // ===================== E-Mail Tab =====================
742 // ======================== END ==========================
743
744 //limitation takers count
745 $options[ $name_prefix . 'enable_takers_count' ] = (isset( $options[ $name_prefix . 'enable_takers_count' ] ) && $options[ $name_prefix . 'enable_takers_count' ] == 'on') ? stripslashes ( $options[ $name_prefix . 'enable_takers_count' ] ) : 'off';
746 $settings[ $name_prefix . 'enable_takers_count' ] = (isset($options[ $name_prefix . 'enable_takers_count' ]) && $options[ $name_prefix . 'enable_takers_count' ] == 'on') ? true : false;
747
748 //Takers Count
749 $settings[ $name_prefix . 'takers_count' ] = (isset($options[ $name_prefix . 'takers_count' ]) && $options[ $name_prefix . 'takers_count' ] != '') ? absint ( intval( $options[ $name_prefix . 'takers_count' ] ) ) : 1;
750
751 // Auto numbering
752 $settings[ $name_prefix . 'auto_numbering' ] = (isset($options[ $name_prefix . 'auto_numbering' ]) && $options[ $name_prefix . 'auto_numbering' ] != '') ? stripslashes( $options[ $name_prefix . 'auto_numbering' ] ) : 'none';
753
754 // Loader custom gif
755 $settings[ $name_prefix . 'loader_gif' ] = (isset($options[ $name_prefix . 'loader_gif' ]) && $options[ $name_prefix . 'loader_gif' ] != '') ? esc_url( $options[ $name_prefix . 'loader_gif' ] ) : '';
756 $settings[ $name_prefix . 'loader_gif_width' ] = (isset($options[ $name_prefix . 'loader_gif_width' ]) && $options[ $name_prefix . 'loader_gif_width' ] != '') ? esc_attr( $options[ $name_prefix . 'loader_gif_width' ] ) : '100';
757
758
759 return $settings;
760 }
761
762 public static function get_surveys($ordering = ''){
763 global $wpdb;
764 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
765
766 $sql = "SELECT id,title
767 FROM {$surveys_table} WHERE `status` = 'published'";
768
769
770 if($ordering != ''){
771 $sql .= ' ORDER BY id '.$ordering;
772 }
773
774 $surveys = $wpdb->get_results( $sql , "ARRAY_A" );
775
776 return $surveys;
777 }
778
779 public static function get_survey_current_column( $survey_id , $column, $status = 'published'){
780 global $wpdb;
781 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
782
783 $sql = "SELECT ".sanitize_text_field($column)."
784 FROM {$surveys_table} WHERE `id`= ".sanitize_text_field($survey_id)." AND `status` = '".sanitize_text_field($status)."' ";
785 $current_column = $wpdb->get_var( $sql );
786
787 return $current_column;
788 }
789
790 public static function get_survey_by_id( $id ){
791 global $wpdb;
792 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
793
794 $sql = "SELECT *
795 FROM {$surveys_table}
796 WHERE id=" . esc_sql( absint( $id ) );
797
798 $survey = $wpdb->get_row( $sql );
799
800 return $survey;
801 }
802
803 public static function get_survey_category_by_id( $id ){
804 global $wpdb;
805 $survey_cat_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "survey_categories";
806
807 $sql = "SELECT *
808 FROM {$survey_cat_table}
809 WHERE id=" . esc_sql( absint( $id ) );
810
811 $category = $wpdb->get_row( $sql );
812
813 return $category;
814 }
815
816 public static function get_question_category_by_id( $id ){
817 global $wpdb;
818 $question_cat_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "question_categories";
819
820 $sql = "SELECT *
821 FROM {$question_cat_table}
822 WHERE id=" . esc_sql( absint( $id ) );
823
824 $category = $wpdb->get_row( $sql );
825
826 return $category;
827 }
828
829 public static function get_question_by_id( $id ){
830 global $wpdb;
831 $questions_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "questions";
832 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
833
834 $sql = "SELECT *
835 FROM {$questions_table}
836 WHERE id=" . esc_sql( absint( $id ) );
837
838 $question = $wpdb->get_row( $sql );
839
840 $sql = "SELECT *
841 FROM {$answers_table}
842 WHERE question_id=" . esc_sql( absint( $id ) );
843
844 $answers = $wpdb->get_results( $sql );
845
846 $question->answers = $answers;
847
848 return $question;
849 }
850
851 public static function get_question_by_ids( $ids ){
852 global $wpdb;
853 $questions_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "questions";
854 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
855
856 $qids = esc_sql( implode( ',', $ids ) );
857
858 $sql = "SELECT *
859 FROM {$questions_table}
860 WHERE id IN (" . esc_sql( $qids ) . ")
861 ORDER BY ordering";
862
863 $questions = $wpdb->get_results( $sql );
864
865 foreach ( $questions as $key => &$question ) {
866
867 $sql = "SELECT *
868 FROM {$answers_table}
869 WHERE question_id=" . esc_sql( absint( $question->id ) ) ."
870 ORDER BY ordering";
871
872 $answers = $wpdb->get_results( $sql );
873
874 $question->answers = $answers;
875
876 }
877
878 return $questions;
879 }
880
881 public static function get_section_by_id($id){
882 global $wpdb;
883 $sections_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "sections";
884
885 $sid = esc_sql( absint( $id ) );
886
887 $sql = "SELECT *
888 FROM {$sections_table}
889 WHERE id={$sid}
890 ORDER BY ordering";
891
892 $section = $wpdb->get_row( $sql );
893
894 return $section;
895 }
896
897 public static function get_answer_by_id($id){
898 global $wpdb;
899 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
900
901 $sql = "SELECT *
902 FROM {$answers_table}
903 WHERE id=" . esc_sql( absint( $id ) );
904
905 $answer = $wpdb->get_row( $sql );
906
907 return $answer;
908 }
909
910 public static function get_answers_by_question_id($id){
911 global $wpdb;
912 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
913
914 $sql = "SELECT *
915 FROM {$answers_table}
916 WHERE question_id=" . esc_sql( absint( $id ) ) . "
917 ORDER BY ordering";
918
919 $answers = $wpdb->get_results( $sql, 'ARRAY_A' );
920
921 if(! empty($answers) ){
922 return $answers;
923 }
924
925 return array();
926 }
927
928 public static function get_survey_questions_count($id){
929 global $wpdb;
930 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
931
932 $sql = "SELECT `questions_count`
933 FROM {$surveys_table}
934 WHERE id=" . esc_sql( absint( $id ) );
935
936 $questions_str = $wpdb->get_var( $sql );
937 $count = intval( $questions_str );
938
939 return $count;
940 }
941
942 public static function get_survey_sections_count($id){
943 global $wpdb;
944 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
945
946 $sql = "SELECT `sections_count`
947 FROM {$surveys_table}
948 WHERE id=" . esc_sql( absint( $id ) );
949
950 $sections_str = $wpdb->get_var( $sql );
951 $count = intval( $sections_str );
952
953 return $count;
954 }
955
956 public static function get_sections_by_survey_id( $ids ) {
957 global $wpdb;
958 if (empty($ids)) {
959 return array();
960 }
961 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "sections";
962
963 $sql = "SELECT * FROM {$table} WHERE `id` IN (" . esc_sql( $ids ) .") ORDER BY `ordering`;";
964 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
965
966 if(! empty($result) ){
967 return $result;
968 }
969
970 return array();
971 }
972
973 public static function get_questions_by_section_id( $section_id, $question_ids ) {
974 global $wpdb;
975 if (empty($question_ids) || empty($section_id)) {
976 return array();
977 }
978 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "questions";
979
980 $sql = "SELECT * FROM {$table} WHERE `section_id` = ". absint( $section_id ) ." AND `id` IN (" . esc_sql( $question_ids ) .") ORDER BY ordering;";
981 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
982
983 if(! empty($result) ){
984 return $result;
985 }
986
987 return array();
988 }
989
990 public static function get_answers_by_question_id_aro( $question_id ) {
991 global $wpdb;
992 if (empty($question_id)) {
993 return false;
994 }
995 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "answers";
996
997 $sql = "SELECT * FROM {$table} WHERE `question_id` = ". absint( $question_id );
998 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
999
1000 return $result;
1001 }
1002
1003 public static function sort_array_keys_by_array($array, $orderArray) {
1004 $ordered = array();
1005 foreach ($orderArray as $key) {
1006 if (array_key_exists('ays-question-'.$key, $array)) {
1007 $ordered['ays-question-'.$key] = $array['ays-question-'.$key];
1008 unset($array['ays-question-'.$key]);
1009 }
1010 }
1011 return $ordered + $array;
1012 }
1013
1014 public static function replace_message_variables($content, $data){
1015 foreach($data as $variable => $value){
1016 $content = str_replace("%%".$variable."%%", $value, $content);
1017 }
1018 return $content;
1019 }
1020
1021 public static function question_type_is($question_id){
1022 global $wpdb;
1023 $questions_table = $wpdb->prefix . "aysquiz_questions";
1024 $question_id = absint(intval($question_id));
1025 $custom_types = array("custom");
1026 $question_type = $wpdb->get_var("SELECT type FROM {$questions_table} WHERE id=". absint( $question_id ) .";");
1027 if($question_type == ''){
1028 $question_type = 'radio';
1029 }
1030
1031 if(in_array($question_type, $custom_types)){
1032 return true;
1033 }
1034 return false;
1035 }
1036
1037 public static function hex2rgba($color, $opacity = false){
1038
1039 $default = 'rgb(0,0,0)';
1040
1041 //Return default if no color provided
1042 if (empty($color))
1043 return $default;
1044
1045 //Sanitize $color if "#" is provided
1046 if ($color[0] == '#') {
1047 $color = substr($color, 1);
1048 }else{
1049 return $color;
1050 }
1051
1052 //Check if color has 6 or 3 characters and get values
1053 if (strlen($color) == 6) {
1054 $hex = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
1055 } elseif (strlen($color) == 3) {
1056 $hex = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
1057 } else {
1058 return $default;
1059 }
1060
1061 //Convert hexadec to rgb
1062 $rgb = array_map('hexdec', $hex);
1063
1064 //Check if opacity is set(rgba or rgb)
1065 if ($opacity) {
1066 if (abs($opacity) > 1)
1067 $opacity = 1.0;
1068 $output = 'rgba(' . implode(",", $rgb) . ',' . $opacity . ')';
1069 } else {
1070 $output = 'rgb(' . implode(",", $rgb) . ')';
1071 }
1072
1073 //Return rgb(a) color string
1074 return $output;
1075 }
1076
1077 public static function rgb2hex( $rgba ) {
1078 if ( strpos( $rgba, '#' ) === 0 ) {
1079 return $rgba;
1080 }
1081
1082 preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color );
1083 if(!empty($by_color)){
1084 return sprintf( '#%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
1085 }
1086 }
1087
1088 public static function secondsToWords($seconds){
1089 $ret = "";
1090
1091 $seconds = absint($seconds);
1092
1093 /*** get the days ***/
1094 $days = (int)($seconds / 86400);
1095 if ($days > 0) {
1096 $ret .= "$days " . __( 'days', "survey-maker" ) . ' ';
1097 }
1098
1099 /*** get the hours ***/
1100 $hours = (int)(($seconds - ($days * 86400)) / 3600);
1101 if ($hours > 0) {
1102 $ret .= "$hours " . __( 'hours', "survey-maker" ) . ' ';
1103 }
1104
1105 /*** get the minutes ***/
1106 $minutes = (int)(($seconds - $days * 86400 - $hours * 3600) / 60);
1107 if ($minutes > 0) {
1108 $ret .= "$minutes " . __( 'minutes', "survey-maker" ) . ' ';
1109 }
1110
1111 /*** get the seconds ***/
1112 $seconds = (int)($seconds - ($days * 86400) - ($hours * 3600) - ($minutes * 60));
1113 if ($seconds > 0) {
1114 $ret .= "$seconds " . __( 'seconds', "survey-maker" );
1115 }
1116
1117 return $ret;
1118 }
1119
1120 public static function get_limit_user_by_ip($id){
1121 global $wpdb;
1122 $table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions" );
1123 $user_ip = self::get_user_ip();
1124 $sql = "SELECT COUNT(*)
1125 FROM `{$table}`
1126 WHERE `user_ip` = '". esc_sql( $user_ip ) ."'
1127 AND `survey_id` = ". absint( $id );
1128 $result = intval($wpdb->get_var($sql));
1129 return $result;
1130 }
1131
1132 public static function get_limit_user_by_id($survey_id, $user_id){
1133 global $wpdb;
1134 $table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions" );
1135 $sql = "SELECT COUNT(*)
1136 FROM `{$table}`
1137 WHERE `user_id` = ". absint( $user_id ) ."
1138 AND `survey_id` = ". absint( $survey_id );
1139 $result = intval($wpdb->get_var($sql));
1140 return $result;
1141 }
1142
1143 public static function get_user_ip(){
1144 $ipaddress = '';
1145 if( !empty($_SERVER) && !empty($_SERVER['REMOTE_ADDR']) ){
1146 $ipaddress = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : 'UNKNOWN';
1147 } else {
1148 if (getenv('REMOTE_ADDR'))
1149 $ipaddress = getenv('REMOTE_ADDR');
1150 elseif (getenv('HTTP_CLIENT_IP'))
1151 $ipaddress = getenv('HTTP_CLIENT_IP');
1152 else if (getenv('HTTP_X_FORWARDED_FOR'))
1153 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
1154 else if (getenv('HTTP_X_FORWARDED'))
1155 $ipaddress = getenv('HTTP_X_FORWARDED');
1156 else if (getenv('HTTP_FORWARDED_FOR'))
1157 $ipaddress = getenv('HTTP_FORWARDED_FOR');
1158 else if (getenv('HTTP_FORWARDED'))
1159 $ipaddress = getenv('HTTP_FORWARDED');
1160 else
1161 $ipaddress = 'UNKNOWN';
1162 }
1163 return $ipaddress;
1164 }
1165
1166 // OLD
1167 // public static function get_user_ip_validated(){
1168 // $ipaddress = '';
1169 // if (getenv('REMOTE_ADDR')){
1170 // $ipaddress = getenv('REMOTE_ADDR');
1171 // }
1172 // elseif (getenv('HTTP_CLIENT_IP')){
1173 // $ipaddress = getenv('HTTP_CLIENT_IP');
1174 // }
1175 // else if (getenv('HTTP_X_FORWARDED_FOR')){
1176 // $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
1177 // }
1178 // else if (getenv('HTTP_X_FORWARDED')){
1179 // $ipaddress = getenv('HTTP_X_FORWARDED');
1180 // }
1181 // else if (getenv('HTTP_FORWARDED_FOR')){
1182 // $ipaddress = getenv('HTTP_FORWARDED_FOR');
1183 // }
1184 // else if (getenv('HTTP_FORWARDED')){
1185 // $ipaddress = getenv('HTTP_FORWARDED');
1186 // }
1187 // else{
1188 // $ipaddress = 'UNKNOWN';
1189 // }
1190 // // Validate the IP address
1191 // if (filter_var($ipaddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) && $ipaddress !== '0.0.0.0') {
1192 // return $ipaddress;
1193 // }
1194 // return 'UNKNOWN';
1195
1196 // }
1197
1198 // FOR REVIEW
1199 public static function get_user_ip_validated(){
1200
1201 if( !empty($_SERVER) && !empty($_SERVER['REMOTE_ADDR']) ){
1202 $ipaddress = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : 'UNKNOWN';
1203
1204 if(!empty($ipaddress) && $ipaddress != 'UNKNOWN' ){
1205 return $ipaddress;
1206 }
1207 }
1208
1209 $headers_to_check = array(
1210 'HTTP_CLIENT_IP',
1211 'HTTP_X_FORWARDED_FOR',
1212 'HTTP_X_FORWARDED',
1213 'HTTP_FORWARDED_FOR',
1214 'HTTP_FORWARDED',
1215 'REMOTE_ADDR'
1216 );
1217
1218 foreach ($headers_to_check as $header) {
1219 if (!empty($_SERVER[$header])) {
1220 // In case of multiple IPs in HTTP_X_FORWARDED_FOR, take the last one
1221 if ($header === 'HTTP_X_FORWARDED_FOR') {
1222 $ips = explode(',', $_SERVER[$header]);
1223 $ip = trim(end($ips));
1224 } else {
1225 $ip = $_SERVER[$header];
1226 }
1227
1228 // Validate the IP address
1229 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) && $ip !== '0.0.0.0') {
1230 return $ip;
1231 }
1232 }
1233 }
1234
1235 return 'UNKNOWN';
1236 }
1237
1238 public static function ays_autoembed( $content ) {
1239 global $wp_embed;
1240 $content = stripslashes( wpautop( $content ) );
1241 $content = $wp_embed->autoembed( $content );
1242 if ( strpos( $content, '[embed]' ) !== false ) {
1243 $content = $wp_embed->run_shortcode( $content );
1244 }
1245 $content = do_shortcode( $content );
1246 return $content;
1247 }
1248
1249 public static function get_questions_categories($q_ids){
1250 global $wpdb;
1251
1252 if($q_ids == ''){
1253 return array();
1254 }
1255 $sql = "SELECT DISTINCT c.id, c.title
1256 FROM {$wpdb->prefix}aysquiz_categories c
1257 JOIN {$wpdb->prefix}aysquiz_questions q
1258 ON c.id = q.category_id
1259 WHERE q.id IN (". esc_sql( $q_ids ) .")";
1260
1261 $result = $wpdb->get_results($sql, 'ARRAY_A');
1262 $cats = array();
1263
1264 foreach($result as $res){
1265 $cats[$res['id']] = $res['title'];
1266 }
1267
1268 return $cats;
1269 }
1270
1271 public static function get_suervey_sections_with_questions( $sections_ids, $question_ids ){
1272
1273 $sections = self::get_sections_by_survey_id($sections_ids);
1274 $sections_count = count( $sections );
1275
1276 foreach ($sections as $section_key => $section) {
1277 $sections[$section_key]['title'] = (isset($section['title']) && $section['title'] != '') ? stripslashes( htmlentities( $section['title'] ) ) : '';
1278 $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? stripslashes( htmlentities( $section['description'] ) ) : '';
1279
1280 $section_questions = self::get_questions_by_section_id( intval( $section['id'] ), $question_ids );
1281
1282 foreach ($section_questions as $question_key => $question) {
1283 $section_questions[$question_key]['question'] = (isset($question['question']) && $question['question'] != '') ? stripslashes( $question['question'] ) : '';
1284 $section_questions[$question_key]['image'] = (isset($question['image']) && $question['image'] != '') ? $question['image'] : '';
1285 $section_questions[$question_key]['type'] = (isset($question['type']) && $question['type'] != '') ? $question['type'] : 'radio';
1286 $section_questions[$question_key]['user_variant'] = (isset($question['user_variant']) && $question['user_variant'] == 'on') ? true : false;
1287
1288 $opts = json_decode( $question['options'], true );
1289 $opts['required'] = (isset($opts['required']) && $opts['required'] == 'on') ? true : false;
1290
1291 $q_answers = self::get_answers_by_question_id( intval( $question['id'] ) );
1292
1293 foreach ($q_answers as $answer_key => $answer) {
1294 $q_answers[$answer_key]['answer'] = (isset($answer['answer']) && $answer['answer'] != '') ? stripslashes( $answer['answer'] ) : '';
1295 $q_answers[$answer_key]['image'] = (isset($answer['image']) && $answer['image'] != '') ? $answer['image'] : '';
1296 $q_answers[$answer_key]['placeholder'] = (isset($answer['placeholder']) && $answer['placeholder'] != '') ? $answer['placeholder'] : '';
1297 }
1298
1299 $section_questions[$question_key]['answers'] = $q_answers;
1300
1301 $section_questions[$question_key]['options'] = $opts;
1302 }
1303
1304 $sections[$section_key]['questions'] = $section_questions;
1305 }
1306
1307 return $sections;
1308 }
1309
1310 /**
1311 * Recursive sanitation for an array
1312 *
1313 * @param $array
1314 *
1315 * @return mixed
1316 */
1317 public static function recursive_sanitize_text_field( $array, $textareas = array() ) {
1318 foreach ( $array as $key => &$value ) {
1319 if ( is_array( $value ) ) {
1320 $value = self::recursive_sanitize_text_field( $value, $textareas );
1321 } else {
1322 if( in_array( $key, $textareas ) ){
1323 if( function_exists( 'sanitize_textarea_field' ) ){
1324 $value = sanitize_textarea_field( $value );
1325 }else{
1326 $value = sanitize_text_field( $value );
1327 }
1328 }else{
1329 $value = sanitize_text_field( $value );
1330 }
1331 }
1332 }
1333
1334 return $array;
1335 }
1336
1337 public static function get_survey_takers_count( $id ){
1338 global $wpdb;
1339 $submission_table = $wpdb->prefix . "ayssurvey_submissions";
1340 $sql = "SELECT COUNT(id) AS count FROM {$submission_table} WHERE survey_id=". absint( $id ) ;
1341 $result = absint( $wpdb->get_var( $sql ) );
1342
1343 return $result;
1344 }
1345
1346 public static function get_setting_data( $meta_key = 'options' ){
1347 global $wpdb;
1348
1349 $name_prefix = 'survey_';
1350
1351 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1352 $sql = "SELECT meta_value FROM " . $settings_table . " WHERE meta_key = '". esc_sql( $meta_key ) ."'";
1353 $result = $wpdb->get_var($sql);
1354
1355 $options = ($result == "") ? array() : json_decode($result, true);
1356
1357 return $options;
1358 }
1359
1360 public static function get_listtables_title_length( $listtable_name ) {
1361 global $wpdb;
1362
1363 $options = self::get_setting_data( 'options' );
1364
1365 $listtable_title_length = 5;
1366 if(! empty($options) ){
1367 switch ( $listtable_name ) {
1368 case 'surveys':
1369 $listtable_title_length = (isset($options['survey_title_length']) && intval($options['survey_title_length']) != 0) ? absint(intval($options['survey_title_length'])) : 5;
1370 break;
1371 case 'submissions':
1372 $listtable_title_length = (isset($options['survey_submissions_title_length']) && intval($options['survey_submissions_title_length']) != 0) ? absint(intval($options['survey_submissions_title_length'])) : 5;
1373 break;
1374 case 'survey_categories':
1375 $listtable_title_length = (isset($options['survey_categories_title_length']) && intval($options['survey_categories_title_length']) != 0) ? absint(intval($options['survey_categories_title_length'])) : 5;
1376 break;
1377 case 'popup_surveys':
1378 $listtable_title_length = (isset($options['survey_popups_title_length']) && intval($options['survey_popups_title_length']) != 0) ? absint(intval($options['survey_popups_title_length'])) : 5;
1379 break;
1380 default:
1381 $listtable_title_length = 5;
1382 break;
1383 }
1384 return $listtable_title_length;
1385 }
1386 return $listtable_title_length;
1387 }
1388
1389 /*
1390 * Get survey default texts from database
1391 */
1392 public static function ays_set_default_texts( $plugin_name, $settings = array() ) {
1393 global $wpdb;
1394
1395 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1396 $sql = "SELECT meta_value FROM " . $settings_table . " WHERE meta_key = 'default_texts'";
1397 $result = $wpdb->get_var($sql);
1398 $settings_static_texts = ($result == "") ? array() : json_decode($result, true);
1399
1400 $wrong_shortcode_text = (isset($settings_static_texts['wrong_shortcode_text']) && $settings_static_texts['wrong_shortcode_text'] != '') ? stripslashes(esc_attr($settings_static_texts['wrong_shortcode_text'])) : 'Wrong shortcode initialized';
1401 $email_validation_error_text = (isset($settings_static_texts['email_validation_error_text']) && $settings_static_texts['email_validation_error_text'] != '') ? stripslashes(esc_html($settings_static_texts['email_validation_error_text'])) : 'Must be a valid email address';
1402 $redirecting_after_text = (isset($settings_static_texts['redirecting_after_text']) && $settings_static_texts['redirecting_after_text'] != '') ? stripslashes( esc_html( $settings_static_texts['redirecting_after_text'] ) ) : 'Redirecting after';
1403
1404 if ($wrong_shortcode_text === 'Wrong shortcode initialized') {
1405 $wrong_shortcode_text = __('Wrong shortcode initialized', "survey-maker");
1406 }
1407
1408 if ($email_validation_error_text === 'Must be a valid email address') {
1409 $email_validation_error_text = __('Must be a valid email address', "survey-maker");
1410 }
1411
1412 if ($redirecting_after_text === 'Redirecting after') {
1413 $redirecting_after_text = __('Redirecting after', "survey-maker");
1414 }
1415
1416 $texts = array(
1417 'wrongShortcode' => $wrong_shortcode_text,
1418 'emailValidationError' => $email_validation_error_text,
1419 'redirectingAfter' => $redirecting_after_text,
1420 );
1421
1422 return $texts;
1423 }
1424
1425 public static function ays_set_survey_texts( $plugin_name, $settings ){
1426
1427 /*
1428 * Get survey buttons texts from database
1429 */
1430 global $wpdb;
1431
1432 $name_prefix = 'survey_';
1433
1434 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1435 $sql = "SELECT meta_value FROM ".$settings_table." WHERE meta_key = 'buttons_texts'";
1436 $result = $wpdb->get_var($sql);
1437 $settings_buttons_texts = ($result == "") ? array() : json_decode($result, true);
1438
1439 $settings_buttons_texts['next_button'] = (isset($settings_buttons_texts['next_button']) && $settings_buttons_texts['next_button'] != '') ? esc_attr($settings_buttons_texts['next_button']) : 'Next';
1440 $ays_next_button = (isset($settings['survey_next_button_each_text']) && $settings['survey_next_button_each_text'] != '') ? esc_attr($settings['survey_next_button_each_text']) : $settings_buttons_texts['next_button'];
1441
1442 $settings_buttons_texts['prev_button'] = (isset($settings_buttons_texts['prev_button']) && $settings_buttons_texts['prev_button'] != '') ? esc_attr($settings_buttons_texts['prev_button']) : 'Prev';
1443 $ays_previous_button = (isset($settings['survey_previous_button_each_text']) && $settings['survey_previous_button_each_text'] != '') ? esc_attr($settings['survey_previous_button_each_text']) : $settings_buttons_texts['prev_button'];
1444
1445 $settings_buttons_texts['clear_button'] = (isset($settings_buttons_texts['clear_button']) && $settings_buttons_texts['clear_button'] != '') ? esc_attr($settings_buttons_texts['clear_button']) : 'Clear selection';
1446 $ays_clear_button = (isset($settings['survey_clear_selection_button_each_text']) && $settings['survey_clear_selection_button_each_text'] != '') ? esc_attr($settings['survey_clear_selection_button_each_text']) : $settings_buttons_texts['clear_button'];
1447
1448 $settings_buttons_texts['finish_button'] = (isset($settings_buttons_texts['finish_button']) && $settings_buttons_texts['finish_button'] != '') ? esc_attr($settings_buttons_texts['finish_button']) : 'Finish';
1449 $ays_finish_button = (isset($settings['survey_finish_button_each_text']) && $settings['survey_finish_button_each_text'] != '') ? esc_attr($settings['survey_finish_button_each_text']) : $settings_buttons_texts['finish_button'];
1450
1451 $settings_buttons_texts['restart_button'] = (isset($settings_buttons_texts['restart_button']) && $settings_buttons_texts['restart_button'] != '') ? esc_attr($settings_buttons_texts['restart_button']) : 'Restart';
1452 $ays_restart_survey_button = (isset($settings['survey_restart_button_each_text']) && $settings['survey_restart_button_each_text'] != '') ? esc_attr($settings['survey_restart_button_each_text']) : $settings_buttons_texts['restart_button'];
1453
1454 $settings_buttons_texts['exit_button'] = (isset($settings_buttons_texts['exit_button']) && $settings_buttons_texts['exit_button'] != '') ? esc_attr($settings_buttons_texts['exit_button']) : 'Exit';
1455 $ays_exit_button = (isset($settings['survey_exit_button_each_text']) && $settings['survey_exit_button_each_text'] != '') ? esc_attr($settings['survey_exit_button_each_text']) : $settings_buttons_texts['exit_button'];
1456 $ays_login_button = (isset($settings_buttons_texts['login_button']) && $settings_buttons_texts['login_button'] != '') ? stripslashes( esc_attr($settings_buttons_texts['login_button']) ) : 'Log In';
1457
1458 $settings_buttons_texts['start_button'] = (isset($settings_buttons_texts['start_button']) && $settings_buttons_texts['start_button'] != '') ? esc_attr($settings_buttons_texts['start_button']) : 'Start';
1459 $ays_start_button = (isset($settings['survey_start_button_each_text']) && $settings['survey_start_button_each_text'] != '') ? stripslashes( esc_attr( $settings['survey_start_button_each_text'] ) ) : $settings_buttons_texts['start_button'];
1460
1461 $settings_buttons_texts['login_button'] = (isset($settings_buttons_texts['login_button']) && $settings_buttons_texts['login_button'] != '') ? esc_attr($settings_buttons_texts['login_button']) : 'Log in';
1462 $ays_login_button = (isset($settings['survey_login_button_each_text']) && $settings['survey_login_button_each_text'] != '') ? stripslashes( esc_attr( $settings['survey_login_button_each_text'] ) ) : $settings_buttons_texts['login_button'];
1463
1464 $ays_next_button_text = ($ays_next_button === 'Next') ? __('Next', "survey-maker") : $ays_next_button;
1465 $ays_previous_button_text = ($ays_previous_button === 'Prev') ? __('Prev', "survey-maker") : $ays_previous_button;
1466 $ays_clear_button_text = ($ays_clear_button === 'Clear selection') ? __('Clear selection', "survey-maker") : $ays_clear_button;
1467 $ays_finish_button_text = ($ays_finish_button === 'Finish') ? __('Finish', "survey-maker") : $ays_finish_button;
1468 $ays_restart_button_text = ($ays_finish_button === 'Restart') ? __('Restart', "survey-maker") : $ays_restart_survey_button;
1469 $ays_exit_button_text = ($ays_exit_button === 'Exit') ? __('Exit', "survey-maker") : $ays_exit_button;
1470 $ays_login_button_text = ($ays_login_button === 'Log In') ? __('Log In', "survey-maker") : $ays_login_button;
1471
1472 if ($ays_start_button === 'Start') {
1473 $ays_start_button_text = __('Start', "survey-maker");
1474 }else{
1475 $ays_start_button_text = $ays_start_button;
1476 }
1477
1478 $texts = array(
1479 'nextButton' => $ays_next_button_text,
1480 'previousButton' => $ays_previous_button_text,
1481 'clearButton' => $ays_clear_button_text,
1482 'finishButton' => $ays_finish_button_text,
1483 'restartButton' => $ays_restart_button_text,
1484 'exitButton' => $ays_exit_button_text,
1485 'loginButton' => $ays_login_button_text,
1486 'startButton' => $ays_start_button_text,
1487 );
1488 return $texts;
1489 }
1490
1491 public static function ays_survey_numbering_all( $numbering ){
1492 $keyword_arr = array();
1493 switch ($numbering) {
1494 case '1.':
1495
1496 $char_min_val = '1';
1497 $char_max_val = '100';
1498 for($x = $char_min_val; $x <= $char_max_val; $x++){
1499 $keyword_arr[] = $x .".";
1500 }
1501
1502 break;
1503 case '1)':
1504
1505 $char_min_val = '1';
1506 $char_max_val = '100';
1507 for($x = $char_min_val; $x <= $char_max_val; $x++){
1508 $keyword_arr[] = $x .")";
1509 }
1510
1511 break;
1512 case 'A.':
1513
1514 $char_min_val = 'A';
1515 $char_max_val = 'Z';
1516 for($x = $char_min_val; $x <= $char_max_val; $x++){
1517 $keyword_arr[] = $x .".";
1518 }
1519
1520 break;
1521 case 'A)':
1522
1523 $char_min_val = 'A';
1524 $char_max_val = 'Z';
1525 for($x = $char_min_val; $x <= $char_max_val; $x++){
1526 $keyword_arr[] = $x .")";
1527 }
1528
1529 break;
1530 case 'a.':
1531 $char_min_val = 'a';
1532 $char_max_val = 'z';
1533 for($x = $char_min_val; $x <= $char_max_val; $x++){
1534 $keyword_arr[] = $x .".";
1535 }
1536
1537 break;
1538 case 'a)':
1539
1540 $char_min_val = 'a';
1541 $char_max_val = 'z';
1542 for($x = $char_min_val; $x <= $char_max_val; $x++){
1543 $keyword_arr[] = $x .")";
1544 }
1545
1546 break;
1547
1548 default:
1549
1550 break;
1551 }
1552
1553 return $keyword_arr;
1554 }
1555
1556 public static function ays_survey_question_results_for_summary( $survey_id, $submission_ids = null ){
1557 global $wpdb;
1558
1559 if($survey_id === null){
1560 return array(
1561 'total_count' => 0,
1562 'questions' => array()
1563 );
1564 }
1565
1566 $answer_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "answers";
1567 $question_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "questions";
1568 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1569 $survey_section_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "sections";
1570 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "surveys";
1571 $submitions_questiions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1572
1573 $question_ids = "SELECT question_ids FROM {$surveys_table} WHERE id =". absint( $survey_id );
1574 $question_ids_results = $wpdb->get_var( $question_ids );
1575 $ays_question_id = ($question_ids_results != '') ? $question_ids_results : null;
1576
1577 if($ays_question_id == null){
1578 return array(
1579 'total_count' => 0,
1580 'questions' => array()
1581 );
1582 }
1583
1584 $questions_ids_arr = explode(',',$ays_question_id);
1585 $answer_id = "SELECT a.id, a.answer, COUNT(s_q.answer_id) AS answer_count
1586 FROM {$answer_table} AS a
1587 LEFT JOIN {$submitions_questiions_table} AS s_q
1588 ON a.id = s_q.answer_id
1589 WHERE s_q.survey_id=". absint( $survey_id ) ."
1590 GROUP BY a.id";
1591
1592 $answer_id_result = $wpdb->get_results($answer_id,'ARRAY_A');
1593
1594 $for_checkbox = "SELECT a.id, a.answer, COUNT(s_q.answer_id) AS answer_count
1595 FROM {$answer_table} AS a
1596 LEFT JOIN {$submitions_questiions_table} AS s_q
1597 ON a.id = s_q.answer_id OR FIND_IN_SET( a.id, s_q.user_answer )
1598 WHERE s_q.type = 'checkbox'
1599 AND s_q.survey_id=". absint( $survey_id ) ."
1600 GROUP BY a.id";
1601
1602 $for_checkbox_result = $wpdb->get_results($for_checkbox,'ARRAY_A');
1603
1604 $answer_count = array();
1605 $question_type = '';
1606 foreach ($answer_id_result as $key => $answer_count_by_id) {
1607 $ays_survey_answer_count = (isset($answer_count_by_id['answer_count']) && $answer_count_by_id['answer_count'] !="") ? absint(intval($answer_count_by_id['answer_count'])) : '';
1608 $answer_count[$answer_count_by_id['id']] = $ays_survey_answer_count;
1609 }
1610
1611 foreach ($for_checkbox_result as $key => $answer_count_by_id) {
1612 $ays_survey_answer_count = (isset($answer_count_by_id['answer_count']) && $answer_count_by_id['answer_count'] !="") ? absint(intval($answer_count_by_id['answer_count'])) : '';
1613 $answer_count[$answer_count_by_id['id']] = $ays_survey_answer_count;
1614 }
1615
1616 $question_by_ids = Survey_Maker_Data::get_question_by_ids( $questions_ids_arr );
1617
1618 $select_answer_q_type = "SELECT type, user_answer, id, question_id
1619 FROM {$submitions_questiions_table}
1620 WHERE user_answer != ''
1621 AND type != 'checkbox'
1622 AND survey_id=". absint( $survey_id );
1623
1624 $submission_answer_other = "SELECT question_id, answer_id, user_variant
1625 FROM {$submitions_questiions_table}
1626 WHERE user_variant != ''
1627 AND survey_id=". absint( $survey_id );
1628
1629 if( $submission_ids !== null ){
1630 if( is_array( $submission_ids ) ){
1631 $select_answer_q_type .= " AND submission_id IN (" . esc_sql( implode( ',', $submission_ids ) ) . ") ";
1632 $submission_answer_other .= " AND submission_id IN (" . esc_sql( implode( ',', $submission_ids ) ) . ") ";
1633 }
1634 }
1635
1636 $result_answers_q_type = $wpdb->get_results($select_answer_q_type,'ARRAY_A');
1637 $result_answers_other = $wpdb->get_results($submission_answer_other,'ARRAY_A');
1638 $text_answer = array();
1639 foreach($result_answers_q_type as $key => $result_answer_q_type){
1640 $text_answer[$result_answer_q_type['type']][$result_answer_q_type['question_id']][] = $result_answer_q_type['user_answer'];
1641 }
1642
1643 $other_answers = array();
1644 $other_answers_all = array();
1645 foreach($result_answers_other as $key => $result_answer_other){
1646 if( intval( $result_answer_other['answer_id'] ) == 0 ){
1647 $other_answers[$result_answer_other['question_id']][] = $result_answer_other['user_variant'];
1648 }
1649 $other_answers_all[$result_answer_other['question_id']][] = $result_answer_other['user_variant'];
1650 }
1651
1652 $text_types = array(
1653 'text',
1654 'short_text',
1655 'number',
1656 'phone',
1657 'star',
1658 'name',
1659 'email',
1660 'linear_scale',
1661 'star',
1662 'date',
1663 'time',
1664 'date_time',
1665 );
1666
1667 //Question types different charts
1668 $ays_submissions_count = array();
1669 $question_results = array();
1670
1671 $total_count = 0;
1672 foreach ($question_by_ids as $key => $question) {
1673
1674 $answers = $question->answers;
1675 $question_id = $question->id;
1676 $question_title = $question->question;
1677
1678 //questions
1679 $question_results[$question_id]['question_id'] = $question_id;
1680 $question_results[$question_id]['question'] = $question_title;
1681 $ays_answer = array();
1682 $question_answer_ids = array();
1683 foreach ($answers as $key => $answer) {
1684 $answer_id = $answer->id;
1685 $answer_title = $answer->answer;
1686
1687 $ays_answer[$answer_id] = isset( $answer_count[$answer_id] ) ? $answer_count[$answer_id] : 0;
1688 $question_answer_ids[$answer_id] = $answer_title;
1689 }
1690
1691 //sum of submissions count per questions
1692 if($question->type == "checkbox"){
1693 $sub_checkbox_count = self::ays_survey_get_submission_count($question->id, $question->type, $survey_id);
1694 $sum_of_count = $sub_checkbox_count;
1695 }else{
1696 $sum_of_count = array_sum( array_values( $ays_answer ) );
1697 }
1698
1699 $question_results[$question_id]['otherAnswers'] = isset( $other_answers[$question->id] ) ? $other_answers[$question->id] : array();
1700
1701 if( in_array( $question->type, $text_types ) ){
1702 $question_ls_options = json_decode($question->options, true);
1703
1704 if($question->type == 'star'){
1705 $scale_from = isset($question_ls_options['star_1']) && $question_ls_options['star_1'] != "" ? stripslashes($question_ls_options['star_1']) : "";
1706 $scale_to = isset($question_ls_options['star_2']) && $question_ls_options['star_2'] != "" ? stripslashes($question_ls_options['star_2']) : "";
1707 $scale_length = isset($question_ls_options['star_scale_length']) && $question_ls_options['star_scale_length'] != "" ? $question_ls_options['star_scale_length'] : "";
1708 $question_results[$question_id]['labels'] = array(
1709 'from' => $scale_from,
1710 'to' => $scale_to,
1711 'length' => $scale_length
1712 );
1713 }
1714 $question_results[$question_id]['answers'] = isset( $text_answer[$question->type] ) ? $text_answer[$question->type] : '';
1715 $question_results[$question_id]['answerTitles'] = isset( $text_answer[$question->type] ) ? $text_answer[$question->type] : '';
1716 $question_results[$question_id]['sum_of_answers_count'] = isset( $text_answer[$question->type][$question->id] ) ? count( $text_answer[$question->type][$question->id] ) : 0;
1717 $question_results[$question_id]['sum_of_same_answers'] = isset( $text_answer[$question->type][$question->id] ) ? array_count_values( $text_answer[$question->type][$question->id] ) : 0;
1718 }else{
1719 $question_results[$question_id]['answers'] = $ays_answer;
1720 $question_results[$question_id]['answerTitles'] = $question_answer_ids;
1721 $question_results[$question_id]['sum_of_answers_count'] = $sum_of_count;
1722 if( $sum_of_count == 0 ){
1723 $question_results[$question_id]['answers'] = array();
1724 }
1725 }
1726
1727 // Answers for charts
1728 if( !empty( $question_results[$question_id]['otherAnswers'] ) ){
1729 $question_results[$question_id]['answers'][0] = count( $question_results[$question_id]['otherAnswers'] );
1730 $question_results[$question_id]['answerTitles'][0] = __( '"Other" answer(s)', "survey-maker" );
1731 $question_results[$question_id]['same_other_count'] = array_count_values( $question_results[$question_id]['otherAnswers'] );
1732
1733 if($question->type == "radio" || $question_type == "yesorno"){
1734 $question_results[$question_id]['sum_of_answers_count'] += count( $question_results[$question_id]['otherAnswers'] );
1735 }
1736 }
1737 //
1738
1739 $total_count += intval( $question_results[$question_id]['sum_of_answers_count'] );
1740
1741 $question_results[$question_id]['question_type'] = $question->type;
1742 }
1743
1744 return array(
1745 'total_count' => $total_count,
1746 'questions' => $question_results
1747 );
1748 }
1749
1750 public static function ays_survey_get_last_submission_id_for_summary( $survey_id ){
1751 global $wpdb;
1752
1753 if($survey_id === null){
1754 return array();
1755 }
1756
1757 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1758
1759 //submission of each result
1760 $submission = "SELECT * FROM {$submitions_table} WHERE survey_id=". absint( $survey_id ) ." ORDER BY id DESC LIMIT 1 ";
1761 $last_submission = $wpdb->get_row( $submission, 'ARRAY_A' );
1762
1763 if( $last_submission == null ){
1764 return array();
1765 }
1766 return $last_submission;
1767 }
1768
1769 public static function ays_survey_individual_results_for_one_submission_for_summary( $submission, $survey ){
1770 global $wpdb;
1771 $survey_id = isset( $survey['id'] ) ? absint( intval( $survey['id'] ) ) : null;
1772
1773 if( is_null( $survey_id ) || empty( $submission )){
1774 return array(
1775 'sections' => array()
1776 );
1777 }
1778
1779 $submitions_questiions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1780
1781 $ays_individual_questions_for_one_submission = array();
1782 $question_answer_id = array();
1783 $submission_id = isset( $submission['id'] ) && $submission['id'] != '' ? $submission['id'] : null;
1784
1785 if( is_null( $submission_id ) ){
1786 return array(
1787 'sections' => array()
1788 );
1789 }
1790
1791 $checkbox_ids = '';
1792
1793 $individual_questions = "SELECT * FROM {$submitions_questiions_table} WHERE submission_id=" . absint( $submission_id );
1794 $individual_questions_results = $wpdb->get_results($individual_questions,'ARRAY_A');
1795
1796 // Survey questions IDs
1797 $question_ids = isset( $survey['question_ids'] ) && $survey['question_ids'] != '' ? $survey['question_ids'] : '';
1798
1799 // Section Ids
1800 $sections_ids = (isset( $survey['section_ids' ] ) && $survey['section_ids'] != '') ? $survey['section_ids'] : '';
1801
1802 $sections = Survey_Maker_Data::get_suervey_sections_with_questions( $sections_ids, $question_ids );
1803
1804 $text_types = array(
1805 'text',
1806 'short_text',
1807 'number',
1808 'phone',
1809 'star',
1810 'name',
1811 'email',
1812 'linear_scale',
1813 'star',
1814 'date',
1815 'time',
1816 );
1817
1818 foreach ($individual_questions_results as $key => $individual_questions_result) {
1819 if($individual_questions_result['type'] == 'checkbox'){
1820 $checkbox_ids = $individual_questions_result['user_answer'] != '' ? explode(',', $individual_questions_result['user_answer']) : array();
1821 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $checkbox_ids;
1822 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = isset($individual_questions_result['user_variant']) && $individual_questions_result['user_variant'] != '' ? $individual_questions_result['user_variant'] : '';
1823 }elseif( in_array( $individual_questions_result['type'], $text_types ) ){
1824 $question_answer_id[ $individual_questions_result['question_id'] ] = $individual_questions_result['user_answer'];
1825 if( $individual_questions_result['type'] == 'date' ){
1826 if( $individual_questions_result['user_answer'] != '' ){
1827 $question_answer_id[ $individual_questions_result['question_id'] ] = date( 'd . m . Y', strtotime( $individual_questions_result['user_answer'] ) );
1828 }else{
1829 $question_answer_id[ $individual_questions_result['question_id'] ] = '';
1830 }
1831 }
1832 elseif( $individual_questions_result['type'] == 'time' ){
1833 if( $individual_questions_result['user_answer'] != '' ){
1834 $question_answer_id[ $individual_questions_result['question_id'] ] = implode(" : ", explode( ":", $individual_questions_result['user_answer'] ));
1835 }else{
1836 $question_answer_id[ $individual_questions_result['question_id'] ] = '';
1837 }
1838 }
1839 }elseif($individual_questions_result['type'] == 'radio'){
1840 $other_answer = isset($individual_questions_result['user_variant']) && $individual_questions_result['user_variant'] != '' ? $individual_questions_result['user_variant'] : '';
1841 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = $other_answer;
1842 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1843 if( intval( $individual_questions_result['answer_id'] ) === 0 && $other_answer !== '' ){
1844 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = $other_answer;
1845 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1846 }elseif( intval( $individual_questions_result['answer_id'] ) === 0 && $other_answer === '' ){
1847 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = '';
1848 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = '-1';
1849 }else{
1850 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = '';
1851 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1852 }
1853 }else{
1854 $question_answer_id[ $individual_questions_result['question_id'] ] = $individual_questions_result['answer_id'];
1855 }
1856 }
1857
1858 $ays_individual_questions_for_one_submission['submission_id'] = $submission['id'];
1859 $ays_individual_questions_for_one_submission['questions'] = $question_answer_id;
1860 $ays_individual_questions_for_one_submission['sections'] = $sections;
1861
1862 return $ays_individual_questions_for_one_submission;
1863 }
1864
1865 public static function get_submission_count_and_ids_for_summary( $survey_id){
1866 global $wpdb;
1867
1868 if($survey_id === null){
1869 return false;
1870 }
1871 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1872
1873 //submission of each result
1874 $submission_ids = "SELECT id,
1875 (SELECT COUNT(id) FROM {$submitions_table} i
1876 WHERE i.survey_id=j.survey_id) AS count_submission
1877 FROM {$submitions_table} j
1878 WHERE survey_id=". absint( $survey_id ) ."
1879 ORDER BY id";
1880 $submission_ids_result = $wpdb->get_results($submission_ids,'ARRAY_A');
1881 $submission_count = '';
1882 $submissions_id_arr = array();
1883 foreach ($submission_ids_result as $key => $submission_id_result) {
1884 $submission_id_count = $submission_id_result['count_submission'];
1885 $submission_count = intval($submission_id_count);
1886 $submissions_id_arr[] = $submission_id_result['id'];
1887 }
1888 $submissions_id_str = implode(',', $submissions_id_arr );
1889
1890 $submission_count_and_ids = array(
1891 'submission_count' => $submission_count,
1892 'submission_ids' => $submissions_id_str,
1893 'submission_ids_arr' => $submissions_id_arr,
1894 );
1895
1896 return $submission_count_and_ids;
1897 }
1898
1899 public static function ays_survey_get_submission_count($id , $type , $survey_id){
1900 global $wpdb;
1901 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1902 $submitions_q_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1903 $results = array();
1904
1905 $sql = "SELECT submission_id AS sub_count
1906 FROM {$submitions_q_table}
1907 WHERE question_id = ". absint( $id ) ."
1908 AND survey_id = ". absint( $survey_id ) ."";
1909
1910 if( $type == 'checkbox' ){
1911 $sql .= " AND user_answer != '' ";
1912 }
1913
1914 $sql .= " GROUP BY submission_id ";
1915 $results = $wpdb->get_results( $sql, 'ARRAY_A' );
1916
1917 $submission_count = count( $results );
1918 return $submission_count;
1919 }
1920
1921 public static function ays_survey_copy_text_formater( $info_array ) {
1922 $return = "`\n";
1923 foreach ( $info_array as $section => $details ) {
1924 $return .= sprintf( "%s: %s", $section, $details );
1925 $return .= "\n";
1926 }
1927 $return .= '`';
1928 return $return;
1929 }
1930
1931 public static function ays_survey_detected_device_chart() {
1932 $device = 'desktop';
1933 $isMobile = preg_match("/(iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile)/i", $_SERVER["HTTP_USER_AGENT"]);
1934 $isTablet = preg_match("/(ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle)/i", $_SERVER["HTTP_USER_AGENT"]);
1935
1936 if($isMobile){
1937 $device = 'mobile';
1938 }else if($isTablet){
1939 $device = 'tablet';
1940 }else{
1941 $device = 'desktop';
1942 }
1943 return $device;
1944 }
1945
1946 public static function ays_survey_get_passed_users_count( $survey_id ) {
1947 global $wpdb;
1948 $submissions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1949 // Get passed users
1950 $sql = "SELECT COUNT(id) AS users_count FROM ".$submissions_table."
1951 WHERE survey_id = ".$survey_id." AND user_id != 0
1952 GROUP BY user_id";
1953 $result = $wpdb->get_results($sql);
1954 // Get passed guests count
1955 $sql2 = "SELECT COUNT(id) FROM ".$submissions_table." WHERE `user_id` = 0 AND `survey_id` = ".$survey_id;
1956 $result2 = $wpdb->get_var($sql2);
1957 $all_count = intval(count($result)) + intval($result2);
1958 return $all_count;
1959 }
1960
1961 public static function get_template_part( $slug, $name = null, $args = array(), $path = 'admin' ) {
1962 /**
1963 * Fires before the specified template part file is loaded.
1964 *
1965 * The dynamic portion of the hook name, `$slug`, refers to the slug name
1966 * for the generic template part.
1967 *
1968 * @since 1.0.0
1969 * @since 1.0.0 The `$args` parameter was added.
1970 *
1971 * @param string $slug The slug name for the generic template.
1972 * @param string|null $name The name of the specialized template.
1973 * @param array $args Additional arguments passed to the template.
1974 */
1975
1976 $templates = array();
1977 $name = (string) $name;
1978 if ( '' !== $name ) {
1979 $templates[] = "{$slug}-{$name}.php";
1980 }
1981
1982 $templates[] = "{$slug}.php";
1983
1984 /**
1985 * Fires before an attempt is made to locate and load a template part.
1986 *
1987 * @since 1.0.0
1988 * @since 1.0.0 The `$args` parameter was added.
1989 *
1990 * @param string $slug The slug name for the generic template.
1991 * @param string $name The name of the specialized template.
1992 * @param string[] $templates Array of template files to search for, in order.
1993 * @param array $args Additional arguments passed to the template.
1994 */
1995 do_action( 'ays_sm_get_template_part', $slug, $name, $templates, $path, $args );
1996
1997 if ( ! self::locate_template( $templates, true, false, $path, $args ) ) {
1998 return false;
1999 }
2000 }
2001
2002 public static function locate_template( $template_names, $load = false, $require_once = true, $path = 'admin', $args = array() ) {
2003 $located = '';
2004 foreach ( (array) $template_names as $template_name ) {
2005 if ( ! $template_name ) {
2006 continue;
2007 }
2008
2009 $path = $path == 'public' ? SURVEY_MAKER_PUBLIC_PATH : SURVEY_MAKER_ADMIN_PATH;
2010
2011 if ( file_exists( $path . '/' . $template_name ) ) {
2012 $located = $path . '/' . $template_name;
2013 break;
2014 } elseif ( file_exists( $path . '/' . $template_name ) ) {
2015 $located = $path . '/' . $template_name;
2016 break;
2017 }
2018 }
2019 if ( $load && '' !== $located ) {
2020
2021 self::load_template( $located, $require_once, $args );
2022 }
2023
2024 return $located;
2025 }
2026
2027 public static function load_template( $_template_file, $require_once = true, $args = array() ) {
2028 if ( $require_once ) {
2029
2030 require_once $_template_file;
2031 } else {
2032 require $_template_file;
2033 }
2034 }
2035
2036
2037 public static function get_submission_count_and_ids( $survey_id, $filters = array() ){
2038 global $wpdb;
2039
2040 if($survey_id === null){
2041 return false;
2042 }
2043 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
2044
2045 $filters_where_condition = "";
2046 if (isset($filters['is_filter']) && $filters['is_filter']) {
2047 $filters_where_condition = self::get_filters_where_condition($filters);
2048 }
2049
2050 //submission of each result
2051 $submission_ids = "SELECT id
2052 FROM {$submitions_table} j
2053 WHERE survey_id=". absint( $survey_id ) . $filters_where_condition . "
2054 ORDER BY id";
2055 $submission_ids_result = $wpdb->get_results($submission_ids,'ARRAY_A');
2056
2057 $submission_count_sql = "SELECT COUNT(id) AS count_submission
2058 FROM {$submitions_table}
2059 WHERE survey_id=". absint( $survey_id ) . $filters_where_condition ." ";
2060 $submission_count_result = $wpdb->get_var($submission_count_sql);
2061 $submission_count = '';
2062 $submissions_id_arr = array();
2063
2064 foreach ($submission_ids_result as $key => $submission_id_result) {
2065 $submission_count = intval($submission_count_result);
2066 $submissions_id_arr[] = $submission_id_result['id'];
2067 }
2068 $submissions_id_str = implode(',', $submissions_id_arr );
2069
2070 $submission_count_and_ids = array(
2071 'submission_count' => $submission_count,
2072 'submission_ids' => $submissions_id_str,
2073 'submission_ids_arr' => $submissions_id_arr,
2074 );
2075
2076 return $submission_count_and_ids;
2077 }
2078
2079 // Check users cookie
2080 public static function ays_survey_set_cookie($attr){
2081 $cookie_name = $attr['name'].$attr['id'];
2082 $cookie_value = $attr['title'];
2083 $cookie_value = isset( $attr['attempts_count'] ) ? $attr['attempts_count'] : 1;
2084 self::ays_survey_remove_cookie( $attr );
2085 $cookie_expiration = current_time('timestamp') + (1 * 365 * 24 * 60 * 60);
2086 setcookie($cookie_name, $cookie_value, $cookie_expiration, '/');
2087 }
2088
2089 public static function ays_survey_remove_cookie($attr){
2090 $cookie_name = $attr['name'].$attr['id'];
2091 if(isset($_COOKIE[$cookie_name])){
2092 unset($_COOKIE[$cookie_name]);
2093 $cookie_expiration = current_time('timestamp') - 1;
2094 setcookie($cookie_name, null, $cookie_expiration, '/');
2095 }
2096 }
2097
2098 public static function ays_survey_check_cookie($attr){
2099 $cookie_name = $attr['name'].$attr['id'];
2100 if(isset($_COOKIE[$cookie_name])){
2101 if( isset( $attr['increase_count'] ) && $attr['increase_count'] == true ){
2102 $attr['attempts_count'] = intval( $_COOKIE[$cookie_name] ) + 1;
2103 self::ays_survey_set_cookie( $attr );
2104 }
2105 return true;
2106 }
2107 return false;
2108 }
2109
2110 public static function get_limit_cookie_count($attr){
2111 $cookie_name = $attr['name'].$attr['id'];
2112 if(isset($_COOKIE[$cookie_name])){
2113 return intval( $_COOKIE[ $cookie_name ] );
2114 }
2115 return false;
2116 }
2117
2118 public static function get_user_profile_data(){
2119
2120 $user_first_name = '';
2121 $user_last_name = '';
2122 $user_nickname = '';
2123
2124 $user_id = get_current_user_id();
2125 if($user_id != 0){
2126 $usermeta = get_user_meta( $user_id );
2127
2128 if($usermeta !== null){
2129 $user_first_name = (isset($usermeta['first_name'][0]) && $usermeta['first_name'][0] != '' ) ? sanitize_text_field( $usermeta['first_name'][0] ) : '';
2130 $user_last_name = (isset($usermeta['last_name'][0]) && $usermeta['last_name'][0] != '' ) ? sanitize_text_field( $usermeta['last_name'][0] ) : '';
2131 $user_nickname = (isset($usermeta['nickname'][0]) && $usermeta['nickname'][0] != '' ) ? sanitize_text_field( $usermeta['nickname'][0] ) : '';
2132 }
2133 }
2134
2135 $message_data = array(
2136 'user_first_name' => $user_first_name,
2137 'user_last_name' => $user_last_name,
2138 'user_nickname' => $user_nickname,
2139 );
2140
2141 $current_user_data = get_userdata( $user_id );
2142 $user_display_name = "";
2143 $user_wordpress_roles = '';
2144 $user_website_url = '';
2145 $user_email = '';
2146
2147 if ( ! is_null( $current_user_data ) && $current_user_data ) {
2148 $user_display_name = ( isset( $current_user_data->data->display_name ) && $current_user_data->data->display_name != '' ) ? sanitize_text_field( $current_user_data->data->display_name ) : "";
2149 $user_email = ( isset( $current_user_data->data->user_email ) && $current_user_data->data->user_email != '' ) ? sanitize_text_field( $current_user_data->data->user_email ) : "";
2150 $user_wordpress_roles = ( isset( $current_user_data->roles ) && ! empty( $current_user_data->roles ) ) ? $current_user_data->roles : "";
2151 if ( !empty( $user_wordpress_roles ) && $user_wordpress_roles != "" ) {
2152 if ( is_array( $user_wordpress_roles ) ) {
2153 $user_wordpress_roles = implode(",", $user_wordpress_roles);
2154 }
2155 }
2156 $user_website_url = ( isset( $current_user_data->user_url ) && ! empty( $current_user_data->user_url ) ) ? $current_user_data->user_url : "";
2157 }
2158
2159 $message_data['user_display_name'] = $user_display_name;
2160 $message_data['user_wordpress_roles'] = $user_wordpress_roles;
2161 $message_data['user_website_url'] = $user_website_url;
2162 $message_data['user_wordpress_email'] = $user_email;
2163 $message_data['user_ip_address'] = self::get_user_ip();
2164
2165 return $message_data;
2166 }
2167
2168 public static function get_survey_results_count_by_id($id){
2169 global $wpdb;
2170
2171 $sql = "SELECT COUNT(*) AS res_count
2172 FROM {$wpdb->prefix}ayssurvey_submissions
2173 WHERE survey_id=". $id ." ";
2174
2175 $quiz = $wpdb->get_row($sql, 'ARRAY_A');
2176
2177 return $quiz;
2178 }
2179
2180 public static function ays_survey_is_elementor(){
2181 if( isset( $_GET['action'] ) && $_GET['action'] == 'elementor' ){
2182 $is_elementor = true;
2183 }elseif( isset( $_REQUEST['elementor-preview'] ) && $_REQUEST['elementor-preview'] != '' ){
2184 $is_elementor = true;
2185 }else{
2186 $is_elementor = false;
2187 }
2188
2189 if ( ! $is_elementor ) {
2190 $is_elementor = ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ? true : false;
2191 }
2192
2193 return $is_elementor;
2194 }
2195
2196 public static function ays_survey_is_editor(){
2197 $is_editor = false;
2198 if( isset( $_GET['action'] ) && ( $_GET['action'] == 'add' || $_GET['action'] == 'edit' ) ){
2199 if ( isset( $_GET['post'] ) && absint( $_GET['post'] ) > 0 ) {
2200 $is_editor = true;
2201 }
2202 } elseif ( isset( $_GET['context'] ) && ( $_GET['context'] == 'add' || $_GET['context'] == 'edit' ) ) {
2203 if( isset( $_GET['post_id'] ) & absint( $_GET['post_id'] ) > 0 ){
2204 $is_editor = true;
2205 }
2206 }
2207
2208 return $is_editor;
2209 }
2210
2211 // Retrieves the attachment ID from the file URL
2212 public static function ays_survey_get_image_id_by_url( $image_url ) {
2213 global $wpdb;
2214
2215 $image_alt_text = "";
2216 if ( !empty( $image_url ) ) {
2217
2218 $re = '/-\d+[Xx]\d+\./';
2219 $subst = '.';
2220
2221 $image_url = preg_replace($re, $subst, $image_url, 1);
2222
2223 $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
2224 if ( !is_null( $attachment ) && !empty( $attachment ) ) {
2225
2226 $image_id = (isset( $attachment[0] ) && $attachment[0] != "") ? absint( $attachment[0] ) : "";
2227 if ( $image_id != "" ) {
2228 $image_alt_text = self::ays_survey_get_image_alt_text_by_id( $image_id );
2229 }
2230 }
2231 }
2232
2233 return $image_alt_text;
2234 }
2235
2236 public static function ays_survey_get_image_alt_text_by_id( $image_id ) {
2237
2238 $image_data = "";
2239 if ( $image_id != "" ) {
2240
2241 $result = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);
2242 if ( $result && $result != "" ) {
2243 $image_data = esc_attr( $result );
2244 }
2245 }
2246
2247 return $image_data;
2248 }
2249
2250 public static function get_user_by_ip($id){
2251 global $wpdb;
2252 $user_ip = self::get_user_ip();
2253 $sql = "SELECT COUNT(*)
2254 FROM `{$wpdb->prefix}ayssurvey_submissions`
2255 WHERE `user_ip` = '$user_ip'
2256 AND `survey_id` = $id";
2257 $result = $wpdb->get_var($sql);
2258 return $result;
2259 }
2260
2261 public static function get_surveys_by_category( $id ){
2262 global $wpdb;
2263
2264 $id = ( isset( $id ) && $id != '' ) ? absint( intval( $id ) ) : null;
2265 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
2266 $categories_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "survey_categories";
2267
2268 $results = '';
2269
2270 if($id != null){
2271 $sql = "SELECT *, s.`title`, s.`id`, s.`options` FROM `{$surveys_table}` AS s LEFT JOIN `{$categories_table}` AS c ON FIND_IN_SET(c.`id`, s. `category_ids` ) AND c.`status` = 'published' AND s.`status` = 'published' WHERE c.`id` = " . esc_sql( $id );
2272 $results = $wpdb->get_results( $sql, 'ARRAY_A');
2273 }
2274
2275 return $results;
2276 }
2277
2278 public static function survey_lazy_loading_for_images( $toggle ){
2279 if($toggle){
2280 return "loading='lazy'";
2281 }
2282 return '';
2283 }
2284
2285 public static function survey_no_items_list_tables() {
2286 if( isset( $_GET['status'] ) && ($_GET['status'] == 'deleted' || $_GET['status'] == 'restored')){
2287 $url = remove_query_arg( array('fstatus', 'status', '_wpnonce') );
2288 $url = esc_url_raw( $url );
2289 wp_redirect( $url );
2290 }
2291 else{
2292 echo esc_html__( 'There are no surveys yet.', "survey-maker" );
2293 }
2294 }
2295
2296 public static function survey_get_loader($type , $loading = ''){
2297 switch( $type ){
2298 case 'default':
2299 $survey_loader_html = "<div data-class='lds-ellipsis' data-role='loader' class='lds-ellipsis ays-survey-wait-loading-loader'><div></div><div></div><div></div><div></div></div>";
2300 break;
2301 case 'circle':
2302 $survey_loader_html = "<div data-class='lds-circle' data-role='loader' class='lds-circle ays-survey-wait-loading-loader'></div>";
2303 break;
2304 case 'dual_ring':
2305 $survey_loader_html = "<div data-class='lds-dual-ring' data-role='loader' class='lds-dual-ring ays-survey-wait-loading-loader'></div>";
2306 break;
2307 case 'facebook':
2308 $survey_loader_html = "<div data-class='lds-facebook' data-role='loader' class='lds-facebook ays-survey-wait-loading-loader'><div></div><div></div><div></div></div>";
2309 break;
2310 case 'hourglass':
2311 $survey_loader_html = "<div data-class='lds-hourglass' data-role='loader' class='lds-hourglass ays-survey-wait-loading-loader'></div>";
2312 break;
2313 case 'ripple':
2314 $survey_loader_html = "<div data-class='lds-ripple' data-role='loader' class='lds-ripple ays-survey-wait-loading-loader'><div></div><div></div></div>";
2315 break;
2316 case 'snake':
2317 $survey_loader_html = '<div class="ays-survey-loader-snake ays-survey-wait-loading-loader" data-class="ays-survey-loader-snake" data-role="loader"><div></div><div></div><div></div><div></div><div></div><div></div></div>';
2318 break;
2319 // case 'text':
2320 // $survey_loader_html = '<div class="ays-survey-loader ays-survey-loader-with-text '.$custom_class.'" data-class="ays-survey-loader-text" data-role="loader">'.$text.'</div>';
2321 // break;
2322 // case 'custom_gif':
2323 // $survey_loader_html = '<div class="ays-survey-loader ays-survey-loader-with-custom-gif '.$custom_class.'" data-class="ays-survey-loader-cistom-gif" data-role="loader"><img src="'.$gif.'" '.$loading.' style="width: '.$gif_width.'px;object-fit:cover;"></div>';
2324 // break;
2325 default:
2326 $survey_loader_html = "<div data-class='lds-ellipsis' data-role='loader' class='lds-ellipsis ays-survey-wait-loading-loader'><div></div><div></div><div></div><div></div></div>";
2327 break;
2328 }
2329 return $survey_loader_html;
2330 }
2331
2332 public static function ays_set_survey_message_variables_data( $id, $survey, $settings_options ){
2333
2334 /*
2335 * Survey message variables for Start Page
2336 */
2337
2338 $survey = (array)$survey;
2339
2340 // Survey options
2341 $options = ( json_decode($survey['options'], true) != null ) ? json_decode($survey['options'], true) : array();
2342
2343 // General Setting's Options
2344
2345 // Do not store IP adressess
2346 $disable_user_ip = (isset($settings_options['disable_user_ip']) && $settings_options['disable_user_ip'] == 'on') ? true : false;
2347
2348 // Survey title
2349 $survey_title = (isset( $survey['title'] ) && $survey['title'] != "") ? stripslashes( sanitize_text_field($survey['title']) ) : "";
2350
2351 // Survey create date
2352 $survey_creation_date = (isset($survey['date_created']) && $survey['date_created'] != '') ? sanitize_text_field( $survey['date_created'] ) : "";
2353 if( $survey_creation_date != "" ){
2354 $survey_creation_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_creation_date ) );
2355 }
2356
2357 // Survey modified date
2358 $survey_modified_date = (isset($survey['date_modified']) && $survey['date_modified'] != '') ? sanitize_text_field( $survey['date_modified'] ) : "";
2359 if( $survey_modified_date != "" ){
2360 $survey_modified_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_modified_date ) );
2361 }
2362
2363 // Current time
2364 $survey_current_time = explode( ' ', current_time( 'mysql' ) );
2365 $survey_current_time_only = ($survey_current_time[1]) ? $survey_current_time[1] : '';
2366
2367 // Get survey author
2368 $current_survey_user_data = get_userdata( $survey['author_id'] );
2369 $current_survey_author = '';
2370 $current_survey_author_email = '';
2371 if ( isset( $current_survey_user_data ) && $current_survey_user_data ) {
2372 // Get survey author name
2373 $current_survey_author = ( isset( $current_survey_user_data->data->display_name ) && $current_survey_user_data->data->display_name != '' ) ? sanitize_text_field( $current_survey_user_data->data->display_name ) : "";
2374 // Get survey author email
2375 $current_survey_author_email = ( isset( $current_survey_user_data->data->user_email ) && $current_survey_user_data->data->user_email != '' ) ? sanitize_text_field( $current_survey_user_data->data->user_email ) : "";
2376 }
2377
2378 $questions_count = (isset( $survey['questions_count'] ) && $survey['questions_count'] != "") ? stripslashes( sanitize_text_field($survey['questions_count']) ) : 0;
2379
2380 $survey_question_count = self::get_survey_questions_count($id);
2381 $survey_sections_count = self::get_survey_sections_count($id);
2382 $survey_passed_users_count = self::ays_survey_get_passed_users_count($id);
2383
2384 // WP home page url
2385 $home_main_url = home_url();
2386 $wp_home_page_url = '<a href="'.$home_main_url.'" target="_blank">'.$home_main_url.'</a>';
2387
2388 $survey_user_information = self::get_user_profile_data();
2389 // Get user first name
2390 $user_first_name = (isset( $survey_user_information['user_first_name'] ) && $survey_user_information['user_first_name'] != "") ? $survey_user_information['user_first_name'] : '';
2391
2392 // Get user last name
2393 $user_last_name = (isset( $survey_user_information['user_last_name'] ) && $survey_user_information['user_last_name'] != "") ? $survey_user_information['user_last_name'] : '';
2394
2395 // Get user nick name
2396 $user_nick_name = (isset( $survey_user_information['user_nickname'] ) && $survey_user_information['user_nickname'] != "") ? $survey_user_information['user_nickname'] : '';
2397
2398 // Get display name
2399 $user_display_name = (isset( $survey_user_information['user_display_name'] ) && $survey_user_information['user_display_name'] != "") ? $survey_user_information['user_display_name'] : '';
2400
2401 // User Wordpress role
2402 $user_wordpress_roles = (isset( $survey_user_information['user_wordpress_roles'] ) && $survey_user_information['user_wordpress_roles'] != "") ? $survey_user_information['user_wordpress_roles'] : '';
2403
2404 // User ip address
2405 $user_ip_address = "";
2406 if($disable_user_ip){
2407 $user_ip_address = '';
2408 }else{
2409 $user_ip_address = self::get_user_ip();
2410 }
2411
2412 // User wordpress email
2413 $user_wordpress_email = (isset( $survey_user_information['user_wordpress_email'] ) && $survey_user_information['user_wordpress_email'] != "") ? esc_attr($survey_user_information['user_wordpress_email']) : '';
2414
2415 $super_admin_email = get_option('admin_email');
2416
2417 $message_data = array(
2418 'survey_title' => $survey_title,
2419 'survey_id' => $id,
2420 'questions_count' => $questions_count,
2421 'current_time' => $survey_current_time_only,
2422 'sections_count' => $survey_sections_count,
2423 'users_count' => $survey_passed_users_count,
2424 'users_first_name' => $user_first_name,
2425 'users_last_name' => $user_last_name,
2426 'users_nick_name' => $user_nick_name,
2427 'users_display_name' => $user_display_name,
2428 'users_ip_address' => $user_ip_address,
2429 'user_wordpress_roles' => $user_wordpress_roles,
2430 'creation_date' => $survey_creation_date,
2431 'modified_date' => $survey_modified_date,
2432 'current_survey_author' => $current_survey_author,
2433 'current_survey_author_email' => $current_survey_author_email,
2434 'current_survey_page_link' => $current_survey_author_email,
2435 'admin_email' => $super_admin_email,
2436 'home_page_url' => $wp_home_page_url,
2437 );
2438
2439 return $message_data;
2440 }
2441
2442 public static function survey_sanitize_specific_content($content) {
2443 // Pattern to match <script> tags, dangerous attributes, and potential SVG exploits
2444 $pattern = '/<script.*?>.*?<\/script>|<[^>]+(?:\bon\w+\s*=\s*|attributeName\s*=\s*[^>]*>)/is';
2445
2446 // Callback function to convert matched tags into text
2447 $callback = function($matches) {
2448 // Convert characters to their HTML entities to render them as text
2449 return htmlspecialchars($matches[0], ENT_QUOTES, 'UTF-8');
2450 };
2451
2452 // Replace the matched patterns with their sanitized text equivalent
2453 $sanitized_content = preg_replace_callback($pattern, $callback, $content);
2454
2455 return $sanitized_content;
2456 }
2457
2458 // Sanitize data by admin level
2459 public static function admin_level_sanitize($data) {
2460
2461 if (is_multisite() && is_super_admin()) {
2462 return stripslashes($data);
2463
2464 } elseif (!is_multisite() && current_user_can('unfiltered_html')) {
2465 return stripslashes($data);
2466
2467 }
2468 return wp_kses_post($data);
2469 }
2470
2471 public static function ays_survey_pb_detect_mobile_device(){
2472 $useragent = $_SERVER['HTTP_USER_AGENT'];
2473 $flag = false;
2474 if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i',$useragent)||preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))){
2475 $flag = true;
2476 }
2477 return $flag;
2478 }
2479
2480 public static function ays_survey_pb_detect_tablet_device(){
2481 $flag = false;
2482 if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
2483 $flag = true;
2484 }
2485 return $flag;
2486 }
2487
2488 public static function get_allowed_tags_for_loader() {
2489 return array(
2490 'span' => array('class' => array()),
2491 'img' => array('src' => array(), 'alt' => array()),
2492 );
2493 }
2494
2495 public static function ays_survey_allowed_html() {
2496 $additionalAllowedTags = wp_kses_allowed_html('post');
2497 return array_merge(
2498 $additionalAllowedTags,
2499 array(
2500 'div' => array(
2501 'class' => true,
2502 'id' => true,
2503 'style' => true,
2504 'data-*' => true,
2505 'aria-selected' => true,
2506 ),
2507 'svg' => array(
2508 'class' => true,
2509 'style' => true,
2510 'width' => true,
2511 'height' => true,
2512 'viewBox' => true,
2513 'viewbox' => true,
2514 'xmlns' => true,
2515 'fill' => true,
2516 'stroke' => true,
2517 'stroke-width' => true,
2518 'stroke-linecap' => true,
2519 'stroke-linejoin' => true,
2520 ),
2521 'path' => array(
2522 'class' => true,
2523 'd' => true,
2524 'fill' => true,
2525 'fill-rule' => true,
2526 'clip-rule' => true,
2527 'stroke-width' => true,
2528 'stroke-linecap' => true,
2529 ),
2530 'circle' => array(
2531 'style' => true,
2532 'id' => true,
2533 'class' => true,
2534 'r' => true,
2535 'cx' => true,
2536 'cy' => true,
2537 ),
2538 'rect' => array(
2539 'class' => true,
2540 'x' => true,
2541 'y' => true,
2542 'width' => true,
2543 'height' => true,
2544 'rx' => true,
2545 'fill' => true,
2546 'stroke' => true,
2547 'style' => true,
2548 'transform' => true,
2549 ),
2550 'defs' => array(
2551 'class' => true,
2552 'width' => true,
2553 'height' => true,
2554 'fill' => true,
2555 'style' => true,
2556 ),
2557 'pattern' => array(
2558 'class' => true,
2559 'id' => true,
2560 'width' => true,
2561 'height' => true,
2562 'patternContentUnits' => true,
2563 'patterncontentunits' => true,
2564 'style' => true,
2565 ),
2566 'use' => array(
2567 'class' => true,
2568 'id' => true,
2569 'xlink' => true,
2570 'xlink:href' => true,
2571 'transform' => true,
2572 'style' => true,
2573 ),
2574 'image' => array(
2575 'class' => true,
2576 'id' => true,
2577 'xlink' => true,
2578 'xlink:href' => true,
2579 'width' => true,
2580 'height' => true,
2581 'style' => true,
2582 ),
2583 'video' => array(
2584 'class' => true,
2585 'id' => true,
2586 'controls' => true,
2587 'style' => true,
2588 ),
2589 'source' => array(
2590 'class' => true,
2591 'id' => true,
2592 'src' => true,
2593 'style' => true,
2594 ),
2595 'form' => array(
2596 'name' => true,
2597 'id' => true,
2598 'action' => true,
2599 'method' => true,
2600 'data-*' => true,
2601 'style' => true,
2602 ),
2603 'input' => array(
2604 'id' => true,
2605 'name' => true,
2606 'class' => true,
2607 'type' => true,
2608 'value' => true,
2609 'size' => true,
2610 'required' => true,
2611 'readonly' => true,
2612 'data-*' => true,
2613 'style' => true,
2614 ),
2615 'select' => array(
2616 'id' => true,
2617 'name' => true,
2618 'class' => true,
2619 'type' => true,
2620 'value' => true,
2621 'size' => true,
2622 'required' => true,
2623 'readonly' => true,
2624 'data-*' => true,
2625 'style' => true,
2626 ),
2627 'option' => array(
2628 'id' => true,
2629 'class' => true,
2630 'type' => true,
2631 'value' => true,
2632 'size' => true,
2633 'required' => true,
2634 'readonly' => true,
2635 'data-*' => true,
2636 'style' => true,
2637 ),
2638 'progress' => array(
2639 'id' => true,
2640 'class' => true,
2641 'max' => true,
2642 'value' => true,
2643 'data-*' => true,
2644 'style' => true,
2645 ),
2646 'img' => array(
2647 'id' => true,
2648 'class' => true,
2649 'loading' => true,
2650 'decoding' => true,
2651 'src' => true,
2652 'sizes' => true,
2653 'srcset' => true,
2654 'width' => true,
2655 'height' => true,
2656 ),
2657 'a' => array(
2658 'aria-selected' => true,
2659 'data-*' => true,
2660 'style' => true,
2661 'target' => true,
2662 ),
2663 ),
2664 $additionalAllowedTags
2665 );
2666 }
2667
2668 public static function ays_survey_custom_allowed_html() {
2669 $additionalAllowedTags = self::ays_survey_allowed_html();
2670 return array_merge(
2671 $additionalAllowedTags,
2672 array(
2673 'iframe' => array(
2674 'class' => true,
2675 'id' => true,
2676 'width' => true,
2677 'height' => true,
2678 'src' => true,
2679 'title' => true,
2680 'frameborder' => true,
2681 'allow' => true,
2682 'allowfullscreen' => true,
2683 'loading' => true,
2684 'referrerpolicy' => true,
2685 'style' => true,
2686 ),
2687 'audio' => array(
2688 'class' => true,
2689 'id' => true,
2690 'controls' => true,
2691 'autoplay' => true,
2692 'loop' => true,
2693 'muted' => true,
2694 'preload' => true,
2695 'src' => true,
2696 'style' => true,
2697 ),
2698 'source' => array(
2699 'src' => true,
2700 'type' => true,
2701 ),
2702 'track' => array(
2703 'kind' => true,
2704 'src' => true,
2705 'srclang' => true,
2706 'label' => true,
2707 'default' => true,
2708 ),
2709 'video' => array(
2710 'class' => true,
2711 'id' => true,
2712 'width' => true,
2713 'height' => true,
2714 'controls' => true,
2715 'autoplay' => true,
2716 'loop' => true,
2717 'muted' => true,
2718 'poster' => true,
2719 'preload' => true,
2720 'src' => true,
2721 'style' => true,
2722 ),
2723 'picture' => array(
2724 'class' => true,
2725 'id' => true,
2726 ),
2727 'figure' => array(
2728 'class' => true,
2729 'id' => true,
2730 'style' => true,
2731 ),
2732 'figcaption' => array(
2733 'class' => true,
2734 'id' => true,
2735 'style' => true,
2736 ),
2737 ),
2738 $additionalAllowedTags
2739 );
2740 }
2741
2742 }
2743