PluginProbe
Survey Maker by AYS / 5.2.3.0
Survey Maker by AYS v5.2.3.0
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.3.0, at includes/class-survey-maker-data.php

2,752 lines 164.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 // Password survey
752 $options[ $name_prefix . 'enable_password' ] = ! isset( $options[ $name_prefix . 'enable_password' ] ) ? 'off' : $options[ $name_prefix .'enable_password' ];
753 $settings[ $name_prefix . 'enable_password' ] = (isset( $options[ $name_prefix . 'enable_password' ] ) && $options[ $name_prefix . 'enable_password' ] == 'on') ? true : false;
754 $settings[ $name_prefix . 'password_survey' ] = (isset( $options[ $name_prefix . 'password_survey' ] ) && $options[ $name_prefix . 'password_survey' ] != '') ? $options[ $name_prefix .'password_survey' ] : '';
755 $settings[ $name_prefix . 'password_type' ] = (isset( $options[ $name_prefix . 'password_type' ] ) && $options[ $name_prefix . 'password_type' ] != '') ? $options[ $name_prefix .'password_type' ] : 'general';
756
757 // Message - Password
758 $settings[ $name_prefix . 'password_message' ] = (isset($options[ $name_prefix . 'password_message' ]) && $options[ $name_prefix . 'password_message' ] != '') ? stripslashes( wpautop( $options[ $name_prefix . 'password_message' ] ) ) : '';
759
760 // Auto numbering
761 $settings[ $name_prefix . 'auto_numbering' ] = (isset($options[ $name_prefix . 'auto_numbering' ]) && $options[ $name_prefix . 'auto_numbering' ] != '') ? stripslashes( $options[ $name_prefix . 'auto_numbering' ] ) : 'none';
762
763 // Loader custom gif
764 $settings[ $name_prefix . 'loader_gif' ] = (isset($options[ $name_prefix . 'loader_gif' ]) && $options[ $name_prefix . 'loader_gif' ] != '') ? esc_url( $options[ $name_prefix . 'loader_gif' ] ) : '';
765 $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';
766
767
768 return $settings;
769 }
770
771 public static function get_surveys($ordering = ''){
772 global $wpdb;
773 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
774
775 $sql = "SELECT id,title
776 FROM {$surveys_table} WHERE `status` = 'published'";
777
778
779 if($ordering != ''){
780 $sql .= ' ORDER BY id '.$ordering;
781 }
782
783 $surveys = $wpdb->get_results( $sql , "ARRAY_A" );
784
785 return $surveys;
786 }
787
788 public static function get_survey_current_column( $survey_id , $column, $status = 'published'){
789 global $wpdb;
790 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
791
792 $sql = "SELECT ".sanitize_text_field($column)."
793 FROM {$surveys_table} WHERE `id`= ".sanitize_text_field($survey_id)." AND `status` = '".sanitize_text_field($status)."' ";
794 $current_column = $wpdb->get_var( $sql );
795
796 return $current_column;
797 }
798
799 public static function get_survey_by_id( $id ){
800 global $wpdb;
801 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
802
803 $sql = "SELECT *
804 FROM {$surveys_table}
805 WHERE id=" . esc_sql( absint( $id ) );
806
807 $survey = $wpdb->get_row( $sql );
808
809 return $survey;
810 }
811
812 public static function get_survey_category_by_id( $id ){
813 global $wpdb;
814 $survey_cat_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "survey_categories";
815
816 $sql = "SELECT *
817 FROM {$survey_cat_table}
818 WHERE id=" . esc_sql( absint( $id ) );
819
820 $category = $wpdb->get_row( $sql );
821
822 return $category;
823 }
824
825 public static function get_question_category_by_id( $id ){
826 global $wpdb;
827 $question_cat_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "question_categories";
828
829 $sql = "SELECT *
830 FROM {$question_cat_table}
831 WHERE id=" . esc_sql( absint( $id ) );
832
833 $category = $wpdb->get_row( $sql );
834
835 return $category;
836 }
837
838 public static function get_question_by_id( $id ){
839 global $wpdb;
840 $questions_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "questions";
841 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
842
843 $sql = "SELECT *
844 FROM {$questions_table}
845 WHERE id=" . esc_sql( absint( $id ) );
846
847 $question = $wpdb->get_row( $sql );
848
849 $sql = "SELECT *
850 FROM {$answers_table}
851 WHERE question_id=" . esc_sql( absint( $id ) );
852
853 $answers = $wpdb->get_results( $sql );
854
855 $question->answers = $answers;
856
857 return $question;
858 }
859
860 public static function get_question_by_ids( $ids ){
861 global $wpdb;
862 $questions_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "questions";
863 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
864
865 $qids = esc_sql( implode( ',', $ids ) );
866
867 $sql = "SELECT *
868 FROM {$questions_table}
869 WHERE id IN (" . esc_sql( $qids ) . ")
870 ORDER BY ordering";
871
872 $questions = $wpdb->get_results( $sql );
873
874 foreach ( $questions as $key => &$question ) {
875
876 $sql = "SELECT *
877 FROM {$answers_table}
878 WHERE question_id=" . esc_sql( absint( $question->id ) ) ."
879 ORDER BY ordering";
880
881 $answers = $wpdb->get_results( $sql );
882
883 $question->answers = $answers;
884
885 }
886
887 return $questions;
888 }
889
890 public static function get_section_by_id($id){
891 global $wpdb;
892 $sections_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "sections";
893
894 $sid = esc_sql( absint( $id ) );
895
896 $sql = "SELECT *
897 FROM {$sections_table}
898 WHERE id={$sid}
899 ORDER BY ordering";
900
901 $section = $wpdb->get_row( $sql );
902
903 return $section;
904 }
905
906 public static function get_answer_by_id($id){
907 global $wpdb;
908 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
909
910 $sql = "SELECT *
911 FROM {$answers_table}
912 WHERE id=" . esc_sql( absint( $id ) );
913
914 $answer = $wpdb->get_row( $sql );
915
916 return $answer;
917 }
918
919 public static function get_answers_by_question_id($id){
920 global $wpdb;
921 $answers_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "answers";
922
923 $sql = "SELECT *
924 FROM {$answers_table}
925 WHERE question_id=" . esc_sql( absint( $id ) ) . "
926 ORDER BY ordering";
927
928 $answers = $wpdb->get_results( $sql, 'ARRAY_A' );
929
930 if(! empty($answers) ){
931 return $answers;
932 }
933
934 return array();
935 }
936
937 public static function get_survey_questions_count($id){
938 global $wpdb;
939 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
940
941 $sql = "SELECT `questions_count`
942 FROM {$surveys_table}
943 WHERE id=" . esc_sql( absint( $id ) );
944
945 $questions_str = $wpdb->get_var( $sql );
946 $count = intval( $questions_str );
947
948 return $count;
949 }
950
951 public static function get_survey_sections_count($id){
952 global $wpdb;
953 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
954
955 $sql = "SELECT `sections_count`
956 FROM {$surveys_table}
957 WHERE id=" . esc_sql( absint( $id ) );
958
959 $sections_str = $wpdb->get_var( $sql );
960 $count = intval( $sections_str );
961
962 return $count;
963 }
964
965 public static function get_sections_by_survey_id( $ids ) {
966 global $wpdb;
967 if (empty($ids)) {
968 return array();
969 }
970 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "sections";
971
972 $sql = "SELECT * FROM {$table} WHERE `id` IN (" . esc_sql( $ids ) .") ORDER BY `ordering`;";
973 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
974
975 if(! empty($result) ){
976 return $result;
977 }
978
979 return array();
980 }
981
982 public static function get_questions_by_section_id( $section_id, $question_ids ) {
983 global $wpdb;
984 if (empty($question_ids) || empty($section_id)) {
985 return array();
986 }
987 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "questions";
988
989 $sql = "SELECT * FROM {$table} WHERE `section_id` = ". absint( $section_id ) ." AND `id` IN (" . esc_sql( $question_ids ) .") ORDER BY ordering;";
990 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
991
992 if(! empty($result) ){
993 return $result;
994 }
995
996 return array();
997 }
998
999 public static function get_answers_by_question_id_aro( $question_id ) {
1000 global $wpdb;
1001 if (empty($question_id)) {
1002 return false;
1003 }
1004 $table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "answers";
1005
1006 $sql = "SELECT * FROM {$table} WHERE `question_id` = ". absint( $question_id );
1007 $result = $wpdb->get_results( $sql, 'ARRAY_A' );
1008
1009 return $result;
1010 }
1011
1012 public static function sort_array_keys_by_array($array, $orderArray) {
1013 $ordered = array();
1014 foreach ($orderArray as $key) {
1015 if (array_key_exists('ays-question-'.$key, $array)) {
1016 $ordered['ays-question-'.$key] = $array['ays-question-'.$key];
1017 unset($array['ays-question-'.$key]);
1018 }
1019 }
1020 return $ordered + $array;
1021 }
1022
1023 public static function replace_message_variables($content, $data){
1024 foreach($data as $variable => $value){
1025 $content = str_replace("%%".$variable."%%", $value, $content);
1026 }
1027 return $content;
1028 }
1029
1030 public static function question_type_is($question_id){
1031 global $wpdb;
1032 $questions_table = $wpdb->prefix . "aysquiz_questions";
1033 $question_id = absint(intval($question_id));
1034 $custom_types = array("custom");
1035 $question_type = $wpdb->get_var("SELECT type FROM {$questions_table} WHERE id=". absint( $question_id ) .";");
1036 if($question_type == ''){
1037 $question_type = 'radio';
1038 }
1039
1040 if(in_array($question_type, $custom_types)){
1041 return true;
1042 }
1043 return false;
1044 }
1045
1046 public static function hex2rgba($color, $opacity = false){
1047
1048 $default = 'rgb(0,0,0)';
1049
1050 //Return default if no color provided
1051 if (empty($color))
1052 return $default;
1053
1054 //Sanitize $color if "#" is provided
1055 if ($color[0] == '#') {
1056 $color = substr($color, 1);
1057 }else{
1058 return $color;
1059 }
1060
1061 //Check if color has 6 or 3 characters and get values
1062 if (strlen($color) == 6) {
1063 $hex = array($color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5]);
1064 } elseif (strlen($color) == 3) {
1065 $hex = array($color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2]);
1066 } else {
1067 return $default;
1068 }
1069
1070 //Convert hexadec to rgb
1071 $rgb = array_map('hexdec', $hex);
1072
1073 //Check if opacity is set(rgba or rgb)
1074 if ($opacity) {
1075 if (abs($opacity) > 1)
1076 $opacity = 1.0;
1077 $output = 'rgba(' . implode(",", $rgb) . ',' . $opacity . ')';
1078 } else {
1079 $output = 'rgb(' . implode(",", $rgb) . ')';
1080 }
1081
1082 //Return rgb(a) color string
1083 return $output;
1084 }
1085
1086 public static function rgb2hex( $rgba ) {
1087 if ( strpos( $rgba, '#' ) === 0 ) {
1088 return $rgba;
1089 }
1090
1091 preg_match( '/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i', $rgba, $by_color );
1092 if(!empty($by_color)){
1093 return sprintf( '#%02x%02x%02x', $by_color[1], $by_color[2], $by_color[3] );
1094 }
1095 }
1096
1097 public static function secondsToWords($seconds){
1098 $ret = "";
1099
1100 $seconds = absint($seconds);
1101
1102 /*** get the days ***/
1103 $days = (int)($seconds / 86400);
1104 if ($days > 0) {
1105 $ret .= "$days " . __( 'days', "survey-maker" ) . ' ';
1106 }
1107
1108 /*** get the hours ***/
1109 $hours = (int)(($seconds - ($days * 86400)) / 3600);
1110 if ($hours > 0) {
1111 $ret .= "$hours " . __( 'hours', "survey-maker" ) . ' ';
1112 }
1113
1114 /*** get the minutes ***/
1115 $minutes = (int)(($seconds - $days * 86400 - $hours * 3600) / 60);
1116 if ($minutes > 0) {
1117 $ret .= "$minutes " . __( 'minutes', "survey-maker" ) . ' ';
1118 }
1119
1120 /*** get the seconds ***/
1121 $seconds = (int)($seconds - ($days * 86400) - ($hours * 3600) - ($minutes * 60));
1122 if ($seconds > 0) {
1123 $ret .= "$seconds " . __( 'seconds', "survey-maker" );
1124 }
1125
1126 return $ret;
1127 }
1128
1129 public static function get_limit_user_by_ip($id){
1130 global $wpdb;
1131 $table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions" );
1132 $user_ip = self::get_user_ip();
1133 $sql = "SELECT COUNT(*)
1134 FROM `{$table}`
1135 WHERE `user_ip` = '". esc_sql( $user_ip ) ."'
1136 AND `survey_id` = ". absint( $id );
1137 $result = intval($wpdb->get_var($sql));
1138 return $result;
1139 }
1140
1141 public static function get_limit_user_by_id($survey_id, $user_id){
1142 global $wpdb;
1143 $table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions" );
1144 $sql = "SELECT COUNT(*)
1145 FROM `{$table}`
1146 WHERE `user_id` = ". absint( $user_id ) ."
1147 AND `survey_id` = ". absint( $survey_id );
1148 $result = intval($wpdb->get_var($sql));
1149 return $result;
1150 }
1151
1152 public static function get_user_ip(){
1153 $ipaddress = '';
1154 if( !empty($_SERVER) && !empty($_SERVER['REMOTE_ADDR']) ){
1155 $ipaddress = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : 'UNKNOWN';
1156 } else {
1157 if (getenv('REMOTE_ADDR'))
1158 $ipaddress = getenv('REMOTE_ADDR');
1159 elseif (getenv('HTTP_CLIENT_IP'))
1160 $ipaddress = getenv('HTTP_CLIENT_IP');
1161 else if (getenv('HTTP_X_FORWARDED_FOR'))
1162 $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
1163 else if (getenv('HTTP_X_FORWARDED'))
1164 $ipaddress = getenv('HTTP_X_FORWARDED');
1165 else if (getenv('HTTP_FORWARDED_FOR'))
1166 $ipaddress = getenv('HTTP_FORWARDED_FOR');
1167 else if (getenv('HTTP_FORWARDED'))
1168 $ipaddress = getenv('HTTP_FORWARDED');
1169 else
1170 $ipaddress = 'UNKNOWN';
1171 }
1172 return $ipaddress;
1173 }
1174
1175 // OLD
1176 // public static function get_user_ip_validated(){
1177 // $ipaddress = '';
1178 // if (getenv('REMOTE_ADDR')){
1179 // $ipaddress = getenv('REMOTE_ADDR');
1180 // }
1181 // elseif (getenv('HTTP_CLIENT_IP')){
1182 // $ipaddress = getenv('HTTP_CLIENT_IP');
1183 // }
1184 // else if (getenv('HTTP_X_FORWARDED_FOR')){
1185 // $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
1186 // }
1187 // else if (getenv('HTTP_X_FORWARDED')){
1188 // $ipaddress = getenv('HTTP_X_FORWARDED');
1189 // }
1190 // else if (getenv('HTTP_FORWARDED_FOR')){
1191 // $ipaddress = getenv('HTTP_FORWARDED_FOR');
1192 // }
1193 // else if (getenv('HTTP_FORWARDED')){
1194 // $ipaddress = getenv('HTTP_FORWARDED');
1195 // }
1196 // else{
1197 // $ipaddress = 'UNKNOWN';
1198 // }
1199 // // Validate the IP address
1200 // if (filter_var($ipaddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) && $ipaddress !== '0.0.0.0') {
1201 // return $ipaddress;
1202 // }
1203 // return 'UNKNOWN';
1204
1205 // }
1206
1207 // FOR REVIEW
1208 public static function get_user_ip_validated(){
1209
1210 if( !empty($_SERVER) && !empty($_SERVER['REMOTE_ADDR']) ){
1211 $ipaddress = isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] ? sanitize_text_field($_SERVER['REMOTE_ADDR']) : 'UNKNOWN';
1212
1213 if(!empty($ipaddress) && $ipaddress != 'UNKNOWN' ){
1214 return $ipaddress;
1215 }
1216 }
1217
1218 $headers_to_check = array(
1219 'HTTP_CLIENT_IP',
1220 'HTTP_X_FORWARDED_FOR',
1221 'HTTP_X_FORWARDED',
1222 'HTTP_FORWARDED_FOR',
1223 'HTTP_FORWARDED',
1224 'REMOTE_ADDR'
1225 );
1226
1227 foreach ($headers_to_check as $header) {
1228 if (!empty($_SERVER[$header])) {
1229 // In case of multiple IPs in HTTP_X_FORWARDED_FOR, take the last one
1230 if ($header === 'HTTP_X_FORWARDED_FOR') {
1231 $ips = explode(',', $_SERVER[$header]);
1232 $ip = trim(end($ips));
1233 } else {
1234 $ip = $_SERVER[$header];
1235 }
1236
1237 // Validate the IP address
1238 if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) && $ip !== '0.0.0.0') {
1239 return $ip;
1240 }
1241 }
1242 }
1243
1244 return 'UNKNOWN';
1245 }
1246
1247 public static function ays_autoembed( $content ) {
1248 global $wp_embed;
1249 $content = stripslashes( wpautop( $content ) );
1250 $content = $wp_embed->autoembed( $content );
1251 if ( strpos( $content, '[embed]' ) !== false ) {
1252 $content = $wp_embed->run_shortcode( $content );
1253 }
1254 $content = do_shortcode( $content );
1255 return $content;
1256 }
1257
1258 public static function get_questions_categories($q_ids){
1259 global $wpdb;
1260
1261 if($q_ids == ''){
1262 return array();
1263 }
1264 $sql = "SELECT DISTINCT c.id, c.title
1265 FROM {$wpdb->prefix}aysquiz_categories c
1266 JOIN {$wpdb->prefix}aysquiz_questions q
1267 ON c.id = q.category_id
1268 WHERE q.id IN (". esc_sql( $q_ids ) .")";
1269
1270 $result = $wpdb->get_results($sql, 'ARRAY_A');
1271 $cats = array();
1272
1273 foreach($result as $res){
1274 $cats[$res['id']] = $res['title'];
1275 }
1276
1277 return $cats;
1278 }
1279
1280 public static function get_suervey_sections_with_questions( $sections_ids, $question_ids ){
1281
1282 $sections = self::get_sections_by_survey_id($sections_ids);
1283 $sections_count = count( $sections );
1284
1285 foreach ($sections as $section_key => $section) {
1286 $sections[$section_key]['title'] = (isset($section['title']) && $section['title'] != '') ? stripslashes( htmlentities( $section['title'] ) ) : '';
1287 $sections[$section_key]['description'] = (isset($section['description']) && $section['description'] != '') ? stripslashes( htmlentities( $section['description'] ) ) : '';
1288
1289 $section_questions = self::get_questions_by_section_id( intval( $section['id'] ), $question_ids );
1290
1291 foreach ($section_questions as $question_key => $question) {
1292 $section_questions[$question_key]['question'] = (isset($question['question']) && $question['question'] != '') ? stripslashes( $question['question'] ) : '';
1293 $section_questions[$question_key]['image'] = (isset($question['image']) && $question['image'] != '') ? $question['image'] : '';
1294 $section_questions[$question_key]['type'] = (isset($question['type']) && $question['type'] != '') ? $question['type'] : 'radio';
1295 $section_questions[$question_key]['user_variant'] = (isset($question['user_variant']) && $question['user_variant'] == 'on') ? true : false;
1296
1297 $opts = json_decode( $question['options'], true );
1298 $opts['required'] = (isset($opts['required']) && $opts['required'] == 'on') ? true : false;
1299
1300 $q_answers = self::get_answers_by_question_id( intval( $question['id'] ) );
1301
1302 foreach ($q_answers as $answer_key => $answer) {
1303 $q_answers[$answer_key]['answer'] = (isset($answer['answer']) && $answer['answer'] != '') ? stripslashes( $answer['answer'] ) : '';
1304 $q_answers[$answer_key]['image'] = (isset($answer['image']) && $answer['image'] != '') ? $answer['image'] : '';
1305 $q_answers[$answer_key]['placeholder'] = (isset($answer['placeholder']) && $answer['placeholder'] != '') ? $answer['placeholder'] : '';
1306 }
1307
1308 $section_questions[$question_key]['answers'] = $q_answers;
1309
1310 $section_questions[$question_key]['options'] = $opts;
1311 }
1312
1313 $sections[$section_key]['questions'] = $section_questions;
1314 }
1315
1316 return $sections;
1317 }
1318
1319 /**
1320 * Recursive sanitation for an array
1321 *
1322 * @param $array
1323 *
1324 * @return mixed
1325 */
1326 public static function recursive_sanitize_text_field( $array, $textareas = array() ) {
1327 foreach ( $array as $key => &$value ) {
1328 if ( is_array( $value ) ) {
1329 $value = self::recursive_sanitize_text_field( $value, $textareas );
1330 } else {
1331 if( in_array( $key, $textareas ) ){
1332 if( function_exists( 'sanitize_textarea_field' ) ){
1333 $value = sanitize_textarea_field( $value );
1334 }else{
1335 $value = sanitize_text_field( $value );
1336 }
1337 }else{
1338 $value = sanitize_text_field( $value );
1339 }
1340 }
1341 }
1342
1343 return $array;
1344 }
1345
1346 public static function get_survey_takers_count( $id ){
1347 global $wpdb;
1348 $submission_table = $wpdb->prefix . "ayssurvey_submissions";
1349 $sql = "SELECT COUNT(id) AS count FROM {$submission_table} WHERE survey_id=". absint( $id ) ;
1350 $result = absint( $wpdb->get_var( $sql ) );
1351
1352 return $result;
1353 }
1354
1355 public static function get_setting_data( $meta_key = 'options' ){
1356 global $wpdb;
1357
1358 $name_prefix = 'survey_';
1359
1360 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1361 $sql = "SELECT meta_value FROM " . $settings_table . " WHERE meta_key = '". esc_sql( $meta_key ) ."'";
1362 $result = $wpdb->get_var($sql);
1363
1364 $options = ($result == "") ? array() : json_decode($result, true);
1365
1366 return $options;
1367 }
1368
1369 public static function get_listtables_title_length( $listtable_name ) {
1370 global $wpdb;
1371
1372 $options = self::get_setting_data( 'options' );
1373
1374 $listtable_title_length = 5;
1375 if(! empty($options) ){
1376 switch ( $listtable_name ) {
1377 case 'surveys':
1378 $listtable_title_length = (isset($options['survey_title_length']) && intval($options['survey_title_length']) != 0) ? absint(intval($options['survey_title_length'])) : 5;
1379 break;
1380 case 'submissions':
1381 $listtable_title_length = (isset($options['survey_submissions_title_length']) && intval($options['survey_submissions_title_length']) != 0) ? absint(intval($options['survey_submissions_title_length'])) : 5;
1382 break;
1383 case 'survey_categories':
1384 $listtable_title_length = (isset($options['survey_categories_title_length']) && intval($options['survey_categories_title_length']) != 0) ? absint(intval($options['survey_categories_title_length'])) : 5;
1385 break;
1386 case 'popup_surveys':
1387 $listtable_title_length = (isset($options['survey_popups_title_length']) && intval($options['survey_popups_title_length']) != 0) ? absint(intval($options['survey_popups_title_length'])) : 5;
1388 break;
1389 default:
1390 $listtable_title_length = 5;
1391 break;
1392 }
1393 return $listtable_title_length;
1394 }
1395 return $listtable_title_length;
1396 }
1397
1398 /*
1399 * Get survey default texts from database
1400 */
1401 public static function ays_set_default_texts( $plugin_name, $settings = array() ) {
1402 global $wpdb;
1403
1404 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1405 $sql = "SELECT meta_value FROM " . $settings_table . " WHERE meta_key = 'default_texts'";
1406 $result = $wpdb->get_var($sql);
1407 $settings_static_texts = ($result == "") ? array() : json_decode($result, true);
1408
1409 $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';
1410 $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';
1411 $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';
1412
1413 if ($wrong_shortcode_text === 'Wrong shortcode initialized') {
1414 $wrong_shortcode_text = __('Wrong shortcode initialized', "survey-maker");
1415 }
1416
1417 if ($email_validation_error_text === 'Must be a valid email address') {
1418 $email_validation_error_text = __('Must be a valid email address', "survey-maker");
1419 }
1420
1421 if ($redirecting_after_text === 'Redirecting after') {
1422 $redirecting_after_text = __('Redirecting after', "survey-maker");
1423 }
1424
1425 $texts = array(
1426 'wrongShortcode' => $wrong_shortcode_text,
1427 'emailValidationError' => $email_validation_error_text,
1428 'redirectingAfter' => $redirecting_after_text,
1429 );
1430
1431 return $texts;
1432 }
1433
1434 public static function ays_set_survey_texts( $plugin_name, $settings ){
1435
1436 /*
1437 * Get survey buttons texts from database
1438 */
1439 global $wpdb;
1440
1441 $name_prefix = 'survey_';
1442
1443 $settings_table = $wpdb->prefix . "ayssurvey_settings";
1444 $sql = "SELECT meta_value FROM ".$settings_table." WHERE meta_key = 'buttons_texts'";
1445 $result = $wpdb->get_var($sql);
1446 $settings_buttons_texts = ($result == "") ? array() : json_decode($result, true);
1447
1448 $settings_buttons_texts['next_button'] = (isset($settings_buttons_texts['next_button']) && $settings_buttons_texts['next_button'] != '') ? esc_attr($settings_buttons_texts['next_button']) : 'Next';
1449 $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'];
1450
1451 $settings_buttons_texts['prev_button'] = (isset($settings_buttons_texts['prev_button']) && $settings_buttons_texts['prev_button'] != '') ? esc_attr($settings_buttons_texts['prev_button']) : 'Prev';
1452 $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'];
1453
1454 $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';
1455 $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'];
1456
1457 $settings_buttons_texts['finish_button'] = (isset($settings_buttons_texts['finish_button']) && $settings_buttons_texts['finish_button'] != '') ? esc_attr($settings_buttons_texts['finish_button']) : 'Finish';
1458 $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'];
1459
1460 $settings_buttons_texts['restart_button'] = (isset($settings_buttons_texts['restart_button']) && $settings_buttons_texts['restart_button'] != '') ? esc_attr($settings_buttons_texts['restart_button']) : 'Restart';
1461 $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'];
1462
1463 $settings_buttons_texts['exit_button'] = (isset($settings_buttons_texts['exit_button']) && $settings_buttons_texts['exit_button'] != '') ? esc_attr($settings_buttons_texts['exit_button']) : 'Exit';
1464 $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'];
1465 $ays_login_button = (isset($settings_buttons_texts['login_button']) && $settings_buttons_texts['login_button'] != '') ? stripslashes( esc_attr($settings_buttons_texts['login_button']) ) : 'Log In';
1466
1467 $settings_buttons_texts['start_button'] = (isset($settings_buttons_texts['start_button']) && $settings_buttons_texts['start_button'] != '') ? esc_attr($settings_buttons_texts['start_button']) : 'Start';
1468 $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'];
1469
1470 $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';
1471 $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'];
1472
1473 $ays_next_button_text = ($ays_next_button === 'Next') ? __('Next', "survey-maker") : $ays_next_button;
1474 $ays_previous_button_text = ($ays_previous_button === 'Prev') ? __('Prev', "survey-maker") : $ays_previous_button;
1475 $ays_clear_button_text = ($ays_clear_button === 'Clear selection') ? __('Clear selection', "survey-maker") : $ays_clear_button;
1476 $ays_finish_button_text = ($ays_finish_button === 'Finish') ? __('Finish', "survey-maker") : $ays_finish_button;
1477 $ays_restart_button_text = ($ays_finish_button === 'Restart') ? __('Restart', "survey-maker") : $ays_restart_survey_button;
1478 $ays_exit_button_text = ($ays_exit_button === 'Exit') ? __('Exit', "survey-maker") : $ays_exit_button;
1479 $ays_login_button_text = ($ays_login_button === 'Log In') ? __('Log In', "survey-maker") : $ays_login_button;
1480
1481 if ($ays_start_button === 'Start') {
1482 $ays_start_button_text = __('Start', "survey-maker");
1483 }else{
1484 $ays_start_button_text = $ays_start_button;
1485 }
1486
1487 $texts = array(
1488 'nextButton' => $ays_next_button_text,
1489 'previousButton' => $ays_previous_button_text,
1490 'clearButton' => $ays_clear_button_text,
1491 'finishButton' => $ays_finish_button_text,
1492 'restartButton' => $ays_restart_button_text,
1493 'exitButton' => $ays_exit_button_text,
1494 'loginButton' => $ays_login_button_text,
1495 'startButton' => $ays_start_button_text,
1496 );
1497 return $texts;
1498 }
1499
1500 public static function ays_survey_numbering_all( $numbering ){
1501 $keyword_arr = array();
1502 switch ($numbering) {
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 '1)':
1513
1514 $char_min_val = '1';
1515 $char_max_val = '100';
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
1532 $char_min_val = 'A';
1533 $char_max_val = 'Z';
1534 for($x = $char_min_val; $x <= $char_max_val; $x++){
1535 $keyword_arr[] = $x .")";
1536 }
1537
1538 break;
1539 case 'a.':
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 case 'a)':
1548
1549 $char_min_val = 'a';
1550 $char_max_val = 'z';
1551 for($x = $char_min_val; $x <= $char_max_val; $x++){
1552 $keyword_arr[] = $x .")";
1553 }
1554
1555 break;
1556
1557 default:
1558
1559 break;
1560 }
1561
1562 return $keyword_arr;
1563 }
1564
1565 public static function ays_survey_question_results_for_summary( $survey_id, $submission_ids = null ){
1566 global $wpdb;
1567
1568 if($survey_id === null){
1569 return array(
1570 'total_count' => 0,
1571 'questions' => array()
1572 );
1573 }
1574
1575 $answer_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "answers";
1576 $question_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "questions";
1577 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1578 $survey_section_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "sections";
1579 $surveys_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "surveys";
1580 $submitions_questiions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1581
1582 $question_ids = "SELECT question_ids FROM {$surveys_table} WHERE id =". absint( $survey_id );
1583 $question_ids_results = $wpdb->get_var( $question_ids );
1584 $ays_question_id = ($question_ids_results != '') ? $question_ids_results : null;
1585
1586 if($ays_question_id == null){
1587 return array(
1588 'total_count' => 0,
1589 'questions' => array()
1590 );
1591 }
1592
1593 $questions_ids_arr = explode(',',$ays_question_id);
1594 $answer_id = "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
1598 WHERE s_q.survey_id=". absint( $survey_id ) ."
1599 GROUP BY a.id";
1600
1601 $answer_id_result = $wpdb->get_results($answer_id,'ARRAY_A');
1602
1603 $for_checkbox = "SELECT a.id, a.answer, COUNT(s_q.answer_id) AS answer_count
1604 FROM {$answer_table} AS a
1605 LEFT JOIN {$submitions_questiions_table} AS s_q
1606 ON a.id = s_q.answer_id OR FIND_IN_SET( a.id, s_q.user_answer )
1607 WHERE s_q.type = 'checkbox'
1608 AND s_q.survey_id=". absint( $survey_id ) ."
1609 GROUP BY a.id";
1610
1611 $for_checkbox_result = $wpdb->get_results($for_checkbox,'ARRAY_A');
1612
1613 $answer_count = array();
1614 $question_type = '';
1615 foreach ($answer_id_result as $key => $answer_count_by_id) {
1616 $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'])) : '';
1617 $answer_count[$answer_count_by_id['id']] = $ays_survey_answer_count;
1618 }
1619
1620 foreach ($for_checkbox_result as $key => $answer_count_by_id) {
1621 $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'])) : '';
1622 $answer_count[$answer_count_by_id['id']] = $ays_survey_answer_count;
1623 }
1624
1625 $question_by_ids = Survey_Maker_Data::get_question_by_ids( $questions_ids_arr );
1626
1627 $select_answer_q_type = "SELECT type, user_answer, id, question_id
1628 FROM {$submitions_questiions_table}
1629 WHERE user_answer != ''
1630 AND type != 'checkbox'
1631 AND survey_id=". absint( $survey_id );
1632
1633 $submission_answer_other = "SELECT question_id, answer_id, user_variant
1634 FROM {$submitions_questiions_table}
1635 WHERE user_variant != ''
1636 AND survey_id=". absint( $survey_id );
1637
1638 if( $submission_ids !== null ){
1639 if( is_array( $submission_ids ) ){
1640 $select_answer_q_type .= " AND submission_id IN (" . esc_sql( implode( ',', $submission_ids ) ) . ") ";
1641 $submission_answer_other .= " AND submission_id IN (" . esc_sql( implode( ',', $submission_ids ) ) . ") ";
1642 }
1643 }
1644
1645 $result_answers_q_type = $wpdb->get_results($select_answer_q_type,'ARRAY_A');
1646 $result_answers_other = $wpdb->get_results($submission_answer_other,'ARRAY_A');
1647 $text_answer = array();
1648 foreach($result_answers_q_type as $key => $result_answer_q_type){
1649 $text_answer[$result_answer_q_type['type']][$result_answer_q_type['question_id']][] = $result_answer_q_type['user_answer'];
1650 }
1651
1652 $other_answers = array();
1653 $other_answers_all = array();
1654 foreach($result_answers_other as $key => $result_answer_other){
1655 if( intval( $result_answer_other['answer_id'] ) == 0 ){
1656 $other_answers[$result_answer_other['question_id']][] = $result_answer_other['user_variant'];
1657 }
1658 $other_answers_all[$result_answer_other['question_id']][] = $result_answer_other['user_variant'];
1659 }
1660
1661 $text_types = array(
1662 'text',
1663 'short_text',
1664 'number',
1665 'phone',
1666 'star',
1667 'name',
1668 'email',
1669 'linear_scale',
1670 'star',
1671 'date',
1672 'time',
1673 'date_time',
1674 );
1675
1676 //Question types different charts
1677 $ays_submissions_count = array();
1678 $question_results = array();
1679
1680 $total_count = 0;
1681 foreach ($question_by_ids as $key => $question) {
1682
1683 $answers = $question->answers;
1684 $question_id = $question->id;
1685 $question_title = $question->question;
1686
1687 //questions
1688 $question_results[$question_id]['question_id'] = $question_id;
1689 $question_results[$question_id]['question'] = $question_title;
1690 $ays_answer = array();
1691 $question_answer_ids = array();
1692 foreach ($answers as $key => $answer) {
1693 $answer_id = $answer->id;
1694 $answer_title = $answer->answer;
1695
1696 $ays_answer[$answer_id] = isset( $answer_count[$answer_id] ) ? $answer_count[$answer_id] : 0;
1697 $question_answer_ids[$answer_id] = $answer_title;
1698 }
1699
1700 //sum of submissions count per questions
1701 if($question->type == "checkbox"){
1702 $sub_checkbox_count = self::ays_survey_get_submission_count($question->id, $question->type, $survey_id);
1703 $sum_of_count = $sub_checkbox_count;
1704 }else{
1705 $sum_of_count = array_sum( array_values( $ays_answer ) );
1706 }
1707
1708 $question_results[$question_id]['otherAnswers'] = isset( $other_answers[$question->id] ) ? $other_answers[$question->id] : array();
1709
1710 if( in_array( $question->type, $text_types ) ){
1711 $question_ls_options = json_decode($question->options, true);
1712
1713 if($question->type == 'star'){
1714 $scale_from = isset($question_ls_options['star_1']) && $question_ls_options['star_1'] != "" ? stripslashes($question_ls_options['star_1']) : "";
1715 $scale_to = isset($question_ls_options['star_2']) && $question_ls_options['star_2'] != "" ? stripslashes($question_ls_options['star_2']) : "";
1716 $scale_length = isset($question_ls_options['star_scale_length']) && $question_ls_options['star_scale_length'] != "" ? $question_ls_options['star_scale_length'] : "";
1717 $question_results[$question_id]['labels'] = array(
1718 'from' => $scale_from,
1719 'to' => $scale_to,
1720 'length' => $scale_length
1721 );
1722 }
1723 $question_results[$question_id]['answers'] = isset( $text_answer[$question->type] ) ? $text_answer[$question->type] : '';
1724 $question_results[$question_id]['answerTitles'] = isset( $text_answer[$question->type] ) ? $text_answer[$question->type] : '';
1725 $question_results[$question_id]['sum_of_answers_count'] = isset( $text_answer[$question->type][$question->id] ) ? count( $text_answer[$question->type][$question->id] ) : 0;
1726 $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;
1727 }else{
1728 $question_results[$question_id]['answers'] = $ays_answer;
1729 $question_results[$question_id]['answerTitles'] = $question_answer_ids;
1730 $question_results[$question_id]['sum_of_answers_count'] = $sum_of_count;
1731 if( $sum_of_count == 0 ){
1732 $question_results[$question_id]['answers'] = array();
1733 }
1734 }
1735
1736 // Answers for charts
1737 if( !empty( $question_results[$question_id]['otherAnswers'] ) ){
1738 $question_results[$question_id]['answers'][0] = count( $question_results[$question_id]['otherAnswers'] );
1739 $question_results[$question_id]['answerTitles'][0] = __( '"Other" answer(s)', "survey-maker" );
1740 $question_results[$question_id]['same_other_count'] = array_count_values( $question_results[$question_id]['otherAnswers'] );
1741
1742 if($question->type == "radio" || $question_type == "yesorno"){
1743 $question_results[$question_id]['sum_of_answers_count'] += count( $question_results[$question_id]['otherAnswers'] );
1744 }
1745 }
1746 //
1747
1748 $total_count += intval( $question_results[$question_id]['sum_of_answers_count'] );
1749
1750 $question_results[$question_id]['question_type'] = $question->type;
1751 }
1752
1753 return array(
1754 'total_count' => $total_count,
1755 'questions' => $question_results
1756 );
1757 }
1758
1759 public static function ays_survey_get_last_submission_id_for_summary( $survey_id ){
1760 global $wpdb;
1761
1762 if($survey_id === null){
1763 return array();
1764 }
1765
1766 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1767
1768 //submission of each result
1769 $submission = "SELECT * FROM {$submitions_table} WHERE survey_id=". absint( $survey_id ) ." ORDER BY id DESC LIMIT 1 ";
1770 $last_submission = $wpdb->get_row( $submission, 'ARRAY_A' );
1771
1772 if( $last_submission == null ){
1773 return array();
1774 }
1775 return $last_submission;
1776 }
1777
1778 public static function ays_survey_individual_results_for_one_submission_for_summary( $submission, $survey ){
1779 global $wpdb;
1780 $survey_id = isset( $survey['id'] ) ? absint( intval( $survey['id'] ) ) : null;
1781
1782 if( is_null( $survey_id ) || empty( $submission )){
1783 return array(
1784 'sections' => array()
1785 );
1786 }
1787
1788 $submitions_questiions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1789
1790 $ays_individual_questions_for_one_submission = array();
1791 $question_answer_id = array();
1792 $submission_id = isset( $submission['id'] ) && $submission['id'] != '' ? $submission['id'] : null;
1793
1794 if( is_null( $submission_id ) ){
1795 return array(
1796 'sections' => array()
1797 );
1798 }
1799
1800 $checkbox_ids = '';
1801
1802 $individual_questions = "SELECT * FROM {$submitions_questiions_table} WHERE submission_id=" . absint( $submission_id );
1803 $individual_questions_results = $wpdb->get_results($individual_questions,'ARRAY_A');
1804
1805 // Survey questions IDs
1806 $question_ids = isset( $survey['question_ids'] ) && $survey['question_ids'] != '' ? $survey['question_ids'] : '';
1807
1808 // Section Ids
1809 $sections_ids = (isset( $survey['section_ids' ] ) && $survey['section_ids'] != '') ? $survey['section_ids'] : '';
1810
1811 $sections = Survey_Maker_Data::get_suervey_sections_with_questions( $sections_ids, $question_ids );
1812
1813 $text_types = array(
1814 'text',
1815 'short_text',
1816 'number',
1817 'phone',
1818 'star',
1819 'name',
1820 'email',
1821 'linear_scale',
1822 'star',
1823 'date',
1824 'time',
1825 );
1826
1827 foreach ($individual_questions_results as $key => $individual_questions_result) {
1828 if($individual_questions_result['type'] == 'checkbox'){
1829 $checkbox_ids = $individual_questions_result['user_answer'] != '' ? explode(',', $individual_questions_result['user_answer']) : array();
1830 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $checkbox_ids;
1831 $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'] : '';
1832 }elseif( in_array( $individual_questions_result['type'], $text_types ) ){
1833 $question_answer_id[ $individual_questions_result['question_id'] ] = $individual_questions_result['user_answer'];
1834 if( $individual_questions_result['type'] == 'date' ){
1835 if( $individual_questions_result['user_answer'] != '' ){
1836 $question_answer_id[ $individual_questions_result['question_id'] ] = date( 'd . m . Y', strtotime( $individual_questions_result['user_answer'] ) );
1837 }else{
1838 $question_answer_id[ $individual_questions_result['question_id'] ] = '';
1839 }
1840 }
1841 elseif( $individual_questions_result['type'] == 'time' ){
1842 if( $individual_questions_result['user_answer'] != '' ){
1843 $question_answer_id[ $individual_questions_result['question_id'] ] = implode(" : ", explode( ":", $individual_questions_result['user_answer'] ));
1844 }else{
1845 $question_answer_id[ $individual_questions_result['question_id'] ] = '';
1846 }
1847 }
1848 }elseif($individual_questions_result['type'] == 'radio'){
1849 $other_answer = isset($individual_questions_result['user_variant']) && $individual_questions_result['user_variant'] != '' ? $individual_questions_result['user_variant'] : '';
1850 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = $other_answer;
1851 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1852 if( intval( $individual_questions_result['answer_id'] ) === 0 && $other_answer !== '' ){
1853 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = $other_answer;
1854 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1855 }elseif( intval( $individual_questions_result['answer_id'] ) === 0 && $other_answer === '' ){
1856 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = '';
1857 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = '-1';
1858 }else{
1859 $question_answer_id[ $individual_questions_result['question_id'] ]['otherAnswer'] = '';
1860 $question_answer_id[ $individual_questions_result['question_id'] ]['answer'] = $individual_questions_result['answer_id'];
1861 }
1862 }else{
1863 $question_answer_id[ $individual_questions_result['question_id'] ] = $individual_questions_result['answer_id'];
1864 }
1865 }
1866
1867 $ays_individual_questions_for_one_submission['submission_id'] = $submission['id'];
1868 $ays_individual_questions_for_one_submission['questions'] = $question_answer_id;
1869 $ays_individual_questions_for_one_submission['sections'] = $sections;
1870
1871 return $ays_individual_questions_for_one_submission;
1872 }
1873
1874 public static function get_submission_count_and_ids_for_summary( $survey_id){
1875 global $wpdb;
1876
1877 if($survey_id === null){
1878 return false;
1879 }
1880 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1881
1882 //submission of each result
1883 $submission_ids = "SELECT id,
1884 (SELECT COUNT(id) FROM {$submitions_table} i
1885 WHERE i.survey_id=j.survey_id) AS count_submission
1886 FROM {$submitions_table} j
1887 WHERE survey_id=". absint( $survey_id ) ."
1888 ORDER BY id";
1889 $submission_ids_result = $wpdb->get_results($submission_ids,'ARRAY_A');
1890 $submission_count = '';
1891 $submissions_id_arr = array();
1892 foreach ($submission_ids_result as $key => $submission_id_result) {
1893 $submission_id_count = $submission_id_result['count_submission'];
1894 $submission_count = intval($submission_id_count);
1895 $submissions_id_arr[] = $submission_id_result['id'];
1896 }
1897 $submissions_id_str = implode(',', $submissions_id_arr );
1898
1899 $submission_count_and_ids = array(
1900 'submission_count' => $submission_count,
1901 'submission_ids' => $submissions_id_str,
1902 'submission_ids_arr' => $submissions_id_arr,
1903 );
1904
1905 return $submission_count_and_ids;
1906 }
1907
1908 public static function ays_survey_get_submission_count($id , $type , $survey_id){
1909 global $wpdb;
1910 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1911 $submitions_q_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions_questions";
1912 $results = array();
1913
1914 $sql = "SELECT submission_id AS sub_count
1915 FROM {$submitions_q_table}
1916 WHERE question_id = ". absint( $id ) ."
1917 AND survey_id = ". absint( $survey_id ) ."";
1918
1919 if( $type == 'checkbox' ){
1920 $sql .= " AND user_answer != '' ";
1921 }
1922
1923 $sql .= " GROUP BY submission_id ";
1924 $results = $wpdb->get_results( $sql, 'ARRAY_A' );
1925
1926 $submission_count = count( $results );
1927 return $submission_count;
1928 }
1929
1930 public static function ays_survey_copy_text_formater( $info_array ) {
1931 $return = "`\n";
1932 foreach ( $info_array as $section => $details ) {
1933 $return .= sprintf( "%s: %s", $section, $details );
1934 $return .= "\n";
1935 }
1936 $return .= '`';
1937 return $return;
1938 }
1939
1940 public static function ays_survey_detected_device_chart() {
1941 $device = 'desktop';
1942 $isMobile = preg_match("/(iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile)/i", $_SERVER["HTTP_USER_AGENT"]);
1943 $isTablet = preg_match("/(ipad|android|android 3.0|xoom|sch-i800|playbook|tablet|kindle)/i", $_SERVER["HTTP_USER_AGENT"]);
1944
1945 if($isMobile){
1946 $device = 'mobile';
1947 }else if($isTablet){
1948 $device = 'tablet';
1949 }else{
1950 $device = 'desktop';
1951 }
1952 return $device;
1953 }
1954
1955 public static function ays_survey_get_passed_users_count( $survey_id ) {
1956 global $wpdb;
1957 $submissions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
1958 // Get passed users
1959 $sql = "SELECT COUNT(id) AS users_count FROM ".$submissions_table."
1960 WHERE survey_id = ".$survey_id." AND user_id != 0
1961 GROUP BY user_id";
1962 $result = $wpdb->get_results($sql);
1963 // Get passed guests count
1964 $sql2 = "SELECT COUNT(id) FROM ".$submissions_table." WHERE `user_id` = 0 AND `survey_id` = ".$survey_id;
1965 $result2 = $wpdb->get_var($sql2);
1966 $all_count = intval(count($result)) + intval($result2);
1967 return $all_count;
1968 }
1969
1970 public static function get_template_part( $slug, $name = null, $args = array(), $path = 'admin' ) {
1971 /**
1972 * Fires before the specified template part file is loaded.
1973 *
1974 * The dynamic portion of the hook name, `$slug`, refers to the slug name
1975 * for the generic template part.
1976 *
1977 * @since 1.0.0
1978 * @since 1.0.0 The `$args` parameter was added.
1979 *
1980 * @param string $slug The slug name for the generic template.
1981 * @param string|null $name The name of the specialized template.
1982 * @param array $args Additional arguments passed to the template.
1983 */
1984
1985 $templates = array();
1986 $name = (string) $name;
1987 if ( '' !== $name ) {
1988 $templates[] = "{$slug}-{$name}.php";
1989 }
1990
1991 $templates[] = "{$slug}.php";
1992
1993 /**
1994 * Fires before an attempt is made to locate and load a template part.
1995 *
1996 * @since 1.0.0
1997 * @since 1.0.0 The `$args` parameter was added.
1998 *
1999 * @param string $slug The slug name for the generic template.
2000 * @param string $name The name of the specialized template.
2001 * @param string[] $templates Array of template files to search for, in order.
2002 * @param array $args Additional arguments passed to the template.
2003 */
2004 do_action( 'ays_sm_get_template_part', $slug, $name, $templates, $path, $args );
2005
2006 if ( ! self::locate_template( $templates, true, false, $path, $args ) ) {
2007 return false;
2008 }
2009 }
2010
2011 public static function locate_template( $template_names, $load = false, $require_once = true, $path = 'admin', $args = array() ) {
2012 $located = '';
2013 foreach ( (array) $template_names as $template_name ) {
2014 if ( ! $template_name ) {
2015 continue;
2016 }
2017
2018 $path = $path == 'public' ? SURVEY_MAKER_PUBLIC_PATH : SURVEY_MAKER_ADMIN_PATH;
2019
2020 if ( file_exists( $path . '/' . $template_name ) ) {
2021 $located = $path . '/' . $template_name;
2022 break;
2023 } elseif ( file_exists( $path . '/' . $template_name ) ) {
2024 $located = $path . '/' . $template_name;
2025 break;
2026 }
2027 }
2028 if ( $load && '' !== $located ) {
2029
2030 self::load_template( $located, $require_once, $args );
2031 }
2032
2033 return $located;
2034 }
2035
2036 public static function load_template( $_template_file, $require_once = true, $args = array() ) {
2037 if ( $require_once ) {
2038
2039 require_once $_template_file;
2040 } else {
2041 require $_template_file;
2042 }
2043 }
2044
2045
2046 public static function get_submission_count_and_ids( $survey_id, $filters = array() ){
2047 global $wpdb;
2048
2049 if($survey_id === null){
2050 return false;
2051 }
2052 $submitions_table = $wpdb->prefix . SURVEY_MAKER_DB_PREFIX . "submissions";
2053
2054 $filters_where_condition = "";
2055 if (isset($filters['is_filter']) && $filters['is_filter']) {
2056 $filters_where_condition = self::get_filters_where_condition($filters);
2057 }
2058
2059 //submission of each result
2060 $submission_ids = "SELECT id
2061 FROM {$submitions_table} j
2062 WHERE survey_id=". absint( $survey_id ) . $filters_where_condition . "
2063 ORDER BY id";
2064 $submission_ids_result = $wpdb->get_results($submission_ids,'ARRAY_A');
2065
2066 $submission_count_sql = "SELECT COUNT(id) AS count_submission
2067 FROM {$submitions_table}
2068 WHERE survey_id=". absint( $survey_id ) . $filters_where_condition ." ";
2069 $submission_count_result = $wpdb->get_var($submission_count_sql);
2070 $submission_count = '';
2071 $submissions_id_arr = array();
2072
2073 foreach ($submission_ids_result as $key => $submission_id_result) {
2074 $submission_count = intval($submission_count_result);
2075 $submissions_id_arr[] = $submission_id_result['id'];
2076 }
2077 $submissions_id_str = implode(',', $submissions_id_arr );
2078
2079 $submission_count_and_ids = array(
2080 'submission_count' => $submission_count,
2081 'submission_ids' => $submissions_id_str,
2082 'submission_ids_arr' => $submissions_id_arr,
2083 );
2084
2085 return $submission_count_and_ids;
2086 }
2087
2088 // Check users cookie
2089 public static function ays_survey_set_cookie($attr){
2090 $cookie_name = $attr['name'].$attr['id'];
2091 $cookie_value = $attr['title'];
2092 $cookie_value = isset( $attr['attempts_count'] ) ? $attr['attempts_count'] : 1;
2093 self::ays_survey_remove_cookie( $attr );
2094 $cookie_expiration = current_time('timestamp') + (1 * 365 * 24 * 60 * 60);
2095 setcookie($cookie_name, $cookie_value, $cookie_expiration, '/');
2096 }
2097
2098 public static function ays_survey_remove_cookie($attr){
2099 $cookie_name = $attr['name'].$attr['id'];
2100 if(isset($_COOKIE[$cookie_name])){
2101 unset($_COOKIE[$cookie_name]);
2102 $cookie_expiration = current_time('timestamp') - 1;
2103 setcookie($cookie_name, null, $cookie_expiration, '/');
2104 }
2105 }
2106
2107 public static function ays_survey_check_cookie($attr){
2108 $cookie_name = $attr['name'].$attr['id'];
2109 if(isset($_COOKIE[$cookie_name])){
2110 if( isset( $attr['increase_count'] ) && $attr['increase_count'] == true ){
2111 $attr['attempts_count'] = intval( $_COOKIE[$cookie_name] ) + 1;
2112 self::ays_survey_set_cookie( $attr );
2113 }
2114 return true;
2115 }
2116 return false;
2117 }
2118
2119 public static function get_limit_cookie_count($attr){
2120 $cookie_name = $attr['name'].$attr['id'];
2121 if(isset($_COOKIE[$cookie_name])){
2122 return intval( $_COOKIE[ $cookie_name ] );
2123 }
2124 return false;
2125 }
2126
2127 public static function get_user_profile_data(){
2128
2129 $user_first_name = '';
2130 $user_last_name = '';
2131 $user_nickname = '';
2132
2133 $user_id = get_current_user_id();
2134 if($user_id != 0){
2135 $usermeta = get_user_meta( $user_id );
2136
2137 if($usermeta !== null){
2138 $user_first_name = (isset($usermeta['first_name'][0]) && $usermeta['first_name'][0] != '' ) ? sanitize_text_field( $usermeta['first_name'][0] ) : '';
2139 $user_last_name = (isset($usermeta['last_name'][0]) && $usermeta['last_name'][0] != '' ) ? sanitize_text_field( $usermeta['last_name'][0] ) : '';
2140 $user_nickname = (isset($usermeta['nickname'][0]) && $usermeta['nickname'][0] != '' ) ? sanitize_text_field( $usermeta['nickname'][0] ) : '';
2141 }
2142 }
2143
2144 $message_data = array(
2145 'user_first_name' => $user_first_name,
2146 'user_last_name' => $user_last_name,
2147 'user_nickname' => $user_nickname,
2148 );
2149
2150 $current_user_data = get_userdata( $user_id );
2151 $user_display_name = "";
2152 $user_wordpress_roles = '';
2153 $user_website_url = '';
2154 $user_email = '';
2155
2156 if ( ! is_null( $current_user_data ) && $current_user_data ) {
2157 $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 ) : "";
2158 $user_email = ( isset( $current_user_data->data->user_email ) && $current_user_data->data->user_email != '' ) ? sanitize_text_field( $current_user_data->data->user_email ) : "";
2159 $user_wordpress_roles = ( isset( $current_user_data->roles ) && ! empty( $current_user_data->roles ) ) ? $current_user_data->roles : "";
2160 if ( !empty( $user_wordpress_roles ) && $user_wordpress_roles != "" ) {
2161 if ( is_array( $user_wordpress_roles ) ) {
2162 $user_wordpress_roles = implode(",", $user_wordpress_roles);
2163 }
2164 }
2165 $user_website_url = ( isset( $current_user_data->user_url ) && ! empty( $current_user_data->user_url ) ) ? $current_user_data->user_url : "";
2166 }
2167
2168 $message_data['user_display_name'] = $user_display_name;
2169 $message_data['user_wordpress_roles'] = $user_wordpress_roles;
2170 $message_data['user_website_url'] = $user_website_url;
2171 $message_data['user_wordpress_email'] = $user_email;
2172 $message_data['user_ip_address'] = self::get_user_ip();
2173
2174 return $message_data;
2175 }
2176
2177 public static function get_survey_results_count_by_id($id){
2178 global $wpdb;
2179
2180 $sql = "SELECT COUNT(*) AS res_count
2181 FROM {$wpdb->prefix}ayssurvey_submissions
2182 WHERE survey_id=". $id ." ";
2183
2184 $quiz = $wpdb->get_row($sql, 'ARRAY_A');
2185
2186 return $quiz;
2187 }
2188
2189 public static function ays_survey_is_elementor(){
2190 if( isset( $_GET['action'] ) && $_GET['action'] == 'elementor' ){
2191 $is_elementor = true;
2192 }elseif( isset( $_REQUEST['elementor-preview'] ) && $_REQUEST['elementor-preview'] != '' ){
2193 $is_elementor = true;
2194 }else{
2195 $is_elementor = false;
2196 }
2197
2198 if ( ! $is_elementor ) {
2199 $is_elementor = ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ? true : false;
2200 }
2201
2202 return $is_elementor;
2203 }
2204
2205 public static function ays_survey_is_editor(){
2206 $is_editor = false;
2207 if( isset( $_GET['action'] ) && ( $_GET['action'] == 'add' || $_GET['action'] == 'edit' ) ){
2208 if ( isset( $_GET['post'] ) && absint( $_GET['post'] ) > 0 ) {
2209 $is_editor = true;
2210 }
2211 } elseif ( isset( $_GET['context'] ) && ( $_GET['context'] == 'add' || $_GET['context'] == 'edit' ) ) {
2212 if( isset( $_GET['post_id'] ) & absint( $_GET['post_id'] ) > 0 ){
2213 $is_editor = true;
2214 }
2215 }
2216
2217 return $is_editor;
2218 }
2219
2220 // Retrieves the attachment ID from the file URL
2221 public static function ays_survey_get_image_id_by_url( $image_url ) {
2222 global $wpdb;
2223
2224 $image_alt_text = "";
2225 if ( !empty( $image_url ) ) {
2226
2227 $re = '/-\d+[Xx]\d+\./';
2228 $subst = '.';
2229
2230 $image_url = preg_replace($re, $subst, $image_url, 1);
2231
2232 $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid='%s';", $image_url ));
2233 if ( !is_null( $attachment ) && !empty( $attachment ) ) {
2234
2235 $image_id = (isset( $attachment[0] ) && $attachment[0] != "") ? absint( $attachment[0] ) : "";
2236 if ( $image_id != "" ) {
2237 $image_alt_text = self::ays_survey_get_image_alt_text_by_id( $image_id );
2238 }
2239 }
2240 }
2241
2242 return $image_alt_text;
2243 }
2244
2245 public static function ays_survey_get_image_alt_text_by_id( $image_id ) {
2246
2247 $image_data = "";
2248 if ( $image_id != "" ) {
2249
2250 $result = get_post_meta($image_id, '_wp_attachment_image_alt', TRUE);
2251 if ( $result && $result != "" ) {
2252 $image_data = esc_attr( $result );
2253 }
2254 }
2255
2256 return $image_data;
2257 }
2258
2259 public static function get_user_by_ip($id){
2260 global $wpdb;
2261 $user_ip = self::get_user_ip();
2262 $sql = "SELECT COUNT(*)
2263 FROM `{$wpdb->prefix}ayssurvey_submissions`
2264 WHERE `user_ip` = '$user_ip'
2265 AND `survey_id` = $id";
2266 $result = $wpdb->get_var($sql);
2267 return $result;
2268 }
2269
2270 public static function get_surveys_by_category( $id ){
2271 global $wpdb;
2272
2273 $id = ( isset( $id ) && $id != '' ) ? absint( intval( $id ) ) : null;
2274 $surveys_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "surveys";
2275 $categories_table = esc_sql( $wpdb->prefix . SURVEY_MAKER_DB_PREFIX ) . "survey_categories";
2276
2277 $results = '';
2278
2279 if($id != null){
2280 $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 );
2281 $results = $wpdb->get_results( $sql, 'ARRAY_A');
2282 }
2283
2284 return $results;
2285 }
2286
2287 public static function survey_lazy_loading_for_images( $toggle ){
2288 if($toggle){
2289 return "loading='lazy'";
2290 }
2291 return '';
2292 }
2293
2294 public static function survey_no_items_list_tables() {
2295 if( isset( $_GET['status'] ) && ($_GET['status'] == 'deleted' || $_GET['status'] == 'restored')){
2296 $url = remove_query_arg( array('fstatus', 'status', '_wpnonce') );
2297 $url = esc_url_raw( $url );
2298 wp_redirect( $url );
2299 }
2300 else{
2301 echo esc_html__( 'There are no surveys yet.', "survey-maker" );
2302 }
2303 }
2304
2305 public static function survey_get_loader($type , $loading = ''){
2306 switch( $type ){
2307 case 'default':
2308 $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>";
2309 break;
2310 case 'circle':
2311 $survey_loader_html = "<div data-class='lds-circle' data-role='loader' class='lds-circle ays-survey-wait-loading-loader'></div>";
2312 break;
2313 case 'dual_ring':
2314 $survey_loader_html = "<div data-class='lds-dual-ring' data-role='loader' class='lds-dual-ring ays-survey-wait-loading-loader'></div>";
2315 break;
2316 case 'facebook':
2317 $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>";
2318 break;
2319 case 'hourglass':
2320 $survey_loader_html = "<div data-class='lds-hourglass' data-role='loader' class='lds-hourglass ays-survey-wait-loading-loader'></div>";
2321 break;
2322 case 'ripple':
2323 $survey_loader_html = "<div data-class='lds-ripple' data-role='loader' class='lds-ripple ays-survey-wait-loading-loader'><div></div><div></div></div>";
2324 break;
2325 case 'snake':
2326 $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>';
2327 break;
2328 // case 'text':
2329 // $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>';
2330 // break;
2331 // case 'custom_gif':
2332 // $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>';
2333 // break;
2334 default:
2335 $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>";
2336 break;
2337 }
2338 return $survey_loader_html;
2339 }
2340
2341 public static function ays_set_survey_message_variables_data( $id, $survey, $settings_options ){
2342
2343 /*
2344 * Survey message variables for Start Page
2345 */
2346
2347 $survey = (array)$survey;
2348
2349 // Survey options
2350 $options = ( json_decode($survey['options'], true) != null ) ? json_decode($survey['options'], true) : array();
2351
2352 // General Setting's Options
2353
2354 // Do not store IP adressess
2355 $disable_user_ip = (isset($settings_options['disable_user_ip']) && $settings_options['disable_user_ip'] == 'on') ? true : false;
2356
2357 // Survey title
2358 $survey_title = (isset( $survey['title'] ) && $survey['title'] != "") ? stripslashes( sanitize_text_field($survey['title']) ) : "";
2359
2360 // Survey create date
2361 $survey_creation_date = (isset($survey['date_created']) && $survey['date_created'] != '') ? sanitize_text_field( $survey['date_created'] ) : "";
2362 if( $survey_creation_date != "" ){
2363 $survey_creation_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_creation_date ) );
2364 }
2365
2366 // Survey modified date
2367 $survey_modified_date = (isset($survey['date_modified']) && $survey['date_modified'] != '') ? sanitize_text_field( $survey['date_modified'] ) : "";
2368 if( $survey_modified_date != "" ){
2369 $survey_modified_date = date_i18n( get_option( 'date_format' ), strtotime( $survey_modified_date ) );
2370 }
2371
2372 // Current time
2373 $survey_current_time = explode( ' ', current_time( 'mysql' ) );
2374 $survey_current_time_only = ($survey_current_time[1]) ? $survey_current_time[1] : '';
2375
2376 // Get survey author
2377 $current_survey_user_data = get_userdata( $survey['author_id'] );
2378 $current_survey_author = '';
2379 $current_survey_author_email = '';
2380 if ( isset( $current_survey_user_data ) && $current_survey_user_data ) {
2381 // Get survey author name
2382 $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 ) : "";
2383 // Get survey author email
2384 $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 ) : "";
2385 }
2386
2387 $questions_count = (isset( $survey['questions_count'] ) && $survey['questions_count'] != "") ? stripslashes( sanitize_text_field($survey['questions_count']) ) : 0;
2388
2389 $survey_question_count = self::get_survey_questions_count($id);
2390 $survey_sections_count = self::get_survey_sections_count($id);
2391 $survey_passed_users_count = self::ays_survey_get_passed_users_count($id);
2392
2393 // WP home page url
2394 $home_main_url = home_url();
2395 $wp_home_page_url = '<a href="'.$home_main_url.'" target="_blank">'.$home_main_url.'</a>';
2396
2397 $survey_user_information = self::get_user_profile_data();
2398 // Get user first name
2399 $user_first_name = (isset( $survey_user_information['user_first_name'] ) && $survey_user_information['user_first_name'] != "") ? $survey_user_information['user_first_name'] : '';
2400
2401 // Get user last name
2402 $user_last_name = (isset( $survey_user_information['user_last_name'] ) && $survey_user_information['user_last_name'] != "") ? $survey_user_information['user_last_name'] : '';
2403
2404 // Get user nick name
2405 $user_nick_name = (isset( $survey_user_information['user_nickname'] ) && $survey_user_information['user_nickname'] != "") ? $survey_user_information['user_nickname'] : '';
2406
2407 // Get display name
2408 $user_display_name = (isset( $survey_user_information['user_display_name'] ) && $survey_user_information['user_display_name'] != "") ? $survey_user_information['user_display_name'] : '';
2409
2410 // User Wordpress role
2411 $user_wordpress_roles = (isset( $survey_user_information['user_wordpress_roles'] ) && $survey_user_information['user_wordpress_roles'] != "") ? $survey_user_information['user_wordpress_roles'] : '';
2412
2413 // User ip address
2414 $user_ip_address = "";
2415 if($disable_user_ip){
2416 $user_ip_address = '';
2417 }else{
2418 $user_ip_address = self::get_user_ip();
2419 }
2420
2421 // User wordpress email
2422 $user_wordpress_email = (isset( $survey_user_information['user_wordpress_email'] ) && $survey_user_information['user_wordpress_email'] != "") ? esc_attr($survey_user_information['user_wordpress_email']) : '';
2423
2424 $super_admin_email = get_option('admin_email');
2425
2426 $message_data = array(
2427 'survey_title' => $survey_title,
2428 'survey_id' => $id,
2429 'questions_count' => $questions_count,
2430 'current_time' => $survey_current_time_only,
2431 'sections_count' => $survey_sections_count,
2432 'users_count' => $survey_passed_users_count,
2433 'users_first_name' => $user_first_name,
2434 'users_last_name' => $user_last_name,
2435 'users_nick_name' => $user_nick_name,
2436 'users_display_name' => $user_display_name,
2437 'users_ip_address' => $user_ip_address,
2438 'user_wordpress_roles' => $user_wordpress_roles,
2439 'creation_date' => $survey_creation_date,
2440 'modified_date' => $survey_modified_date,
2441 'current_survey_author' => $current_survey_author,
2442 'current_survey_author_email' => $current_survey_author_email,
2443 'current_survey_page_link' => $current_survey_author_email,
2444 'admin_email' => $super_admin_email,
2445 'home_page_url' => $wp_home_page_url,
2446 );
2447
2448 return $message_data;
2449 }
2450
2451 public static function survey_sanitize_specific_content($content) {
2452 // Pattern to match <script> tags, dangerous attributes, and potential SVG exploits
2453 $pattern = '/<script.*?>.*?<\/script>|<[^>]+(?:\bon\w+\s*=\s*|attributeName\s*=\s*[^>]*>)/is';
2454
2455 // Callback function to convert matched tags into text
2456 $callback = function($matches) {
2457 // Convert characters to their HTML entities to render them as text
2458 return htmlspecialchars($matches[0], ENT_QUOTES, 'UTF-8');
2459 };
2460
2461 // Replace the matched patterns with their sanitized text equivalent
2462 $sanitized_content = preg_replace_callback($pattern, $callback, $content);
2463
2464 return $sanitized_content;
2465 }
2466
2467 // Sanitize data by admin level
2468 public static function admin_level_sanitize($data) {
2469
2470 if (is_multisite() && is_super_admin()) {
2471 return stripslashes($data);
2472
2473 } elseif (!is_multisite() && current_user_can('unfiltered_html')) {
2474 return stripslashes($data);
2475
2476 }
2477 return wp_kses_post($data);
2478 }
2479
2480 public static function ays_survey_pb_detect_mobile_device(){
2481 $useragent = $_SERVER['HTTP_USER_AGENT'];
2482 $flag = false;
2483 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))){
2484 $flag = true;
2485 }
2486 return $flag;
2487 }
2488
2489 public static function ays_survey_pb_detect_tablet_device(){
2490 $flag = false;
2491 if (preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
2492 $flag = true;
2493 }
2494 return $flag;
2495 }
2496
2497 public static function get_allowed_tags_for_loader() {
2498 return array(
2499 'span' => array('class' => array()),
2500 'img' => array('src' => array(), 'alt' => array()),
2501 );
2502 }
2503
2504 public static function ays_survey_allowed_html() {
2505 $additionalAllowedTags = wp_kses_allowed_html('post');
2506 return array_merge(
2507 $additionalAllowedTags,
2508 array(
2509 'div' => array(
2510 'class' => true,
2511 'id' => true,
2512 'style' => true,
2513 'data-*' => true,
2514 'aria-selected' => true,
2515 ),
2516 'svg' => array(
2517 'class' => true,
2518 'style' => true,
2519 'width' => true,
2520 'height' => true,
2521 'viewBox' => true,
2522 'viewbox' => true,
2523 'xmlns' => true,
2524 'fill' => true,
2525 'stroke' => true,
2526 'stroke-width' => true,
2527 'stroke-linecap' => true,
2528 'stroke-linejoin' => true,
2529 ),
2530 'path' => array(
2531 'class' => true,
2532 'd' => true,
2533 'fill' => true,
2534 'fill-rule' => true,
2535 'clip-rule' => true,
2536 'stroke-width' => true,
2537 'stroke-linecap' => true,
2538 ),
2539 'circle' => array(
2540 'style' => true,
2541 'id' => true,
2542 'class' => true,
2543 'r' => true,
2544 'cx' => true,
2545 'cy' => true,
2546 ),
2547 'rect' => array(
2548 'class' => true,
2549 'x' => true,
2550 'y' => true,
2551 'width' => true,
2552 'height' => true,
2553 'rx' => true,
2554 'fill' => true,
2555 'stroke' => true,
2556 'style' => true,
2557 'transform' => true,
2558 ),
2559 'defs' => array(
2560 'class' => true,
2561 'width' => true,
2562 'height' => true,
2563 'fill' => true,
2564 'style' => true,
2565 ),
2566 'pattern' => array(
2567 'class' => true,
2568 'id' => true,
2569 'width' => true,
2570 'height' => true,
2571 'patternContentUnits' => true,
2572 'patterncontentunits' => true,
2573 'style' => true,
2574 ),
2575 'use' => array(
2576 'class' => true,
2577 'id' => true,
2578 'xlink' => true,
2579 'xlink:href' => true,
2580 'transform' => true,
2581 'style' => true,
2582 ),
2583 'image' => array(
2584 'class' => true,
2585 'id' => true,
2586 'xlink' => true,
2587 'xlink:href' => true,
2588 'width' => true,
2589 'height' => true,
2590 'style' => true,
2591 ),
2592 'video' => array(
2593 'class' => true,
2594 'id' => true,
2595 'controls' => true,
2596 'style' => true,
2597 ),
2598 'source' => array(
2599 'class' => true,
2600 'id' => true,
2601 'src' => true,
2602 'style' => true,
2603 ),
2604 'form' => array(
2605 'name' => true,
2606 'id' => true,
2607 'action' => true,
2608 'method' => true,
2609 'data-*' => true,
2610 'style' => true,
2611 ),
2612 'input' => array(
2613 'id' => true,
2614 'name' => true,
2615 'class' => true,
2616 'type' => true,
2617 'value' => true,
2618 'size' => true,
2619 'required' => true,
2620 'readonly' => true,
2621 'data-*' => true,
2622 'style' => true,
2623 ),
2624 'select' => array(
2625 'id' => true,
2626 'name' => true,
2627 'class' => true,
2628 'type' => true,
2629 'value' => true,
2630 'size' => true,
2631 'required' => true,
2632 'readonly' => true,
2633 'data-*' => true,
2634 'style' => true,
2635 ),
2636 'option' => array(
2637 'id' => true,
2638 'class' => true,
2639 'type' => true,
2640 'value' => true,
2641 'size' => true,
2642 'required' => true,
2643 'readonly' => true,
2644 'data-*' => true,
2645 'style' => true,
2646 ),
2647 'progress' => array(
2648 'id' => true,
2649 'class' => true,
2650 'max' => true,
2651 'value' => true,
2652 'data-*' => true,
2653 'style' => true,
2654 ),
2655 'img' => array(
2656 'id' => true,
2657 'class' => true,
2658 'loading' => true,
2659 'decoding' => true,
2660 'src' => true,
2661 'sizes' => true,
2662 'srcset' => true,
2663 'width' => true,
2664 'height' => true,
2665 ),
2666 'a' => array(
2667 'aria-selected' => true,
2668 'data-*' => true,
2669 'style' => true,
2670 'target' => true,
2671 ),
2672 ),
2673 $additionalAllowedTags
2674 );
2675 }
2676
2677 public static function ays_survey_custom_allowed_html() {
2678 $additionalAllowedTags = self::ays_survey_allowed_html();
2679 return array_merge(
2680 $additionalAllowedTags,
2681 array(
2682 'iframe' => array(
2683 'class' => true,
2684 'id' => true,
2685 'width' => true,
2686 'height' => true,
2687 'src' => true,
2688 'title' => true,
2689 'frameborder' => true,
2690 'allow' => true,
2691 'allowfullscreen' => true,
2692 'loading' => true,
2693 'referrerpolicy' => true,
2694 'style' => true,
2695 ),
2696 'audio' => array(
2697 'class' => true,
2698 'id' => true,
2699 'controls' => true,
2700 'autoplay' => true,
2701 'loop' => true,
2702 'muted' => true,
2703 'preload' => true,
2704 'src' => true,
2705 'style' => true,
2706 ),
2707 'source' => array(
2708 'src' => true,
2709 'type' => true,
2710 ),
2711 'track' => array(
2712 'kind' => true,
2713 'src' => true,
2714 'srclang' => true,
2715 'label' => true,
2716 'default' => true,
2717 ),
2718 'video' => array(
2719 'class' => true,
2720 'id' => true,
2721 'width' => true,
2722 'height' => true,
2723 'controls' => true,
2724 'autoplay' => true,
2725 'loop' => true,
2726 'muted' => true,
2727 'poster' => true,
2728 'preload' => true,
2729 'src' => true,
2730 'style' => true,
2731 ),
2732 'picture' => array(
2733 'class' => true,
2734 'id' => true,
2735 ),
2736 'figure' => array(
2737 'class' => true,
2738 'id' => true,
2739 'style' => true,
2740 ),
2741 'figcaption' => array(
2742 'class' => true,
2743 'id' => true,
2744 'style' => true,
2745 ),
2746 ),
2747 $additionalAllowedTags
2748 );
2749 }
2750
2751 }
2752