PluginProbe
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls / 5.6.6
Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls v5.6.6
6.5.0 6.4.9 6.4.8 6.4.7 6.4.6 6.4.5 6.4.4 6.4.3 6.4.2 6.4.1 6.4.0 6.3.9 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 All 153 releases
poll-maker / includes / class-poll-maker-ays-activator.php

class-poll-maker-ays-activator.php in Poll Maker by AYS – Versus Polls, Anonymous Polls, Image Polls 5.6.6, at includes/class-poll-maker-ays-activator.php

276 lines 25.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 global $ays_poll_db_version;
3 $ays_poll_db_version = '1.8.7';
4 /**
5 * Fired during plugin activation
6 *
7 * @link https://ays-pro.com/
8 * @since 1.0.0
9 *
10 * @package Poll_Maker_Ays
11 * @subpackage Poll_Maker_Ays/includes
12 */
13
14 /**
15 * Fired during plugin activation.
16 *
17 * This class defines all code necessary to run during the plugin's activation.
18 *
19 * @since 1.0.0
20 * @package Poll_Maker_Ays
21 * @subpackage Poll_Maker_Ays/includes
22 * @author Poll Maker Team <[email protected]>
23 */
24 class Poll_Maker_Ays_Activator {
25
26 /**
27 * Short Description. (use period)
28 *
29 * Long Description.
30 *
31 * @since 1.0.0
32 */
33 public static function activate() {
34 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
35 global $wpdb;
36 $polls_table = $wpdb->prefix . 'ayspoll_polls';
37 $cats_table = $wpdb->prefix . 'ayspoll_categories';
38 $answers_table = $wpdb->prefix . 'ayspoll_answers';
39 $reports_table = $wpdb->prefix . 'ayspoll_reports';
40 $settings_table = $wpdb->prefix . 'ayspoll_settings';
41 $charset_collate = $wpdb->get_charset_collate();
42
43 $sql = "CREATE TABLE $polls_table (
44 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
45 post_id INT(16) UNSIGNED DEFAULT NULL,
46 title VARCHAR(255) NOT NULL,
47 description TEXT NOT NULL,
48 question TEXT NOT NULL,
49 type VARCHAR(32) NOT NULL,
50 view_type VARCHAR(64) NOT NULL,
51 categories VARCHAR(255) NOT NULL,
52 image TEXT DEFAULT '',
53 show_title INT(1) DEFAULT 1,
54 styles TEXT DEFAULT '',
55 custom_css TEXT DEFAULT '',
56 theme_id INT(5) DEFAULT 1,
57 PRIMARY KEY (id)
58 )$charset_collate;";
59 dbDelta($sql);
60 $sql = "CREATE TABLE $cats_table (
61 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
62 title VARCHAR(255) NOT NULL,
63 description TEXT NOT NULL,
64 options TEXT DEFAULT '',
65 PRIMARY KEY (`id`)
66 )$charset_collate;";
67 dbDelta($sql);
68 $sql = "CREATE TABLE $answers_table (
69 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
70 poll_id INT(11) UNSIGNED NOT NULL,
71 answer TEXT DEFAULT '',
72 votes INT(11) NOT NULL,
73 ordering INT(11) NOT NULL DEFAULT 1,
74 redirect TEXT DEFAULT '',
75 user_added INT(1) DEFAULT 0,
76 show_user_added INT(1) DEFAULT 1,
77 answer_img TEXT DEFAULT '',
78 PRIMARY KEY (`id`)
79 )$charset_collate;";
80 dbDelta($sql);
81 $sql = "CREATE TABLE $reports_table (
82 id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
83 answer_id INT(11) UNSIGNED NOT NULL,
84 user_ip VARCHAR(128) NOT NULL,
85 user_id INT(11) DEFAULT 0,
86 vote_date DATETIME NOT NULL,
87 user_email VARCHAR(255) NOT NULL,
88 unread INT(1) DEFAULT 1,
89 other_info TEXT DEFAULT '',
90 poll_id INT(11) UNSIGNED NOT NULL,
91 multi_answer_ids TEXT DEFAULT '',
92 PRIMARY KEY (`id`)
93 )$charset_collate;";
94 dbDelta($sql);
95 $sql = "CREATE TABLE $settings_table (
96 `id` INT(11) NOT NULL AUTO_INCREMENT,
97 `meta_key` TEXT NULL DEFAULT NULL,
98 `meta_value` TEXT NULL DEFAULT NULL,
99 `note` TEXT NULL DEFAULT NULL,
100 `options` TEXT NULL DEFAULT NULL,
101 PRIMARY KEY (`id`)
102 )$charset_collate;";
103 dbDelta($sql);
104
105 // AV added Poll id for report table
106 $answers_table = $wpdb->prefix . 'ayspoll_answers';
107 $report_table = $wpdb->prefix . 'ayspoll_reports';
108
109 $answ_id = $wpdb->get_results("SELECT DISTINCT answer_id FROM $report_table", 'ARRAY_A');
110 if (isset($answ_id) && !empty($answ_id)) {
111 $answer_ids = '';
112 foreach ($answ_id as $key => $value) {
113 if ($key == count($answ_id) - 1 ) {
114 $answer_ids .= $value['answer_id'];
115 }else{
116 $answer_ids .= $value['answer_id'].',';
117 }
118 }
119 $answ_poll_id = $wpdb->get_results("SELECT poll_id, id AS 'answ_id' FROM $answers_table WHERE id IN (".$answer_ids.")", 'ARRAY_A');
120
121 if($answ_poll_id > 0){
122 foreach ($answ_poll_id as $ap_key => $ap_value) {
123 $poll_result = $wpdb->update(
124 $report_table,
125 array(
126 'poll_id' => $ap_value['poll_id']
127 ),
128 array('answer_id' => $ap_value['answ_id']),
129 array(
130 '%d'
131 ),
132 array('%d')
133 );
134 }
135 }
136 }
137 }
138
139 private static function insert_default_values() {
140 global $wpdb;
141 $answers_table = $wpdb->prefix . 'ayspoll_answers';
142 $polls_table = esc_sql($wpdb->prefix . 'ayspoll_polls');
143 $cats_table = esc_sql($wpdb->prefix . 'ayspoll_categories');
144 $settings_table = esc_sql($wpdb->prefix . "ayspoll_settings");
145 $cat_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$cats_table);
146
147 if ($cat_count == 0) {
148 $wpdb->insert($cats_table,
149 array(
150 'title' => 'Uncategorized',
151 'description' => 'Default poll category'
152 ),
153 array( '%s', '%s' )
154 );
155 }
156
157 $poll_create_author = get_current_user_id();
158 $user = get_userdata($poll_create_author);
159 $poll_author = array();
160 if ( ! is_null( $user ) && $user ) {
161 $poll_author = array(
162 'id' => $user->ID."",
163 'name' => $user->data->display_name
164 );
165 }
166
167 $author = json_encode($poll_author, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT);
168 $author = str_replace('"', '\\"', $author);
169
170 $polls_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$polls_table);
171
172 if ($polls_count == 0) {
173 $wpdb->insert($polls_table,
174 array(
175 'title' => 'Default choosing',
176 'description' => 'Default choosing type ',
177 'question' => 'Did you like our plugin?',
178 'type' => 'choosing',
179 'categories' => ',1,',
180 'styles' => '{"randomize_answers":"off","main_color":"#0C6291","text_color":"#0C6291","button_text_color":"#FBFEF9","button_bg_color":"#0C6291","icon_color":"#0C6291","icon_size":24,"width":0,"width_for_mobile":0,"poll_min_height":"","btn_text":"Vote","border_style":"ridge","border_radius":"0","border_width":"2","box_shadow_color":"#000000","poll_box_shadow_x_offset":0,"poll_box_shadow_y_offset":0,"poll_box_shadow_z_offset":15,"enable_background_gradient":"off","background_gradient_color_1":"#103251","background_gradient_color_2":"#607593","poll_gradient_direction":"vertical","poll_question_size_pc":"16","poll_question_size_mobile":"16","poll_question_image_height":"","poll_question_image_object_fit":"cover","poll_mobile_max_width":"","poll_buttons_size":"medium","poll_buttons_font_size":"17","poll_buttons_mobile_font_size":"17","poll_buttons_left_right_padding":"20","poll_buttons_top_bottom_padding":"10","poll_buttons_border_radius":"3","poll_buttons_width":"","enable_box_shadow":"off","bg_color":"#FBFEF9","answer_bg_color":"#FBFEF9","answer_hover_color":"#0C6291","answer_border_side":"all_sides","answer_font_size":"16","poll_answer_font_size_mobile":"16","poll_answer_object_fit":"cover","poll_answer_padding":"10","poll_answer_margin":"10","poll_answer_border_radius":0,"poll_answer_icon_check":"off","poll_answer_icon":"radio","poll_answer_view_type":"list","poll_answer_enable_box_shadow":"off","poll_answer_box_shadow_color":"#000000","poll_answer_box_shadow_x_offset":0,"poll_answer_box_shadow_y_offset":0,"poll_answer_box_shadow_z_offset":10,"title_bg_color":"rgba(255,255,255,0)","poll_title_font_size":"20","poll_title_font_size_mobile":"20","bg_image":false,"enable_answer_style":"on","hide_results":0,"hide_result_message":0,"hide_results_text":"Thanks for your answer!","allow_not_vote":0,"show_social":0,"load_effect":"load_gif","load_gif":"plg_default","limit_users":0,"limitation_message":"","redirect_url":"","redirection_delay":0,"user_role":"","enable_restriction_pass":0,"restriction_pass_message":"","enable_logged_users":0,"enable_logged_users_message":"","notify_email_on":0,"notify_email":"","result_sort_type":"none","create_date":"' . current_time('mysql') . '","author":"' . $author . '","redirect_users":0,"redirect_after_vote_url":"","redirect_after_vote_delay":0,"published":1,"enable_pass_count":"on","activeInterval":"2019-05-30","activeIntervalSec":"","deactiveInterval":"2019-05-30","deactiveIntervalSec":"","active_date_message":"","active_date_check":"","enable_restart_button":0,"enable_vote_btn":1,"disable_answer_hover": 0,"logo_image":"","poll_enable_logo_url":"off","poll_logo_title":"","poll_logo_url":"","custom_class":"","enable_poll_title_text_shadow":"off","poll_title_text_shadow":"rgba(255,255,255,0)","poll_title_text_shadow_x_offset":2,"poll_title_text_shadow_y_offset":2,"poll_title_text_shadow_z_offset":0,"poll_allow_multivote":"off","multivote_answer_min_count":"1","poll_allow_multivote_count":"1","poll_direction":"ltr","show_create_date":0,"show_author":0,"ays_poll_show_timer":0,"ays_show_timer_type":"countdown","show_result_btn_see_schedule":"with_see","active_date_message_soon":"","show_result_btn_schedule":0,"dont_show_poll_cont":"off","see_res_btn_text":"See Results","enable_asnwers_sound":"off","poll_vote_reason":"off","enable_view_more_button":"off","poll_view_more_button_count":0,"answer_sort_type":"default","show_answers_numbering":"none","result_message":"","poll_social_buttons_heading":"","poll_show_social_ln":"on","poll_show_social_fb":"on","poll_show_social_tr":"on","poll_show_social_vk":"off","limit_users_method":"ip","show_votes_count":1,"show_res_percent":1,"show_login_form":"off","info_form":0,"fields":"apm_name,apm_email,apm_phone","required_fields":"apm_email","info_form_title":"","enable_mailchimp":"off","redirect_after_submit":0,"mailchimp_list":"","users_role":"[]","poll_bg_image_position":"center center","poll_bg_img_in_finish_page":"off","ays_add_post_for_poll":"off","result_in_rgba":"off","show_passed_users":"off","see_result_button":"on","see_result_radio":"ays_see_result_button","loader_font_size":"64","effect_message":"","poll_allow_collecting_users_data":"off","poll_every_answer_redirect_delay":"","poll_enable_answer_image_after_voting":"off","poll_enable_answer_redirect_delay":"off","poll_show_passed_users_count":3,"poll_allow_answer":"off","poll_allow_answer_require":"off","poll_answer_image_height":"150","poll_answer_image_height_for_mobile":"150","poll_answer_image_border_radius":"0","poll_title_alignment":"center","poll_title_alignment_mobile":"center","poll_text_type_length_enable":"off","poll_text_type_limit_type":"characters","poll_text_type_limit_length":"","poll_text_type_limit_message":"off","poll_text_type_placeholder":"Your answer","poll_text_type_width":"","poll_text_type_width_type":"percent","poll_enable_password":"off","poll_password":"","poll_enable_password_visibility":"off","poll_password_message":"","display_fields_labels":"off","autofill_user_data":"off","poll_logo_url_new_tab":"off","poll_create_author":' . $poll_create_author . ',"enable_social_links":"off","poll_social_links_heading":"","social_links":{"linkedin_link":"","facebook_link":"","twitter_link":"","vkontakte_link":"","youtube_link":""},"show_chart_type":"default_bar_chart","show_chart_type_google_height":"400","border_color":"#0C6291"}'
181 ),
182 array( '%s', '%s', '%s', '%s', '%s', '%s' )
183 );
184 $last_insert = $wpdb->insert_id;
185 $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'It was a mistake'),array( '%d', '%s' ));
186 $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'There was nothing special'),array( '%d', '%s' ));
187 $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Everything\'s ok'),array( '%d', '%s' ));
188 $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'I enjoyed it'),array( '%d', '%s' ));
189 $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'It\'s amazing'),array( '%d', '%s' ));
190
191 // $wpdb->insert($polls_table,
192 // array(
193 // 'title' => 'Default rating',
194 // 'description' => 'Default rating type ',
195 // 'question' => 'Did you like our plugin?',
196 // 'type' => 'rating',
197 // 'view_type' => 'star',
198 // 'categories' => ',1,',
199 // 'styles' => '{"randomize_answers":"off","main_color":"#0C6291","text_color":"#0C6291","button_text_color":"#FBFEF9","button_bg_color":"#0C6291","icon_color":"#0C6291","icon_size":24,"width":0,"width_for_mobile":0,"poll_min_height":"","btn_text":"Vote","border_style":"ridge","border_radius":"0","border_width":"2","box_shadow_color":"#000000","poll_box_shadow_x_offset":0,"poll_box_shadow_y_offset":0,"poll_box_shadow_z_offset":15,"enable_background_gradient":"off","background_gradient_color_1":"#103251","background_gradient_color_2":"#607593","poll_gradient_direction":"vertical","poll_question_size_pc":"16","poll_question_size_mobile":"16","poll_question_image_height":"","poll_question_image_object_fit":"cover","poll_mobile_max_width":"","poll_buttons_size":"medium","poll_buttons_font_size":"17","poll_buttons_mobile_font_size":"17","poll_buttons_left_right_padding":"20","poll_buttons_top_bottom_padding":"10","poll_buttons_border_radius":"3","poll_buttons_width":"","enable_box_shadow":"off","bg_color":"#FBFEF9","answer_bg_color":"#FBFEF9","answer_border_side":"all_sides","answer_font_size":"16","poll_answer_font_size_mobile":"16","poll_answer_object_fit":"cover","poll_answer_padding":"10","poll_answer_margin":"10","poll_answer_border_radius":0,"poll_answer_icon_check":"off","poll_answer_icon":"radio","poll_answer_view_type":"list","poll_answer_enable_box_shadow":"off","poll_answer_box_shadow_color":"#000000","poll_answer_box_shadow_x_offset":0,"poll_answer_box_shadow_y_offset":0,"poll_answer_box_shadow_z_offset":10,"title_bg_color":"rgba(255,255,255,0)","poll_title_font_size":"20","poll_title_font_size_mobile":"20","bg_image":false,"enable_answer_style":"on","hide_results":0,"hide_result_message":0,"hide_results_text":"Thanks for your answer!","allow_not_vote":0,"show_social":0,"load_effect":"load_gif","load_gif":"plg_default","limit_users":0,"limitation_message":"","redirect_url":"","redirection_delay":0,"user_role":"","enable_restriction_pass":0,"restriction_pass_message":"","enable_logged_users":0,"enable_logged_users_message":"","notify_email_on":0,"notify_email":"","result_sort_type":"none","create_date":"' . current_time('mysql') . '","author":"' . $author . '","redirect_users":0,"redirect_after_vote_url":"","redirect_after_vote_delay":0,"published":1,"enable_pass_count":"on","activeInterval":"2019-05-30","activeIntervalSec":"","deactiveInterval":"2019-05-30","deactiveIntervalSec":"","active_date_message":"","active_date_check":"","enable_restart_button":0,"enable_vote_btn":1,"disable_answer_hover": 0,"logo_image":"","poll_enable_logo_url":"off","poll_logo_title":"","poll_logo_url":"","custom_class":"","enable_poll_title_text_shadow":"off","poll_title_text_shadow":"rgba(255,255,255,0)","poll_title_text_shadow_x_offset":2,"poll_title_text_shadow_y_offset":2,"poll_title_text_shadow_z_offset":0,"poll_allow_multivote":"off","multivote_answer_min_count":"1","poll_allow_multivote_count":"1","poll_direction":"ltr","show_create_date":0,"show_author":0,"ays_poll_show_timer":0,"ays_show_timer_type":"countdown","show_result_btn_see_schedule":"with_see","active_date_message_soon":"","show_result_btn_schedule":0,"dont_show_poll_cont":"off","see_res_btn_text":"See Results","enable_asnwers_sound":"off","poll_vote_reason":"off","enable_view_more_button":"off","poll_view_more_button_count":0,"answer_sort_type":"default","show_answers_numbering":"none","result_message":"","poll_social_buttons_heading":"","poll_show_social_ln":"on","poll_show_social_fb":"on","poll_show_social_tr":"on","poll_show_social_vk":"off","limit_users_method":"ip","show_votes_count":1,"show_res_percent":1,"show_login_form":"off","info_form":0,"fields":"apm_name,apm_email,apm_phone","required_fields":"apm_email","info_form_title":"","enable_mailchimp":"off","redirect_after_submit":0,"mailchimp_list":"","users_role":"[]","poll_bg_image_position":"center center","poll_bg_img_in_finish_page":"off","ays_add_post_for_poll":"off","result_in_rgba":"off","show_passed_users":"off","see_result_button":"on","see_result_radio":"ays_see_result_button","loader_font_size":"","effect_message":"","poll_allow_collecting_users_data":"off","poll_every_answer_redirect_delay":"","poll_enable_answer_image_after_voting":"off","poll_enable_answer_redirect_delay":"off","poll_show_passed_users_count":3,"poll_allow_answer":"off","poll_allow_answer_require":"off","poll_answer_image_height":"150","poll_answer_image_height_for_mobile":"150","poll_answer_image_border_radius":"0","poll_title_alignment":"center","poll_title_alignment_mobile":"center","poll_text_type_length_enable":"off","poll_text_type_limit_type":"characters","poll_text_type_limit_length":"","poll_text_type_limit_message":"off","poll_text_type_placeholder":"Your answer","poll_text_type_width":"","poll_text_type_width_type":"percent","poll_enable_password":"off","poll_password":"","poll_enable_password_visibility":"off","poll_password_message":"","display_fields_labels":"off","autofill_user_data":"off","poll_logo_url_new_tab":"off","enable_social_links":"off","poll_social_links_heading":"","social_links":{"linkedin_link":"","facebook_link":"","twitter_link":"","vkontakte_link":"","youtube_link":""},"show_chart_type":"default_bar_chart","border_color":"#0C6291"}'
200 // ),
201 // array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' )
202 // );
203 // $last_insert = $wpdb->insert_id;
204 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '1'),array( '%d', '%s' ));
205 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '2'),array( '%d', '%s' ));
206 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '3'),array( '%d', '%s' ));
207 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '4'),array( '%d', '%s' ));
208 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '5'),array( '%d', '%s' ));
209
210 // $wpdb->insert($polls_table,
211 // array(
212 // 'title' => 'Demographic poll',
213 // 'description' => 'Demographic poll',
214 // 'question' => 'Where are You from?',
215 // 'type' => 'choosing',
216 // 'categories' => ',1,',
217 // 'show_title' => 1,
218 // 'styles' => '{"randomize_answers":"off","main_color":"#FBFEF9","text_color":"#FBFEF9","button_text_color":"#222222","button_bg_color":"#FBFEF9","icon_color":"#FBFEF9","icon_size":24,"width":0,"width_for_mobile":0,"poll_min_height":"","btn_text":"Vote","border_style":"ridge","border_radius":"0","border_width":"","box_shadow_color":"","poll_box_shadow_x_offset":0,"poll_box_shadow_y_offset":0,"poll_box_shadow_z_offset":15,"enable_background_gradient":"off","background_gradient_color_1":"#103251","background_gradient_color_2":"#607593","poll_gradient_direction":"vertical","poll_question_size_pc":"16","poll_question_size_mobile":"16","poll_question_image_height":"","poll_question_image_object_fit":"cover","poll_mobile_max_width":"","poll_buttons_size":"medium","poll_buttons_font_size":"17","poll_buttons_mobile_font_size":"17","poll_buttons_left_right_padding":"20","poll_buttons_top_bottom_padding":"10","poll_buttons_border_radius":"3","poll_buttons_width":"","enable_box_shadow":"","bg_color":"#222222","answer_bg_color":"#222222","answer_border_side":"all_sides","answer_font_size":"16","poll_answer_font_size_mobile":"16","poll_answer_object_fit":"cover","poll_answer_padding":"10","poll_answer_margin":"10","poll_answer_border_radius":0,"poll_answer_icon_check":"off","poll_answer_icon":"radio","poll_answer_view_type":"list","poll_answer_enable_box_shadow":"off","poll_answer_box_shadow_color":"#000000","poll_answer_box_shadow_x_offset":0,"poll_answer_box_shadow_y_offset":0,"poll_answer_box_shadow_z_offset":10,"title_bg_color":"rgba(255,255,255,0)","poll_title_font_size":"20","poll_title_font_size_mobile":"20","bg_image":false,"enable_answer_style":"on","hide_results":0,"hide_result_message":0,"hide_results_text":"Thanks for your answer!","allow_not_vote":1,"show_social":1,"active_tab":"General","load_effect":"load_gif","load_gif":"plg_2","limit_users":0,"limitation_message":"","redirect_url":"","redirection_delay":0,"user_role":"","enable_restriction_pass":0,"restriction_pass_message":"","enable_logged_users":0,"enable_logged_users_message":"","notify_email_on":0,"notify_email":"","result_sort_type":"DESC","create_date":"' . current_time('mysql') . '","author":"' . $author . '","redirect_users":0,"redirect_after_vote_url":"","redirect_after_vote_delay":0,"published":1,"enable_pass_count":"on","activeInterval":"2019-05-30","activeIntervalSec":"","deactiveInterval":"2019-05-30","deactiveIntervalSec":"","active_date_message":"","active_date_check":"","enable_restart_button":1,"enable_vote_btn":0,"disable_answer_hover": 0,"logo_image":"","poll_enable_logo_url":"off","poll_logo_title":"","poll_logo_url":"","custom_class":"","enable_poll_title_text_shadow":"off","poll_title_text_shadow":"rgba(255,255,255,0)","poll_title_text_shadow_x_offset":2,"poll_title_text_shadow_y_offset":2,"poll_title_text_shadow_z_offset":0,"poll_allow_multivote":"off","multivote_answer_min_count":"1","poll_allow_multivote_count":"1","poll_direction":"ltr","show_create_date":0,"show_author":0,"ays_poll_show_timer":0,"ays_show_timer_type":"countdown","show_result_btn_see_schedule":"with_see","active_date_message_soon":"","show_result_btn_schedule":0,"dont_show_poll_cont":"off","see_res_btn_text":"See Results","enable_asnwers_sound":"off","poll_vote_reason":"off","enable_view_more_button":"off","poll_view_more_button_count":0,"answer_sort_type":"default","show_answers_numbering":"none","result_message":"","poll_social_buttons_heading":"","poll_show_social_ln":"on","poll_show_social_fb":"on","poll_show_social_tr":"on","poll_show_social_vk":"off","limit_users_method":"ip","show_votes_count":1,"show_res_percent":1,"show_login_form":"off","info_form":0,"fields":"apm_name,apm_email,apm_phone","required_fields":"apm_email","info_form_title":"","enable_mailchimp":"off","redirect_after_submit":0,"mailchimp_list":"","users_role":"[]","poll_bg_image_position":"center center","poll_bg_img_in_finish_page":"off","ays_add_post_for_poll":"off","result_in_rgba":"off","show_passed_users":"off","see_result_button":"on","see_result_radio":"ays_see_result_button","loader_font_size":"","effect_message":"","poll_allow_collecting_users_data":"off","poll_every_answer_redirect_delay":"","poll_enable_answer_image_after_voting":"off","poll_enable_answer_redirect_delay":"off","poll_show_passed_users_count":3,"poll_allow_answer":"off","poll_allow_answer_require":"off","poll_answer_image_height":"150","poll_answer_image_height_for_mobile":"150","poll_answer_image_border_radius":"0","poll_title_alignment":"center","poll_title_alignment_mobile":"center","poll_text_type_length_enable":"off","poll_text_type_limit_type":"characters","poll_text_type_limit_length":"","poll_text_type_limit_message":"off","poll_text_type_placeholder":"Your answer","poll_text_type_width":"","poll_text_type_width_type":"percent","poll_enable_password":"off","poll_password":"","poll_enable_password_visibility":"off","poll_password_message":"","display_fields_labels":"off","autofill_user_data":"off","poll_logo_url_new_tab":"off","enable_social_links":"off","poll_social_links_heading":"","social_links":{"linkedin_link":"","facebook_link":"","twitter_link":"","vkontakte_link":"","youtube_link":""},"show_chart_type":"default_bar_chart","border_color":"#FBFEF9"}',
219 // 'theme_id' => 2
220 // ),
221 // array( '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d' )
222 // );
223 // $last_insert = $wpdb->insert_id;
224 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Asia'),array( '%d', '%s' ));
225 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Africa'),array( '%d', '%s' ));
226 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Europe'),array( '%d', '%s' ));
227 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'North America'),array( '%d', '%s' ));
228 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'South America'),array( '%d', '%s' ));
229 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Australia/Oceania'),array( '%d', '%s' ));
230 // $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '<b>Antarctica</b>'),array( '%d', '%s' ));
231 }
232
233 $metas = array(
234 "mailchimp",
235 "options",
236 "fields_placeholders"
237 );
238
239 foreach($metas as $meta_key){
240 $meta_val = esc_sql($meta_key);
241 $sql = "SELECT COUNT(*) FROM ".$settings_table." WHERE meta_key = %s";
242 $result = $wpdb->get_var(
243 $wpdb->prepare( $sql, $meta_val)
244 );
245 if(intval($result) == 0){
246 $result = $wpdb->insert(
247 $settings_table,
248 array(
249 'meta_key' => $meta_val,
250 'meta_value' => "",
251 'note' => "",
252 'options' => ""
253 ),
254 array( '%s', '%s', '%s', '%s' )
255 );
256 }
257
258 }
259 }
260
261 public static function ays_poll_update_db_check() {
262 global $ays_poll_db_version;
263 $is_plugin_downloaded = get_option('ays_poll_db_version', false) === false;
264
265 if ($is_plugin_downloaded) {
266 update_option('ays_poll_maker_first_time_activation_page', true);
267 update_option('ays_poll_maker_poll_creation_challange', true);
268 }
269
270 if (get_site_option('ays_poll_db_version') != $ays_poll_db_version) {
271 self::activate();
272 update_option('ays_poll_db_version', $ays_poll_db_version);
273 self::insert_default_values();
274 }
275 }
276 }