| 1 |
<?php |
| 2 |
global $ays_poll_db_version; |
| 3 |
$ays_poll_db_version = '1.9.0'; |
| 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 <info@ays-pro.com> |
| 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 |
if (function_exists('is_multisite') && is_multisite()) { |
| 35 |
if (isset($_GET['networkwide']) && (int)$_GET['networkwide'] === 1) { |
| 36 |
global $wpdb; |
| 37 |
$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs"); |
| 38 |
|
| 39 |
foreach ($blog_ids as $blog_id) { |
| 40 |
switch_to_blog($blog_id); |
| 41 |
self::create_tables(); |
| 42 |
restore_current_blog(); |
| 43 |
} |
| 44 |
return; |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
self::create_tables(); |
| 49 |
} |
| 50 |
|
| 51 |
private static function create_tables() { |
| 52 |
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 53 |
global $wpdb; |
| 54 |
$polls_table = $wpdb->prefix . 'ayspoll_polls'; |
| 55 |
$cats_table = $wpdb->prefix . 'ayspoll_categories'; |
| 56 |
$answers_table = $wpdb->prefix . 'ayspoll_answers'; |
| 57 |
$reports_table = $wpdb->prefix . 'ayspoll_reports'; |
| 58 |
$settings_table = $wpdb->prefix . 'ayspoll_settings'; |
| 59 |
$charset_collate = $wpdb->get_charset_collate(); |
| 60 |
$is_multisite = function_exists('is_multisite') && is_multisite(); |
| 61 |
|
| 62 |
$sql = "CREATE TABLE $polls_table ( |
| 63 |
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 64 |
post_id INT(16) UNSIGNED DEFAULT NULL, |
| 65 |
title VARCHAR(255) NOT NULL, |
| 66 |
description TEXT NOT NULL, |
| 67 |
question TEXT NOT NULL, |
| 68 |
type VARCHAR(32) NOT NULL, |
| 69 |
view_type VARCHAR(64) NOT NULL, |
| 70 |
categories VARCHAR(255) NOT NULL, |
| 71 |
image TEXT NULL, |
| 72 |
show_title INT(1) DEFAULT 1, |
| 73 |
styles TEXT NULL, |
| 74 |
custom_post_id INT(16) UNSIGNED DEFAULT NULL, |
| 75 |
custom_css TEXT NULL, |
| 76 |
theme_id INT(5) DEFAULT 1, |
| 77 |
PRIMARY KEY (id) |
| 78 |
)$charset_collate;"; |
| 79 |
dbDelta($sql); |
| 80 |
$sql = "CREATE TABLE $cats_table ( |
| 81 |
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 82 |
title VARCHAR(255) NOT NULL, |
| 83 |
description TEXT NOT NULL, |
| 84 |
options TEXT NULL, |
| 85 |
PRIMARY KEY (`id`) |
| 86 |
)$charset_collate;"; |
| 87 |
dbDelta($sql); |
| 88 |
$sql = "CREATE TABLE $answers_table ( |
| 89 |
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 90 |
poll_id INT(11) UNSIGNED NOT NULL, |
| 91 |
answer TEXT NULL, |
| 92 |
votes INT(11) NOT NULL, |
| 93 |
ordering INT(11) NOT NULL DEFAULT 1, |
| 94 |
redirect TEXT NULL, |
| 95 |
user_added INT(1) DEFAULT 0, |
| 96 |
show_user_added INT(1) DEFAULT 1, |
| 97 |
answer_img TEXT NULL, |
| 98 |
PRIMARY KEY (`id`) |
| 99 |
)$charset_collate;"; |
| 100 |
dbDelta($sql); |
| 101 |
$sql = "CREATE TABLE $reports_table ( |
| 102 |
id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 103 |
answer_id INT(11) UNSIGNED NOT NULL, |
| 104 |
user_ip VARCHAR(128) NOT NULL, |
| 105 |
user_id INT(11) DEFAULT 0, |
| 106 |
vote_date DATETIME NOT NULL, |
| 107 |
user_email VARCHAR(255) NOT NULL, |
| 108 |
unread INT(1) DEFAULT 1, |
| 109 |
other_info TEXT NULL, |
| 110 |
poll_id INT(11) UNSIGNED NOT NULL, |
| 111 |
multi_answer_ids TEXT NULL, |
| 112 |
PRIMARY KEY (`id`) |
| 113 |
)$charset_collate;"; |
| 114 |
dbDelta($sql); |
| 115 |
$sql = "CREATE TABLE $settings_table ( |
| 116 |
`id` INT(11) NOT NULL AUTO_INCREMENT, |
| 117 |
`meta_key` TEXT NULL, |
| 118 |
`meta_value` TEXT NULL, |
| 119 |
`note` TEXT NULL, |
| 120 |
`options` TEXT NULL, |
| 121 |
PRIMARY KEY (`id`) |
| 122 |
)$charset_collate;"; |
| 123 |
dbDelta($sql); |
| 124 |
|
| 125 |
$answers_table = $wpdb->prefix . 'ayspoll_answers'; |
| 126 |
$report_table = $wpdb->prefix . 'ayspoll_reports'; |
| 127 |
|
| 128 |
$answ_id = $wpdb->get_results("SELECT DISTINCT answer_id FROM $report_table", 'ARRAY_A'); |
| 129 |
if (isset($answ_id) && !empty($answ_id)) { |
| 130 |
$answer_ids = ''; |
| 131 |
foreach ($answ_id as $key => $value) { |
| 132 |
if ($key == count($answ_id) - 1 ) { |
| 133 |
$answer_ids .= $value['answer_id']; |
| 134 |
}else{ |
| 135 |
$answer_ids .= $value['answer_id'].','; |
| 136 |
} |
| 137 |
} |
| 138 |
$answ_poll_id = $wpdb->get_results("SELECT poll_id, id AS 'answ_id' FROM $answers_table WHERE id IN (".$answer_ids.")", 'ARRAY_A'); |
| 139 |
|
| 140 |
if($answ_poll_id > 0){ |
| 141 |
foreach ($answ_poll_id as $ap_key => $ap_value) { |
| 142 |
$poll_result = $wpdb->update( |
| 143 |
$report_table, |
| 144 |
array( |
| 145 |
'poll_id' => $ap_value['poll_id'] |
| 146 |
), |
| 147 |
array('answer_id' => $ap_value['answ_id']), |
| 148 |
array( |
| 149 |
'%d' |
| 150 |
), |
| 151 |
array('%d') |
| 152 |
); |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
|
| 158 |
private static function insert_default_values() { |
| 159 |
global $wpdb; |
| 160 |
$answers_table = $wpdb->prefix . 'ayspoll_answers'; |
| 161 |
$polls_table = esc_sql($wpdb->prefix . 'ayspoll_polls'); |
| 162 |
$cats_table = esc_sql($wpdb->prefix . 'ayspoll_categories'); |
| 163 |
$settings_table = esc_sql($wpdb->prefix . "ayspoll_settings"); |
| 164 |
$cat_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$cats_table); |
| 165 |
|
| 166 |
if ($cat_count == 0) { |
| 167 |
$wpdb->insert($cats_table, |
| 168 |
array( |
| 169 |
'title' => 'Uncategorized', |
| 170 |
'description' => 'Default poll category' |
| 171 |
), |
| 172 |
array( '%s', '%s' ) |
| 173 |
); |
| 174 |
} |
| 175 |
|
| 176 |
$poll_create_author = get_current_user_id(); |
| 177 |
$user = get_userdata($poll_create_author); |
| 178 |
$poll_author = array(); |
| 179 |
if ( ! is_null( $user ) && $user ) { |
| 180 |
$poll_author = array( |
| 181 |
'id' => $user->ID."", |
| 182 |
'name' => $user->data->display_name |
| 183 |
); |
| 184 |
} |
| 185 |
|
| 186 |
$author = json_encode($poll_author, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_HEX_QUOT); |
| 187 |
$author = str_replace('"', '\\"', $author); |
| 188 |
|
| 189 |
$polls_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$polls_table); |
| 190 |
|
| 191 |
if ($polls_count == 0) { |
| 192 |
$wpdb->insert($polls_table, |
| 193 |
array( |
| 194 |
'title' => 'Default choosing', |
| 195 |
'description' => 'Default choosing type ', |
| 196 |
'question' => 'Did you like our plugin?', |
| 197 |
'type' => 'choosing', |
| 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":"","poll_buttons_mobile_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":"","tiktok_link":""},"show_chart_type":"default_bar_chart","show_chart_type_google_height":"400","border_color":"#0C6291"}' |
| 200 |
), |
| 201 |
array( '%s', '%s', '%s', '%s', '%s', '%s' ) |
| 202 |
); |
| 203 |
$last_insert = $wpdb->insert_id; |
| 204 |
$wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'It was a mistake'),array( '%d', '%s' )); |
| 205 |
$wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'There was nothing special'),array( '%d', '%s' )); |
| 206 |
$wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Everything\'s ok'),array( '%d', '%s' )); |
| 207 |
$wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'I enjoyed it'),array( '%d', '%s' )); |
| 208 |
$wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'It\'s amazing'),array( '%d', '%s' )); |
| 209 |
|
| 210 |
// $wpdb->insert($polls_table, |
| 211 |
// array( |
| 212 |
// 'title' => 'Default rating', |
| 213 |
// 'description' => 'Default rating type ', |
| 214 |
// 'question' => 'Did you like our plugin?', |
| 215 |
// 'type' => 'rating', |
| 216 |
// 'view_type' => 'star', |
| 217 |
// 'categories' => ',1,', |
| 218 |
// '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"}' |
| 219 |
// ), |
| 220 |
// array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) |
| 221 |
// ); |
| 222 |
// $last_insert = $wpdb->insert_id; |
| 223 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '1'),array( '%d', '%s' )); |
| 224 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '2'),array( '%d', '%s' )); |
| 225 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '3'),array( '%d', '%s' )); |
| 226 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '4'),array( '%d', '%s' )); |
| 227 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '5'),array( '%d', '%s' )); |
| 228 |
|
| 229 |
// $wpdb->insert($polls_table, |
| 230 |
// array( |
| 231 |
// 'title' => 'Demographic poll', |
| 232 |
// 'description' => 'Demographic poll', |
| 233 |
// 'question' => 'Where are You from?', |
| 234 |
// 'type' => 'choosing', |
| 235 |
// 'categories' => ',1,', |
| 236 |
// 'show_title' => 1, |
| 237 |
// '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"}', |
| 238 |
// 'theme_id' => 2 |
| 239 |
// ), |
| 240 |
// array( '%s', '%s', '%s', '%s', '%s', '%d', '%s', '%d' ) |
| 241 |
// ); |
| 242 |
// $last_insert = $wpdb->insert_id; |
| 243 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Asia'),array( '%d', '%s' )); |
| 244 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Africa'),array( '%d', '%s' )); |
| 245 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Europe'),array( '%d', '%s' )); |
| 246 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'North America'),array( '%d', '%s' )); |
| 247 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'South America'),array( '%d', '%s' )); |
| 248 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => 'Australia/Oceania'),array( '%d', '%s' )); |
| 249 |
// $wpdb->insert($answers_table, array('poll_id' => $last_insert, 'answer' => '<b>Antarctica</b>'),array( '%d', '%s' )); |
| 250 |
} |
| 251 |
|
| 252 |
$metas = array( |
| 253 |
"mailchimp", |
| 254 |
"options", |
| 255 |
"fields_placeholders" |
| 256 |
); |
| 257 |
|
| 258 |
foreach($metas as $meta_key){ |
| 259 |
$meta_val = esc_sql($meta_key); |
| 260 |
$sql = "SELECT COUNT(*) FROM ".$settings_table." WHERE meta_key = %s"; |
| 261 |
$result = $wpdb->get_var( |
| 262 |
$wpdb->prepare( $sql, $meta_val) |
| 263 |
); |
| 264 |
if(intval($result) == 0){ |
| 265 |
$result = $wpdb->insert( |
| 266 |
$settings_table, |
| 267 |
array( |
| 268 |
'meta_key' => $meta_val, |
| 269 |
'meta_value' => "", |
| 270 |
'note' => "", |
| 271 |
'options' => "" |
| 272 |
), |
| 273 |
array( '%s', '%s', '%s', '%s' ) |
| 274 |
); |
| 275 |
} |
| 276 |
|
| 277 |
} |
| 278 |
|
| 279 |
$terms_activation = get_option('ays_poll_show_agree_terms'); |
| 280 |
$first_activation = get_option('ays_poll_maker_first_time_activation_page', false); |
| 281 |
|
| 282 |
if ( !$terms_activation && $first_activation ) { |
| 283 |
self::ays_poll_activator_request( 'activator' ); |
| 284 |
update_option('ays_poll_agree_terms', 'true'); |
| 285 |
update_option('ays_poll_show_agree_terms', 'hide'); |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
public static function ays_poll_update_db_check() { |
| 290 |
global $ays_poll_db_version; |
| 291 |
$is_plugin_downloaded = get_option('ays_poll_db_version', false) === false; |
| 292 |
|
| 293 |
if ($is_plugin_downloaded) { |
| 294 |
update_option('ays_poll_maker_first_time_activation_page', true); |
| 295 |
update_option('ays_poll_maker_poll_creation_challange', true); |
| 296 |
} |
| 297 |
|
| 298 |
if (get_site_option('ays_poll_db_version') != $ays_poll_db_version) { |
| 299 |
if (function_exists('is_multisite') && is_multisite()) { |
| 300 |
$current_blog_id = get_current_blog_id(); |
| 301 |
if (is_main_site($current_blog_id)) { |
| 302 |
self::activate(); |
| 303 |
update_option('ays_poll_db_version', $ays_poll_db_version); |
| 304 |
self::insert_default_values(); |
| 305 |
} |
| 306 |
} else { |
| 307 |
self::activate(); |
| 308 |
update_option('ays_poll_db_version', $ays_poll_db_version); |
| 309 |
self::insert_default_values(); |
| 310 |
} |
| 311 |
} |
| 312 |
} |
| 313 |
|
| 314 |
public static function ays_poll_activator_request($cta){ |
| 315 |
$curl = curl_init(); |
| 316 |
|
| 317 |
$api_url = "https://poll-plugin.com/poll-maker/"; |
| 318 |
|
| 319 |
wp_remote_post( $api_url, array( |
| 320 |
'timeout' => 30, |
| 321 |
'body' => wp_json_encode(array( |
| 322 |
'type' => 'poll-maker', |
| 323 |
'cta' => $cta, |
| 324 |
)), |
| 325 |
) ); |
| 326 |
} |
| 327 |
} |