PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | admin/activation.php +50 -13 2.1.912.2.7 View file →
@@ -1,13 +1,13 @@
1 1 <?php
2 2 /**
3 3 * Class of activation/deactivation of the plugin. Must be registered in file includes/class.plugin.php
4 4 *
5 - * @author Webcraftic <wordpress.webraftic@gmail.com>
5 + * @author Webcraftic <wordpress.webraftic@gmail.com>
6 6 * @copyright (c) 02.12.2018, Webcraftic
7 - * @see Wbcr_Factory410_Activator
7 + * @see Wbcr_Factory419_Activator
8 8 *
9 - * @version 1.0.1
9 + * @version 1.0.1
10 10 */
11 11
12 12 // Exit if accessed directly
13 13 if ( ! defined( 'ABSPATH' ) ) {
@@ -13,10 +13,10 @@
13 13 if ( ! defined( 'ABSPATH' ) ) {
14 14 exit;
15 15 }
16 16
17 -class WINP_Activation extends Wbcr_Factory410_Activator {
18 -
17 +class WINP_Activation extends Wbcr_Factory419_Activator {
18 +
19 19 /**
20 20 * Method is executed during the activation of the plugin.
21 21 *
22 22 * @since 1.0.0
@@ -21,25 +21,62 @@
21 21 *
22 22 * @since 1.0.0
23 23 */
24 24 public function activate() {
25 -
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 +
26 58 // Write information about the first activation of plugin
27 59 if ( ! get_option( $this->plugin->getOptionName( 'first_activation' ) ) ) {
28 - update_option( $this->plugin->getOptionName( 'first_activation' ), array(
29 - 'version' => $this->plugin->getPluginVersion(),
30 - 'timestamp' => time()
31 - ) );
60 + update_option( $this->plugin->getOptionName( 'first_activation' ), $plugin_activation_info );
32 61 }
33 -
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() {
34 71 // Create a demo snippets with examples of use
35 72 if ( ! get_option( $this->plugin->getOptionName( 'demo_snippets_created' ) ) ) {
36 73 WINP_Helper::create_demo_snippets();
37 74 }
38 -
75 +
39 76 update_option( $this->plugin->getOptionName( 'what_new_210' ), 1 );
40 77 }
41 -
78 +
42 79 /**
43 80 * The method is executed during the deactivation of the plugin.
44 81 *
45 82 * @since 1.0.0