Blocks
6 months ago
Contracts
1 year ago
Database
4 months ago
Integrations
3 months ago
Libraries
3 months ago
Models
3 months ago
Seeds
1 year ago
Services
3 months ago
Support
4 months ago
config
4 months ago
lib
4 months ago
Activator.php
1 year ago
Attachment.php
4 months ago
Controller.php
1 year ago
Core.php
1 year ago
Deactivator.php
1 year ago
Factory.php
3 months ago
Files.php
1 year ago
Playlist.php
1 year ago
Plugin.php
9 months ago
Requirements.php
1 year ago
support.php
1 year ago
Deactivator.php
78 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PrestoPlayer; |
| 4 | |
| 5 | use PrestoPlayer\Database\Table; |
| 6 | use PrestoPlayer\Database\Visits; |
| 7 | use PrestoPlayer\Database\Presets; |
| 8 | use PrestoPlayer\Database\Videos; |
| 9 | use PrestoPlayer\Database\AudioPresets; |
| 10 | use PrestoPlayer\Database\Webhooks; |
| 11 | use PrestoPlayer\Models\ReusableVideo; |
| 12 | |
| 13 | class Deactivator { |
| 14 | |
| 15 | |
| 16 | public static function uninstall() { |
| 17 | // get plugin settings |
| 18 | $uninstall_settings = get_option( 'presto_player_uninstall' ); |
| 19 | |
| 20 | // uninstall all data on delete if selected |
| 21 | if ( isset( $uninstall_settings['uninstall_data'] ) && $uninstall_settings['uninstall_data'] ) { |
| 22 | self::delete_data_on_uninstall(); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | public static function delete_data_on_uninstall() { |
| 27 | // license |
| 28 | delete_option( 'presto_player_license' ); |
| 29 | delete_option( 'presto_player_license_data' ); |
| 30 | |
| 31 | // settings |
| 32 | delete_option( 'presto_player_analytics' ); |
| 33 | delete_option( 'presto_player_google_analytics' ); |
| 34 | delete_option( 'presto_player_branding' ); |
| 35 | delete_option( 'presto_player_bunny_keys' ); |
| 36 | delete_option( 'presto_player_bunny_storage_zones' ); |
| 37 | delete_option( 'presto_player_bunny_pull_zones' ); |
| 38 | delete_option( 'presto_player_bunny_uid' ); |
| 39 | delete_option( 'presto_player_instant_video_width' ); |
| 40 | delete_option( 'presto_player_media_hub_sync_default' ); |
| 41 | |
| 42 | // notices |
| 43 | delete_option( 'presto_player_dismissed_notice_nginx_rules' ); |
| 44 | delete_option( 'presto_player_presto_player_bunny_uid' ); |
| 45 | delete_option( 'presto_player_dismissed_notice_presto_player_reusable_notice' ); |
| 46 | |
| 47 | // uninstall option |
| 48 | delete_option( 'presto_player_uninstall' ); |
| 49 | |
| 50 | // tables |
| 51 | delete_option( 'presto_preset_seed_version' ); |
| 52 | delete_option( 'presto_player_visits_database_version' ); |
| 53 | delete_option( 'presto_player_videos_database_version' ); |
| 54 | delete_option( 'presto_player_presets_database_version' ); |
| 55 | delete_option( 'presto_zone_token' ); |
| 56 | delete_option( 'presto_player_visits_upgrade_version' ); |
| 57 | delete_option( 'presto_player_pro_update_performance' ); |
| 58 | delete_option( 'presto_player_audio_presets_database_version' ); |
| 59 | delete_option( 'presto_player_email_collection_database_version' ); |
| 60 | delete_option( 'presto_audio_preset_seed_version' ); |
| 61 | |
| 62 | // delete our tables |
| 63 | $table = new Table(); |
| 64 | ( new Visits( $table ) )->uninstall(); |
| 65 | ( new Presets( $table ) )->uninstall(); |
| 66 | ( new AudioPresets( $table ) )->uninstall(); |
| 67 | ( new Videos( $table ) )->uninstall(); |
| 68 | ( new Webhooks( $table ) )->uninstall(); |
| 69 | |
| 70 | // delete all reusable videos |
| 71 | $videos = new ReusableVideo(); |
| 72 | $all_videos = $videos->all( array( 'fields' => 'ids' ) ); |
| 73 | foreach ( $all_videos as $video_id ) { |
| 74 | wp_delete_post( $video_id, true ); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 |