PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.2
Kubio AI Page Builder v2.8.2
2.8.4 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 1 year ago Layout 1 year ago Separators 11 months ago StyleManager 1 month ago Styles 1 year ago Activation.php 1 year ago Backup.php 1 year ago CustomizerImporter.php 1 year ago Deactivation.php 1 year ago EditInKubioCustomizerPanel.php 1 year ago Element.php 1 year ago ElementBase.php 4 years ago Importer.php 1 month ago InnerBlocks.php 1 year ago KubioFrontPageRevertNotice.php 9 months ago LodashBasic.php 1 year ago Registry.php 1 year ago ThirdPartyPluginAssetLoaderInEditor.php 3 months ago Utils.php 6 days ago
Deactivation.php
60 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 private function deleteBlockTemplates( $post_type = 'wp_template' ) {
53 $entities = get_block_templates( array(), $post_type );
54
55 foreach ( $entities as $entity ) {
56 wp_delete_post( $entity->wp_id, true );
57 }
58 }
59 }
60