| @@ -1,89 +1,89 @@ | ||
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * Class of activation/deactivation of the plugin. Must be registered in file includes/class.plugin.php | |
| 4 | - * | |
| 5 | - * @author Webcraftic <wordpress.webraftic@gmail.com> | |
| 6 | - * @copyright (c) 02.12.2018, Webcraftic | |
| 7 | - * @see Wbcr_Factory456_Activator | |
| 8 | - * | |
| 9 | - * @version 1.0.1 | |
| 10 | - */ | |
| 11 | - | |
| 12 | -// Exit if accessed directly | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | - exit; | |
| 15 | -} | |
| 16 | - | |
| 17 | -class WINP_Activation extends Wbcr_Factory456_Activator { | |
| 18 | - | |
| 19 | - /** | |
| 20 | - * Method is executed during the activation of the plugin. | |
| 21 | - * | |
| 22 | - * @since 1.0.0 | |
| 23 | - */ | |
| 24 | - public function activate() { | |
| 25 | - $plugin_activation_info = [ | |
| 26 | - 'version' => $this->plugin->getPluginVersion(), | |
| 27 | - 'timestamp' => time() | |
| 28 | - ]; | |
| 29 | - | |
| 30 | - if ( is_multisite() && $this->plugin->isNetworkActive() ) { | |
| 31 | - global $wpdb; | |
| 32 | - | |
| 33 | - // Write information about the first activation of plugin | |
| 34 | - if ( ! get_site_option( $this->plugin->getOptionName( 'first_activation' ) ) ) { | |
| 35 | - update_site_option( $this->plugin->getOptionName( 'first_activation' ), $plugin_activation_info ); | |
| 36 | - } | |
| 37 | - | |
| 38 | - $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); | |
| 39 | - | |
| 40 | - if ( ! empty( $blogs ) ) { | |
| 41 | - foreach ( $blogs as $id ) { | |
| 42 | - | |
| 43 | - switch_to_blog( $id ); | |
| 44 | - | |
| 45 | - $this->new_activation(); | |
| 46 | - | |
| 47 | - restore_current_blog(); | |
| 48 | - } | |
| 49 | - } | |
| 50 | - | |
| 51 | - WINP_Helper::flush_page_cache(); | |
| 52 | - | |
| 53 | - return; | |
| 54 | - } | |
| 55 | - | |
| 56 | - $this->new_activation(); | |
| 57 | - | |
| 58 | - // Write information about the first activation of plugin | |
| 59 | - if ( ! get_option( $this->plugin->getOptionName( 'first_activation' ) ) ) { | |
| 60 | - update_option( $this->plugin->getOptionName( 'first_activation' ), $plugin_activation_info ); | |
| 61 | - } | |
| 62 | - | |
| 63 | - WINP_Helper::flush_page_cache(); | |
| 64 | - } | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 68 | - * @since 2.2.0 | |
| 69 | - */ | |
| 70 | - public function new_activation() { | |
| 71 | - // Create a demo snippets with examples of use | |
| 72 | - if ( ! get_option( $this->plugin->getOptionName( 'demo_snippets_created' ) ) ) { | |
| 73 | - WINP_Helper::create_demo_snippets(); | |
| 74 | - } | |
| 75 | - | |
| 76 | - update_option( $this->plugin->getOptionName( 'what_new_210' ), 1 ); | |
| 77 | - } | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * The method is executed during the deactivation of the plugin. | |
| 81 | - * | |
| 82 | - * @since 1.0.0 | |
| 83 | - */ | |
| 84 | - public function deactivate() { | |
| 85 | - // Code to be executed during plugin deactivation | |
| 86 | - } | |
| 87 | -} | |
| 88 | - | |
| 89 | - | |
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Class of activation/deactivation of the plugin. Must be registered in file includes/class.plugin.php | |
| 4 | + * | |
| 5 | + * @author Webcraftic <wordpress.webraftic@gmail.com> | |
| 6 | + * @copyright (c) 02.12.2018, Webcraftic | |
| 7 | + * @see Wbcr_Factory419_Activator | |
| 8 | + * | |
| 9 | + * @version 1.0.1 | |
| 10 | + */ | |
| 11 | + | |
| 12 | +// Exit if accessed directly | |
| 13 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 14 | + exit; | |
| 15 | +} | |
| 16 | + | |
| 17 | +class WINP_Activation extends Wbcr_Factory419_Activator { | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * Method is executed during the activation of the plugin. | |
| 21 | + * | |
| 22 | + * @since 1.0.0 | |
| 23 | + */ | |
| 24 | + public function activate() { | |
| 25 | + $plugin_activation_info = [ | |
| 26 | + 'version' => $this->plugin->getPluginVersion(), | |
| 27 | + 'timestamp' => time() | |
| 28 | + ]; | |
| 29 | + | |
| 30 | + if ( is_multisite() && $this->plugin->isNetworkActive() ) { | |
| 31 | + global $wpdb; | |
| 32 | + | |
| 33 | + // Write information about the first activation of plugin | |
| 34 | + if ( ! get_site_option( $this->plugin->getOptionName( 'first_activation' ) ) ) { | |
| 35 | + update_site_option( $this->plugin->getOptionName( 'first_activation' ), $plugin_activation_info ); | |
| 36 | + } | |
| 37 | + | |
| 38 | + $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); | |
| 39 | + | |
| 40 | + if ( ! empty( $blogs ) ) { | |
| 41 | + foreach ( $blogs as $id ) { | |
| 42 | + | |
| 43 | + switch_to_blog( $id ); | |
| 44 | + | |
| 45 | + $this->new_activation(); | |
| 46 | + | |
| 47 | + restore_current_blog(); | |
| 48 | + } | |
| 49 | + } | |
| 50 | + | |
| 51 | + WINP_Helper::flush_page_cache(); | |
| 52 | + | |
| 53 | + return; | |
| 54 | + } | |
| 55 | + | |
| 56 | + $this->new_activation(); | |
| 57 | + | |
| 58 | + // Write information about the first activation of plugin | |
| 59 | + if ( ! get_option( $this->plugin->getOptionName( 'first_activation' ) ) ) { | |
| 60 | + update_option( $this->plugin->getOptionName( 'first_activation' ), $plugin_activation_info ); | |
| 61 | + } | |
| 62 | + | |
| 63 | + WINP_Helper::flush_page_cache(); | |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * @author Alexander Kovalev <alex.kovalevv@gmail.com> | |
| 68 | + * @since 2.2.0 | |
| 69 | + */ | |
| 70 | + public function new_activation() { | |
| 71 | + // Create a demo snippets with examples of use | |
| 72 | + if ( ! get_option( $this->plugin->getOptionName( 'demo_snippets_created' ) ) ) { | |
| 73 | + WINP_Helper::create_demo_snippets(); | |
| 74 | + } | |
| 75 | + | |
| 76 | + update_option( $this->plugin->getOptionName( 'what_new_210' ), 1 ); | |
| 77 | + } | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * The method is executed during the deactivation of the plugin. | |
| 81 | + * | |
| 82 | + * @since 1.0.0 | |
| 83 | + */ | |
| 84 | + public function deactivate() { | |
| 85 | + // Code to be executed during plugin deactivation | |
| 86 | + } | |
| 87 | +} | |
| 88 | + | |
| 89 | + | |