| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly! |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Garbage collector class for supportcandy |
| 8 |
*/ |
| 9 |
if ( ! class_exists( 'WPSC_Cleaner' ) ) : |
| 10 |
|
| 11 |
final class WPSC_Cleaner { |
| 12 |
|
| 13 |
/** |
| 14 |
* Initialize this class |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public static function init() { |
| 19 |
|
| 20 |
// schedule cron jobs. |
| 21 |
add_action( 'init', array( __CLASS__, 'schedule' ) ); |
| 22 |
|
| 23 |
// upgrade cleanup. |
| 24 |
add_action( 'wpsc_v1_upgrade_cleanup', array( __CLASS__, 'v1_upgrade_cleanup' ) ); |
| 25 |
add_action( 'wpsc_v2_upgrade_cleanup', array( __CLASS__, 'v2_upgrade_cleanup' ) ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Schedule cron jobs |
| 30 |
* |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
public static function schedule() { |
| 34 |
|
| 35 |
// upgrade cleanup. |
| 36 |
$upgrade = get_option( 'wpsc_upgrade_cleanup', array() ); |
| 37 |
if ( $upgrade ) { |
| 38 |
if ( $upgrade['version'] == 1 && ! wp_next_scheduled( 'wpsc_v1_upgrade_cleanup' ) ) { |
| 39 |
wp_schedule_event( |
| 40 |
time(), |
| 41 |
'hourly', |
| 42 |
'wpsc_v1_upgrade_cleanup' |
| 43 |
); |
| 44 |
} |
| 45 |
if ( $upgrade['version'] == 2 && ! wp_next_scheduled( 'wpsc_v2_upgrade_cleanup' ) ) { |
| 46 |
wp_schedule_event( |
| 47 |
time(), |
| 48 |
'hourly', |
| 49 |
'wpsc_v2_upgrade_cleanup' |
| 50 |
); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* V1 upgrade cleanup |
| 57 |
* |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
public static function v1_upgrade_cleanup() { |
| 61 |
|
| 62 |
self::wpsc_upgrade_register_post_type(); |
| 63 |
$upgrade = get_option( 'wpsc_upgrade_cleanup', array() ); |
| 64 |
|
| 65 |
switch ( $upgrade['status'] ) { |
| 66 |
|
| 67 |
case 'texonomy': |
| 68 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_statuses' ); |
| 69 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_categories' ); |
| 70 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_priorities' ); |
| 71 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ticket_custom_fields' ); |
| 72 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ticket_widget' ); |
| 73 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_agents' ); |
| 74 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_attachment' ); |
| 75 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_en' ); |
| 76 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_canned_reply_categories' ); |
| 77 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_sf_rating' ); |
| 78 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_caa' ); |
| 79 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ep_rules' ); |
| 80 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_schedule_tickets' ); |
| 81 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_sla' ); |
| 82 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_usergroup_data' ); |
| 83 |
$upgrade['status'] = 'options'; |
| 84 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 85 |
break; |
| 86 |
|
| 87 |
case 'options': |
| 88 |
// ticket list more settings. |
| 89 |
delete_option( 'wpsc_tl_agent_orderby' ); |
| 90 |
delete_option( 'wpsc_tl_agent_orderby_order' ); |
| 91 |
delete_option( 'wpsc_tl_agent_no_of_tickets' ); |
| 92 |
delete_option( 'wpsc_tl_agent_unresolve_statuses' ); |
| 93 |
delete_option( 'wpsc_tl_customer_orderby' ); |
| 94 |
delete_option( 'wpsc_tl_customer_orderby_order' ); |
| 95 |
delete_option( 'wpsc_tl_customer_no_of_tickets' ); |
| 96 |
delete_option( 'wpsc_tl_customer_unresolve_statuses' ); |
| 97 |
// email notification general. |
| 98 |
delete_option( 'wpsc_en_from_name' ); |
| 99 |
delete_option( 'wpsc_en_from_email' ); |
| 100 |
delete_option( 'wpsc_en_reply_to' ); |
| 101 |
delete_option( 'wpsc_en_ignore_emails' ); |
| 102 |
delete_option( 'wpsc_support_page_id' ); |
| 103 |
// general settings. |
| 104 |
delete_option( 'wpsc_default_ticket_status' ); |
| 105 |
delete_option( 'wpsc_default_ticket_category' ); |
| 106 |
delete_option( 'wpsc_default_ticket_priority' ); |
| 107 |
delete_option( 'wpsc_ticket_status_after_customer_reply' ); |
| 108 |
delete_option( 'wpsc_ticket_status_after_agent_reply' ); |
| 109 |
delete_option( 'wpsc_close_ticket_status' ); |
| 110 |
delete_option( 'wpsc_allow_customer_close_ticket' ); |
| 111 |
delete_option( 'wpsc_reply_form_position' ); |
| 112 |
delete_option( 'wpsc_ticket_alice' ); |
| 113 |
delete_option( 'wpsc_allow_guest_ticket' ); |
| 114 |
delete_option( 'wpsc_allow_tinymce_in_guest_ticket' ); |
| 115 |
delete_option( 'wpsc_reply_to_close_ticket' ); |
| 116 |
delete_option( 'wpsc_default_login_setting' ); |
| 117 |
delete_option( 'wpsc_user_registration' ); |
| 118 |
// thank you page. |
| 119 |
delete_option( 'wpsc_thankyou_html' ); |
| 120 |
delete_option( 'wpsc_thankyou_url' ); |
| 121 |
// GDPR, terms & conditions. |
| 122 |
delete_option( 'wpsc_terms_and_conditions' ); |
| 123 |
delete_option( 'wpsc_terms_and_conditions_html' ); |
| 124 |
delete_option( 'wpsc_set_in_gdpr' ); |
| 125 |
delete_option( 'wpsc_gdpr_html' ); |
| 126 |
delete_option( 'wpsc_personal_data_retention_period_time' ); |
| 127 |
delete_option( 'wpsc_personal_data_retention_period_unit' ); |
| 128 |
// advanced settings. |
| 129 |
delete_option( 'wpsc_guest_can_upload_files' ); |
| 130 |
delete_option( 'wpsc_ticket_public_mode' ); |
| 131 |
delete_option( 'wpsc_allow_reply_confirmation' ); |
| 132 |
delete_option( 'wpsc_tinymce_toolbar' ); |
| 133 |
delete_option( 'wpsc_tinymce_toolbar_active' ); |
| 134 |
delete_option( 'wpsc_thread_date_format' ); |
| 135 |
delete_option( 'wpsc_do_not_notify_setting' ); |
| 136 |
// captcha. |
| 137 |
delete_option( 'wpsc_captcha' ); |
| 138 |
delete_option( 'wpsc_recaptcha_type' ); |
| 139 |
delete_option( 'wpsc_get_site_key' ); |
| 140 |
delete_option( 'wpsc_get_secret_key' ); |
| 141 |
// satisfaction survey. |
| 142 |
delete_option( 'wpsc_upgrade_sf_rating_map' ); |
| 143 |
delete_option( 'wpsc_sf_page' ); |
| 144 |
delete_option( 'wpsc_sf_thankyou_text' ); |
| 145 |
delete_option( 'wpsc_sf_age' ); |
| 146 |
delete_option( 'wpsc_sf_age_unit' ); |
| 147 |
delete_option( 'wpsc_sf_subject' ); |
| 148 |
delete_option( 'wpsc_sf_email_body' ); |
| 149 |
// email piping. |
| 150 |
delete_option( 'wpsc_ep_block_emails' ); |
| 151 |
delete_option( 'wpsc_ep_cron_execution_time' ); |
| 152 |
delete_option( 'wpsc_ep_piping_type' ); |
| 153 |
delete_option( 'wpsc_ep_client_id' ); |
| 154 |
delete_option( 'wpsc_ep_client_secret' ); |
| 155 |
delete_option( 'wpsc_ep_email_address' ); |
| 156 |
delete_option( 'wpsc_ep_imap_email_address' ); |
| 157 |
delete_option( 'wpsc_ep_imap_email_password' ); |
| 158 |
delete_option( 'wpsc_ep_imap_incoming_mail_server' ); |
| 159 |
delete_option( 'wpsc_ep_imap_port' ); |
| 160 |
delete_option( 'wpsc_ep_refresh_token' ); |
| 161 |
delete_option( 'wpsc_ep_historyId' ); |
| 162 |
delete_option( 'wpsc_ep_block_subject' ); |
| 163 |
delete_option( 'wpsc_ep_allowed_user' ); |
| 164 |
delete_option( 'wpsc_ep_email_type' ); |
| 165 |
delete_option( 'wpsc_ep_debug_mode' ); |
| 166 |
$upgrade['status'] = 'canned_reply'; |
| 167 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 168 |
break; |
| 169 |
|
| 170 |
case 'canned_reply': |
| 171 |
$results = get_posts( |
| 172 |
array( |
| 173 |
'post_type' => 'wpsc_canned_reply', |
| 174 |
'post_status' => array( 'publish', 'trash', 'auto-draft', 'draft' ), |
| 175 |
'posts_per_page' => 10, |
| 176 |
) |
| 177 |
); |
| 178 |
if ( $results ) { |
| 179 |
foreach ( $results as $post ) { |
| 180 |
wp_delete_post( $post->ID, true ); |
| 181 |
} |
| 182 |
} else { |
| 183 |
$upgrade['status'] = 'tickets'; |
| 184 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 185 |
} |
| 186 |
break; |
| 187 |
|
| 188 |
case 'tickets': |
| 189 |
$results = get_posts( |
| 190 |
array( |
| 191 |
'post_type' => 'wpsc_ticket', |
| 192 |
'post_status' => array( 'publish', 'trash' ), |
| 193 |
'posts_per_page' => 10, |
| 194 |
) |
| 195 |
); |
| 196 |
if ( $results ) { |
| 197 |
foreach ( $results as $post ) { |
| 198 |
wp_delete_post( $post->ID, true ); |
| 199 |
} |
| 200 |
} else { |
| 201 |
$upgrade['status'] = 'threads'; |
| 202 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 203 |
} |
| 204 |
break; |
| 205 |
|
| 206 |
case 'threads': |
| 207 |
$results = get_posts( |
| 208 |
array( |
| 209 |
'post_type' => 'wpsc_ticket_thread', |
| 210 |
'post_status' => array( 'publish', 'trash' ), |
| 211 |
'posts_per_page' => 10, |
| 212 |
) |
| 213 |
); |
| 214 |
if ( $results ) { |
| 215 |
foreach ( $results as $post ) { |
| 216 |
wp_delete_post( $post->ID, true ); |
| 217 |
} |
| 218 |
} else { |
| 219 |
delete_option( 'wpsc_upgrade_cleanup' ); |
| 220 |
$timestamp = wp_next_scheduled( 'wpsc_v1_upgrade_cleanup' ); |
| 221 |
if ( $timestamp ) { |
| 222 |
wp_unschedule_event( $timestamp, 'wpsc_v1_upgrade_cleanup' ); |
| 223 |
} |
| 224 |
} |
| 225 |
break; |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
/** |
| 230 |
* V2 upgrade cleanup |
| 231 |
* |
| 232 |
* @return void |
| 233 |
*/ |
| 234 |
public static function v2_upgrade_cleanup() { |
| 235 |
|
| 236 |
self::wpsc_upgrade_register_post_type(); |
| 237 |
$upgrade = get_option( 'wpsc_upgrade_cleanup', array() ); |
| 238 |
|
| 239 |
switch ( $upgrade['status'] ) { |
| 240 |
|
| 241 |
case 'texonomy': |
| 242 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_statuses' ); |
| 243 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_categories' ); |
| 244 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_priorities' ); |
| 245 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ticket_custom_fields' ); |
| 246 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ticket_widget' ); |
| 247 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_agents' ); |
| 248 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_attachment' ); |
| 249 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_en' ); |
| 250 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_canned_reply_categories' ); |
| 251 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_sf_rating' ); |
| 252 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_caa' ); |
| 253 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_ep_rules' ); |
| 254 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_schedule_tickets' ); |
| 255 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_sla' ); |
| 256 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_usergroup_data' ); |
| 257 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_usergroup_custom_field' ); |
| 258 |
self::wpsc_upgrade_delete_all_terms( 'wpsc_gf' ); |
| 259 |
$upgrade['status'] = 'options'; |
| 260 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 261 |
break; |
| 262 |
|
| 263 |
case 'options': |
| 264 |
// agent settings. |
| 265 |
delete_option( 'wpsc_agent_role' ); |
| 266 |
// ticket list more settings. |
| 267 |
delete_option( 'wpsc_tl_agent_orderby' ); |
| 268 |
delete_option( 'wpsc_tl_agent_orderby_order' ); |
| 269 |
delete_option( 'wpsc_tl_agent_no_of_tickets' ); |
| 270 |
delete_option( 'wpsc_tl_agent_unresolve_statuses' ); |
| 271 |
delete_option( 'wpsc_tl_customer_orderby' ); |
| 272 |
delete_option( 'wpsc_tl_customer_orderby_order' ); |
| 273 |
delete_option( 'wpsc_tl_customer_no_of_tickets' ); |
| 274 |
delete_option( 'wpsc_tl_customer_unresolve_statuses' ); |
| 275 |
delete_option( 'wpsc_close_ticket_group' ); |
| 276 |
delete_option( 'wpsc_tl_statuses' ); |
| 277 |
// email notification general. |
| 278 |
delete_option( 'wpsc_en_from_name' ); |
| 279 |
delete_option( 'wpsc_en_from_email' ); |
| 280 |
delete_option( 'wpsc_en_reply_to' ); |
| 281 |
delete_option( 'wpsc_en_ignore_emails' ); |
| 282 |
delete_option( 'wpsc_support_page_id' ); |
| 283 |
delete_option( 'wpsc_email_sending_method' ); |
| 284 |
delete_option( 'wpsc_en_send_mail_count' ); |
| 285 |
// general settings. |
| 286 |
delete_option( 'wpsc_default_ticket_status' ); |
| 287 |
delete_option( 'wpsc_default_ticket_category' ); |
| 288 |
delete_option( 'wpsc_default_ticket_priority' ); |
| 289 |
delete_option( 'wpsc_ticket_status_after_customer_reply' ); |
| 290 |
delete_option( 'wpsc_ticket_status_after_agent_reply' ); |
| 291 |
delete_option( 'wpsc_close_ticket_status' ); |
| 292 |
delete_option( 'wpsc_allow_customer_close_ticket' ); |
| 293 |
delete_option( 'wpsc_reply_form_position' ); |
| 294 |
delete_option( 'wpsc_ticket_alice' ); |
| 295 |
delete_option( 'wpsc_allow_guest_ticket' ); |
| 296 |
delete_option( 'wpsc_allow_tinymce_in_guest_ticket' ); |
| 297 |
delete_option( 'wpsc_reply_to_close_ticket' ); |
| 298 |
delete_option( 'wpsc_default_login_setting' ); |
| 299 |
delete_option( 'wpsc_user_registration' ); |
| 300 |
delete_option( 'wpsc_allow_to_create_ticket' ); |
| 301 |
delete_option( 'wpsc_allow_reply_to_close_ticket' ); |
| 302 |
delete_option( 'wpsc_user_registration_method' ); |
| 303 |
delete_option( 'wpsc_custom_registration_url' ); |
| 304 |
delete_option( 'wpsc_calender_date_format' ); |
| 305 |
delete_option( 'wpsc_custom_login_url' ); |
| 306 |
// thank you page. |
| 307 |
delete_option( 'wpsc_thankyou_html' ); |
| 308 |
delete_option( 'wpsc_thankyou_url' ); |
| 309 |
// GDPR, terms & conditions. |
| 310 |
delete_option( 'wpsc_terms_and_conditions' ); |
| 311 |
delete_option( 'wpsc_terms_and_conditions_html' ); |
| 312 |
delete_option( 'wpsc_set_in_gdpr' ); |
| 313 |
delete_option( 'wpsc_gdpr_html' ); |
| 314 |
delete_option( 'wpsc_personal_data_retention_period_time' ); |
| 315 |
delete_option( 'wpsc_personal_data_retention_period_unit' ); |
| 316 |
// advanced settings. |
| 317 |
delete_option( 'wpsc_guest_can_upload_files' ); |
| 318 |
delete_option( 'wpsc_ticket_public_mode' ); |
| 319 |
delete_option( 'wpsc_allow_reply_confirmation' ); |
| 320 |
delete_option( 'wpsc_tinymce_toolbar' ); |
| 321 |
delete_option( 'wpsc_tinymce_toolbar_active' ); |
| 322 |
delete_option( 'wpsc_thread_date_format' ); |
| 323 |
delete_option( 'wpsc_do_not_notify_setting' ); |
| 324 |
delete_option( 'wpsc_thread_date_time_format' ); |
| 325 |
delete_option( 'wpsc_allow_reply_to_public_tickets' ); |
| 326 |
delete_option( 'wpsc_default_do_not_notify_option' ); |
| 327 |
delete_option( 'wpsc_hide_show_priority' ); |
| 328 |
delete_option( 'wpsc_view_more' ); |
| 329 |
delete_option( 'wpsc_on_and_off_auto_refresh' ); |
| 330 |
delete_option( 'wpsc_ticket_id_type' ); |
| 331 |
delete_option( 'wpsc_custom_ticket_count' ); |
| 332 |
delete_option( 'wpsc_rt_id_length' ); |
| 333 |
delete_option( 'wpsc_thread_limit' ); |
| 334 |
delete_option( 'wpsc_redirect_to_ticket_list' ); |
| 335 |
delete_option( 'wpsc_reg_guest_user_after_create_ticket' ); |
| 336 |
delete_option( 'wpsc_auto_delete_ticket_time' ); |
| 337 |
delete_option( 'wpsc_auto_delete_ticket_time_period_unit' ); |
| 338 |
delete_option( 'wpsc_reply_bcc_visibility' ); |
| 339 |
delete_option( 'wpsc_new_ticket_btn_url' ); |
| 340 |
delete_option( 'wpsc_raised_by_user' ); |
| 341 |
delete_option( 'wpsc_allow_rich_text_editor' ); |
| 342 |
delete_option( 'wpsc_allow_html_pasting' ); |
| 343 |
// captcha. |
| 344 |
delete_option( 'wpsc_captcha' ); |
| 345 |
delete_option( 'wpsc_recaptcha_type' ); |
| 346 |
delete_option( 'wpsc_get_site_key' ); |
| 347 |
delete_option( 'wpsc_get_secret_key' ); |
| 348 |
delete_option( 'wpsc_registration_captcha' ); |
| 349 |
delete_option( 'wpsc_login_captcha' ); |
| 350 |
// appearance. |
| 351 |
delete_option( 'wpsc_create_ticket' ); |
| 352 |
delete_option( 'wpsc_appearance_login_form' ); |
| 353 |
delete_option( 'wpsc_appearance_general_settings' ); |
| 354 |
delete_option( 'wpsc_individual_ticket_page' ); |
| 355 |
delete_option( 'wpsc_modal_window' ); |
| 356 |
delete_option( 'wpsc_appearance_signup' ); |
| 357 |
delete_option( 'wpsc_appearance_ticket_list' ); |
| 358 |
// assign agent rules. |
| 359 |
delete_option( 'wpsc_assign_auto_responder' ); |
| 360 |
// automatic close ticket. |
| 361 |
delete_option( 'wpsc_atc_age' ); |
| 362 |
delete_option( 'wpsc_atc_status' ); |
| 363 |
delete_option( 'wpsc_atc_waring_email_age' ); |
| 364 |
delete_option( 'wpsc_atc_subject' ); |
| 365 |
delete_option( 'wpsc_atc_email_body' ); |
| 366 |
// satisfaction survey. |
| 367 |
delete_option( 'wpsc_upgrade_sf_rating_map' ); |
| 368 |
delete_option( 'wpsc_sf_page' ); |
| 369 |
delete_option( 'wpsc_sf_thankyou_text' ); |
| 370 |
delete_option( 'wpsc_sf_age' ); |
| 371 |
delete_option( 'wpsc_sf_age_unit' ); |
| 372 |
delete_option( 'wpsc_sf_subject' ); |
| 373 |
delete_option( 'wpsc_sf_email_body' ); |
| 374 |
// email piping. |
| 375 |
delete_option( 'wpsc_ep_block_emails' ); |
| 376 |
delete_option( 'wpsc_ep_cron_execution_time' ); |
| 377 |
delete_option( 'wpsc_ep_piping_type' ); |
| 378 |
delete_option( 'wpsc_ep_client_id' ); |
| 379 |
delete_option( 'wpsc_ep_client_secret' ); |
| 380 |
delete_option( 'wpsc_ep_email_address' ); |
| 381 |
delete_option( 'wpsc_ep_imap_email_address' ); |
| 382 |
delete_option( 'wpsc_ep_imap_email_password' ); |
| 383 |
delete_option( 'wpsc_ep_imap_incoming_mail_server' ); |
| 384 |
delete_option( 'wpsc_ep_imap_port' ); |
| 385 |
delete_option( 'wpsc_ep_refresh_token' ); |
| 386 |
delete_option( 'wpsc_ep_historyId' ); |
| 387 |
delete_option( 'wpsc_ep_block_subject' ); |
| 388 |
delete_option( 'wpsc_ep_allowed_user' ); |
| 389 |
delete_option( 'wpsc_ep_email_type' ); |
| 390 |
delete_option( 'wpsc_ep_debug_mode' ); |
| 391 |
delete_option( 'wpsc_ep_emails_forwarded' ); |
| 392 |
delete_option( 'wpsc_ep_from_email' ); |
| 393 |
delete_option( 'wpsc_ep_imap_encryption' ); |
| 394 |
delete_option( 'wpsc_close_user_warn_email_status' ); |
| 395 |
delete_option( 'wpsc_close_user_warn_email_body' ); |
| 396 |
delete_option( 'wpsc_ct_warn_email_status' ); |
| 397 |
delete_option( 'wpsc_ct_warn_email_body' ); |
| 398 |
delete_option( 'wpsc_ep_accept_emails' ); |
| 399 |
delete_option( 'wpsc_add_additional_recepients' ); |
| 400 |
// FAQ. |
| 401 |
delete_option( 'wpsc_select_faq_set' ); |
| 402 |
// knowledgebase. |
| 403 |
delete_option( 'wpsc_select_knowledgbase_set' ); |
| 404 |
// export ticket. |
| 405 |
delete_option( 'wpsc_selected_user_roll_data' ); |
| 406 |
delete_option( 'wpsc_export_ticket_list' ); |
| 407 |
delete_option( 'wpsc_customer_export_ticket_list' ); |
| 408 |
// woocommerce. |
| 409 |
delete_option( 'wpsc_dashboard_support_tab' ); |
| 410 |
delete_option( 'wpsc_dashboard_support_tab_label' ); |
| 411 |
delete_option( 'wpsc_order_help_button' ); |
| 412 |
delete_option( 'wpsc_order_help_button_label' ); |
| 413 |
delete_option( 'wpsc_woo_ticket_url' ); |
| 414 |
// schedule ticket. |
| 415 |
delete_option( 'wpsc_schedule_ticket_btn' ); |
| 416 |
// sla. |
| 417 |
delete_option( 'wpsc_out_sla_color' ); |
| 418 |
delete_option( 'wpsc_in_sla_color' ); |
| 419 |
// usergroups. |
| 420 |
delete_option( 'wpsc_usergroup_change_category' ); |
| 421 |
delete_option( 'wpsc_allow_ug_sup_close_ticket' ); |
| 422 |
// timer. |
| 423 |
delete_option( 'wpsc_timer_enable' ); |
| 424 |
delete_option( 'wpsc_timer_stop' ); |
| 425 |
delete_option( 'wpsc_timer_visibility_for_customer' ); |
| 426 |
// private credentials. |
| 427 |
delete_option( 'wpsc_pc_role_permissions' ); |
| 428 |
// print ticket. |
| 429 |
delete_option( 'wpsc_print_th_btn_setting' ); |
| 430 |
delete_option( 'wpsc_print_btn_lbl' ); |
| 431 |
delete_option( 'wpsc_print_cust_btn_setting' ); |
| 432 |
delete_option( 'wpsc_print_page_header_height' ); |
| 433 |
delete_option( 'wpsc_print_page_footer_height' ); |
| 434 |
delete_option( 'wpsc_print_ticket_header' ); |
| 435 |
delete_option( 'wpsc_print_ticket_body' ); |
| 436 |
delete_option( 'wpsc_print_ticket_footer' ); |
| 437 |
delete_option( 'wpsc_appearance_print_ticket' ); |
| 438 |
// attachment setting. |
| 439 |
delete_option( 'wpsc_attachment_max_filesize' ); |
| 440 |
delete_option( 'wpsc_allow_attachment_type' ); |
| 441 |
delete_option( 'wpsc_image_download_method' ); |
| 442 |
delete_option( 'wpsc_allow_attach_create_ticket' ); |
| 443 |
delete_option( 'wpsc_allow_attach_reply_form' ); |
| 444 |
delete_option( 'wpsc_show_attachment_notice' ); |
| 445 |
delete_option( 'wpsc_attachment_notice' ); |
| 446 |
// upgrade options. |
| 447 |
delete_option( 'wpsc_upgrade_permission_v2' ); |
| 448 |
delete_option( 'wpsc_v2_upgrade_cron_status' ); |
| 449 |
delete_option( 'wpsc_upgrade_installed_addons' ); |
| 450 |
delete_option( 'wpsc_upgrade_cf_slug_map' ); |
| 451 |
delete_option( 'wpsc_upgrade_cf_options_map' ); |
| 452 |
delete_option( 'wpsc_upgrade_status_map' ); |
| 453 |
delete_option( 'wpsc_upgrade_category_map' ); |
| 454 |
delete_option( 'wpsc_upgrade_priority_map' ); |
| 455 |
delete_option( 'wpsc_upgrade_agent_map' ); |
| 456 |
delete_option( 'wpsc_upgrade_ug_term_id_map' ); |
| 457 |
delete_option( 'wpsc_upgrade_saved_filters_map' ); |
| 458 |
delete_option( 'wpsc_upgrade_cf_term_id_map' ); |
| 459 |
delete_option( 'wpsc_upgrade_cf_slug_map' ); |
| 460 |
delete_option( 'wpsc_upgrade_en_term_id_map' ); |
| 461 |
delete_option( 'wpsc_upgrade_aar_map' ); |
| 462 |
delete_option( 'wpsc_upgrade_sla_policy_map' ); |
| 463 |
$upgrade['status'] = 'canned_reply'; |
| 464 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 465 |
break; |
| 466 |
|
| 467 |
case 'canned_reply': |
| 468 |
$results = get_posts( |
| 469 |
array( |
| 470 |
'post_type' => 'wpsc_canned_reply', |
| 471 |
'post_status' => array( 'publish', 'trash', 'auto-draft', 'draft' ), |
| 472 |
'posts_per_page' => 10, |
| 473 |
) |
| 474 |
); |
| 475 |
if ( $results ) { |
| 476 |
foreach ( $results as $post ) { |
| 477 |
wp_delete_post( $post->ID, true ); |
| 478 |
} |
| 479 |
} else { |
| 480 |
$upgrade['status'] = 'threads'; |
| 481 |
update_option( 'wpsc_upgrade_cleanup', $upgrade ); |
| 482 |
} |
| 483 |
break; |
| 484 |
|
| 485 |
case 'threads': |
| 486 |
$results = get_posts( |
| 487 |
array( |
| 488 |
'post_type' => 'wpsc_ticket_thread', |
| 489 |
'post_status' => array( 'publish', 'trash' ), |
| 490 |
'posts_per_page' => 10, |
| 491 |
) |
| 492 |
); |
| 493 |
if ( $results ) { |
| 494 |
foreach ( $results as $post ) { |
| 495 |
wp_delete_post( $post->ID, true ); |
| 496 |
} |
| 497 |
} else { |
| 498 |
delete_option( 'wpsc_upgrade_cleanup' ); |
| 499 |
$timestamp = wp_next_scheduled( 'wpsc_v2_upgrade_cleanup' ); |
| 500 |
if ( $timestamp ) { |
| 501 |
wp_unschedule_event( $timestamp, 'wpsc_v2_upgrade_cleanup' ); |
| 502 |
} |
| 503 |
} |
| 504 |
break; |
| 505 |
} |
| 506 |
} |
| 507 |
|
| 508 |
/** |
| 509 |
* Register post types in order to get data upgrade cleanup |
| 510 |
* |
| 511 |
* @return void |
| 512 |
*/ |
| 513 |
public static function wpsc_upgrade_register_post_type() { |
| 514 |
|
| 515 |
$args = array( |
| 516 |
'public' => false, |
| 517 |
'rewrite' => false, |
| 518 |
); |
| 519 |
register_post_type( 'wpsc_ticket', $args ); |
| 520 |
register_post_type( 'wpsc_ticket_thread', $args ); |
| 521 |
register_taxonomy( 'wpsc_categories', 'wpsc_ticket', $args ); |
| 522 |
register_taxonomy( 'wpsc_statuses', 'wpsc_ticket', $args ); |
| 523 |
register_taxonomy( 'wpsc_priorities', 'wpsc_ticket', $args ); |
| 524 |
register_taxonomy( 'wpsc_ticket_custom_fields', 'wpsc_ticket', $args ); |
| 525 |
register_taxonomy( 'wpsc_ticket_widget', 'wpsc_ticket', $args ); |
| 526 |
register_taxonomy( 'wpsc_agents', 'wpsc_ticket', $args ); |
| 527 |
register_taxonomy( 'wpsc_attachment', 'wpsc_ticket', $args ); |
| 528 |
register_taxonomy( 'wpsc_en', 'wpsc_ticket', $args ); |
| 529 |
// conditional assigned agent (assigned agent rules). |
| 530 |
register_taxonomy( 'wpsc_caa', 'wpsc_ticket', $args ); |
| 531 |
// canned reply. |
| 532 |
register_post_type( 'wpsc_canned_reply', $args ); |
| 533 |
register_taxonomy( 'wpsc_canned_reply_categories', 'wpsc_canned_reply', $args ); |
| 534 |
// satisfaction survey. |
| 535 |
register_taxonomy( 'wpsc_sf_rating', 'wpsc_ticket', $args ); |
| 536 |
// email piping. |
| 537 |
register_taxonomy( 'wpsc_ep_rules', 'wpsc_ticket', $args ); |
| 538 |
// schedule tickets. |
| 539 |
register_taxonomy( 'wpsc_schedule_tickets', 'wpsc_ticket', $args ); |
| 540 |
// sla. |
| 541 |
register_taxonomy( 'wpsc_sla', 'wpsc_ticket', $args ); |
| 542 |
// usergroup. |
| 543 |
register_taxonomy( 'wpsc_usergroup_data', 'wpsc_ticket', $args ); |
| 544 |
register_taxonomy( 'wpsc_usergroup_custom_field', 'wpsc_ticket', $args ); |
| 545 |
// gravity forms. |
| 546 |
register_taxonomy( 'wpsc_gf', 'wpsc_ticket', $args ); |
| 547 |
} |
| 548 |
|
| 549 |
/** |
| 550 |
* Delete all terms of given texonomy |
| 551 |
* |
| 552 |
* @param string $taxonomy_name - texonomy name. |
| 553 |
* @return void |
| 554 |
*/ |
| 555 |
public static function wpsc_upgrade_delete_all_terms( $taxonomy_name ) { |
| 556 |
|
| 557 |
$terms = get_terms( |
| 558 |
array( |
| 559 |
'taxonomy' => $taxonomy_name, |
| 560 |
'hide_empty' => false, |
| 561 |
) |
| 562 |
); |
| 563 |
foreach ( $terms as $term ) { |
| 564 |
wp_delete_term( $term->term_id, $taxonomy_name ); |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
endif; |
| 569 |
|
| 570 |
WPSC_Cleaner::init(); |
| 571 |
|