Blocks
2 months ago
Contracts
1 year ago
Database
1 week ago
Integrations
1 week ago
Libraries
1 week ago
Models
1 week ago
Seeds
1 year ago
Services
1 week ago
Support
1 week ago
config
1 week ago
lib
1 month ago
Activator.php
1 month ago
Attachment.php
1 week ago
Controller.php
1 year ago
Core.php
1 year ago
Deactivator.php
2 months ago
Factory.php
3 months ago
Files.php
1 week ago
Playlist.php
1 year ago
Plugin.php
1 month ago
Requirements.php
1 year ago
support.php
1 week ago
Deactivator.php
108 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Plugin deactivation and uninstall handler. |
| 4 | * |
| 5 | * @package PrestoPlayer |
| 6 | */ |
| 7 | |
| 8 | namespace PrestoPlayer; |
| 9 | |
| 10 | use PrestoPlayer\Database\Table; |
| 11 | use PrestoPlayer\Database\Visits; |
| 12 | use PrestoPlayer\Database\Presets; |
| 13 | use PrestoPlayer\Database\Videos; |
| 14 | use PrestoPlayer\Database\AudioPresets; |
| 15 | use PrestoPlayer\Database\Webhooks; |
| 16 | use PrestoPlayer\Models\ReusableVideo; |
| 17 | use PrestoPlayer\Services\Usage; |
| 18 | |
| 19 | /** |
| 20 | * Class Deactivator |
| 21 | * |
| 22 | * Handles plugin data cleanup on uninstall. |
| 23 | */ |
| 24 | class Deactivator { |
| 25 | |
| 26 | /** |
| 27 | * Handle plugin uninstall based on user settings. |
| 28 | * |
| 29 | * @return void |
| 30 | */ |
| 31 | public static function uninstall() { |
| 32 | // Get plugin settings. |
| 33 | $uninstall_settings = get_option( 'presto_player_uninstall' ); |
| 34 | |
| 35 | // Uninstall all data on delete if selected. |
| 36 | if ( isset( $uninstall_settings['uninstall_data'] ) && $uninstall_settings['uninstall_data'] ) { |
| 37 | self::delete_data_on_uninstall(); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Delete all plugin data from the database. |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | public static function delete_data_on_uninstall() { |
| 47 | // License. |
| 48 | delete_option( 'presto_player_license' ); |
| 49 | delete_option( 'presto_player_license_data' ); |
| 50 | |
| 51 | // Settings. |
| 52 | delete_option( 'presto_player_analytics' ); |
| 53 | delete_option( 'presto_player_google_analytics' ); |
| 54 | delete_option( 'presto_player_branding' ); |
| 55 | delete_option( 'presto_player_bunny_keys' ); |
| 56 | delete_option( 'presto_player_bunny_storage_zones' ); |
| 57 | delete_option( 'presto_player_bunny_pull_zones' ); |
| 58 | delete_option( 'presto_player_bunny_uid' ); |
| 59 | delete_option( 'presto_player_instant_video_width' ); |
| 60 | delete_option( 'presto_player_media_hub_sync_default' ); |
| 61 | |
| 62 | // Notices. |
| 63 | delete_option( 'presto_player_dismissed_notice_nginx_rules' ); |
| 64 | delete_option( 'presto_player_presto_player_bunny_uid' ); |
| 65 | delete_option( 'presto_player_dismissed_notice_presto_player_reusable_notice' ); |
| 66 | |
| 67 | // Uninstall option. |
| 68 | delete_option( 'presto_player_uninstall' ); |
| 69 | |
| 70 | // Tables. |
| 71 | delete_option( 'presto_preset_seed_version' ); |
| 72 | delete_option( 'presto_player_visits_database_version' ); |
| 73 | delete_option( 'presto_player_videos_database_version' ); |
| 74 | delete_option( 'presto_player_presets_database_version' ); |
| 75 | delete_option( 'presto_zone_token' ); |
| 76 | delete_option( 'presto_player_visits_upgrade_version' ); |
| 77 | delete_option( 'presto_player_pro_update_performance' ); |
| 78 | delete_option( 'presto_player_audio_presets_database_version' ); |
| 79 | delete_option( 'presto_player_email_collection_database_version' ); |
| 80 | delete_option( 'presto_audio_preset_seed_version' ); |
| 81 | |
| 82 | // Delete our tables. |
| 83 | $table = new Table(); |
| 84 | ( new Visits( $table ) )->uninstall(); |
| 85 | ( new Presets( $table ) )->uninstall(); |
| 86 | ( new AudioPresets( $table ) )->uninstall(); |
| 87 | ( new Videos( $table ) )->uninstall(); |
| 88 | ( new Webhooks( $table ) )->uninstall(); |
| 89 | |
| 90 | // Daily views KPI tracking. |
| 91 | delete_transient( Usage::DAILY_VIEWS_OPTION ); |
| 92 | delete_transient( 'presto_player_state_events_checked' ); |
| 93 | |
| 94 | // BSF Analytics event tracking. |
| 95 | delete_option( 'presto_player_tracked_version' ); |
| 96 | // BSF Analytics library prefixes options with the product slug (hyphenated). |
| 97 | delete_option( 'presto-player_usage_events_pending' ); |
| 98 | delete_option( 'presto-player_usage_events_pushed' ); |
| 99 | |
| 100 | // Delete all reusable videos. |
| 101 | $videos = new ReusableVideo(); |
| 102 | $all_videos = $videos->all( array( 'fields' => 'ids' ) ); |
| 103 | foreach ( $all_videos as $video_id ) { |
| 104 | wp_delete_post( $video_id, true ); |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 |