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

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