PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.4.3
Kubio AI Page Builder v2.4.3
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / src / Core / Deactivation.php
kubio / lib / src / Core Last commit date
Background 1 year ago Blocks 1 year ago GlobalElements 3 years ago Layout 4 years ago License 2 years ago Separators 4 years ago StyleManager 1 year ago Styles 4 years ago Activation.php 1 year ago Backup.php 4 years ago CustomizerImporter.php 1 year ago Deactivation.php 4 years ago EditInKubioCustomizerPanel.php 4 years ago Element.php 2 years ago ElementBase.php 4 years ago Importer.php 2 years ago InnerBlocks.php 4 years ago LodashBasic.php 2 years ago Registry.php 3 years ago Utils.php 1 year ago
Deactivation.php
62 lines
1 <?php
2
3 namespace Kubio\Core;
4
5 use Kubio\Flags;
6
7 class Deactivation {
8
9 private static $instance = null;
10
11 public static function load() {
12 if ( ! self::$instance ) {
13 self::$instance = new self();
14 }
15
16 return self::$instance;
17 }
18
19 public function __construct() {
20 add_action( 'kubio/plugin_deactivated', array( $this, 'deactivate' ) );
21 }
22
23 public function deactivate() {
24
25 $active_plugins = get_option( 'active_plugins', array() );
26
27 $current_plugin_file = trim( str_replace( wp_normalize_path( WP_PLUGIN_DIR ), '', wp_normalize_path( KUBIO_ENTRY_FILE ) ), '/' );
28 $active_plugins = array_diff( $active_plugins, array( $current_plugin_file ) );
29
30 // if another kubio plugin is still active ( pro or free version ) skip backup
31 foreach ( $active_plugins as $active_plugin ) {
32 if ( strpos( $active_plugin, 'kubio/' ) === 0 || strpos( $active_plugin, 'kubio-pro/' ) === 0 ) {
33 return;
34 }
35 }
36
37 $identifier = uniqid( 'bkp-deactivation-' );
38 $backup = new Backup();
39 $result = $backup->backupSiteStructureAndStyle( $identifier );
40
41 // stop deactivating block templates is the backup fails
42 if ( is_wp_error( $result ) ) {
43 return;
44 }
45
46 $template = get_stylesheet();
47 Flags::setSetting( "deactivation_backup_key.{$template}", $identifier );
48 $this->deleteBlockTemplates( 'wp_template' );
49 $this->deleteBlockTemplates( 'wp_template_part' );
50
51 }
52
53 private function deleteBlockTemplates( $post_type = 'wp_template' ) {
54 $entities = get_block_templates( array(), $post_type );
55
56 foreach ( $entities as $entity ) {
57 wp_delete_post( $entity->wp_id, true );
58 }
59 }
60
61 }
62