PluginProbe
Statify / 1.6.3
Statify v1.6.3
2.0.2 2.0.1 trunk 0.7 0.8 0.9 1.0 1.2.8 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 All 32 releases
statify / inc / class-statify-install.php

class-statify-install.php in Statify 1.6.3, at inc/class-statify-install.php

90 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Statify: Statify_Install class
4 *
5 * This file contains the derived class for the plugin's installation features.
6 *
7 * @package Statify
8 * @since 0.1
9 */
10
11 // Quit if accessed outside WP context.
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Statify_Install
16 *
17 * @since 0.1
18 * @version 2016-12-20
19 */
20 class Statify_Install {
21
22 /**
23 * Plugin activation handler.
24 *
25 * @since 0.1.0
26 *
27 * @param bool $network_wide Whether the plugin was activated network-wide or not.
28 */
29 public static function init( $network_wide = false ) {
30
31 if ( $network_wide && is_multisite() ) {
32 $sites = get_sites();
33
34 // Create tables for each site in a network.
35 foreach ( $sites as $site ) {
36 // Convert object to array.
37 $site = (array) $site;
38
39 switch_to_blog( $site['blog_id'] );
40 self::_apply();
41 }
42
43 restore_current_blog();
44 } else {
45 self::_apply();
46 }
47 }
48
49 /**
50 * Sets up the plugin for a newly created site on Multisite.
51 *
52 * @since 1.4.4
53 *
54 * @param int $site_id Site ID.
55 */
56 public function init_site( $site_id ) {
57
58 switch_to_blog( (int) $site_id );
59
60 self::_apply();
61
62 restore_current_blog();
63 }
64
65 /**
66 * Creates the database tables needed for the plugin.
67 *
68 * @since 0.1.0
69 * @version 1.4.0
70 */
71 private static function _apply() {
72
73 // Cleanup any leftover transients.
74 delete_transient( 'statify_data' );
75
76 // Set up the cron event.
77 if ( ! wp_next_scheduled( 'statify_cleanup' ) ) {
78 wp_schedule_event(
79 time(),
80 'daily',
81 'statify_cleanup'
82 );
83 }
84
85 // Create the actual tables.
86 Statify_Table::init();
87 Statify_Table::create();
88 }
89 }
90