PluginProbe
Faust.js / 1.0.2
Faust.js v1.0.2
1.8.12 1.8.11 1.4.1 1.8.0 1.8.8 1.8.9 trunk 0.7.0 0.7.1 0.7.10 0.7.11 0.7.3 0.7.4 0.7.5 0.7.6 0.7.7 0.7.8 0.7.9 0.8.0 0.8.1 0.8.3 0.8.4 0.8.5 0.8.6 0.8.7 All 40 releases
← All changes | includes/utilities/callbacks.php +37 -13 0.7.01.0.2 View file →
@@ -6,12 +6,14 @@
6 6 */
7 7
8 8 namespace WPE\FaustWP\Utilities;
9 9
10 +use function WPE\FaustWP\Detect_Conflicts\delete_conflicts_dismissed;
10 11 use function WPE\FaustWP\Settings\{
11 12 get_secret_key,
12 13 faustwp_get_settings,
13 - faustwp_update_setting
14 + faustwp_update_setting,
15 + maybe_set_default_settings
14 16 };
15 17
16 18 if ( ! defined( 'ABSPATH' ) ) {
17 19 exit;
@@ -29,29 +31,34 @@
29 31 * @todo is flush_rewrite_rules() needed?
30 32 *
31 33 * @link https://developer.wordpress.org/reference/functions/register_activation_hook/
32 34 *
35 + * @param bool $network_active True if plugin is network activated.
36 + *
33 37 * @return void
34 38 */
35 -function handle_activation() {
39 +function handle_activation( $network_active ) {
36 40 if ( is_plugin_active( 'wpe-headless/wpe-headless.php' ) ) {
37 41 deactivate_plugins( 'wpe-headless/wpe-headless.php', true );
38 42 }
39 43
40 - $secret_key = get_secret_key();
41 - $settings = faustwp_get_settings();
44 + // Handle network activation of plugin within multisite.
45 + if ( $network_active ) {
46 + $args = array(
47 + 'fields' => 'ids',
48 + );
49 + $sites = get_sites( $args );
42 50
43 - if ( empty( $settings ) ) {
44 - faustwp_update_setting( 'disable_theme', '1' );
45 - faustwp_update_setting( 'enable_rewrites', '1' );
46 - faustwp_update_setting( 'enable_redirects', '1' );
47 - }
51 + foreach ( $sites as $site ) {
52 + switch_to_blog( $site );
53 + maybe_set_default_settings();
54 + restore_current_blog();
55 + }
48 56
49 - if ( ! $secret_key ) {
50 - faustwp_update_setting( 'secret_key', wp_generate_uuid4() );
57 + return;
51 58 }
52 59
53 - flush_rewrite_rules();
60 + maybe_set_default_settings();
54 61 }
55 62
56 63 register_deactivation_hook( FAUSTWP_FILE, __NAMESPACE__ . '\\handle_deactivation' );
57 64 /**
@@ -56,9 +63,9 @@
56 63 register_deactivation_hook( FAUSTWP_FILE, __NAMESPACE__ . '\\handle_deactivation' );
57 64 /**
58 65 * Callback for WordPress register_deactivation_hook() function.
59 66 *
60 - * Flush rewrite rules on plugin deactivation.
67 + * Clear conflict dismissals and flush rewrites on plugin deactivation.
61 68 *
62 69 * @todo is flush_rewrite_rules() needed?
63 70 *
64 71 * @link https://developer.wordpress.org/reference/functions/register_deactivation_hook/
@@ -65,6 +72,23 @@
65 72 *
66 73 * @return void
67 74 */
68 75 function handle_deactivation() {
76 + delete_conflicts_dismissed();
69 77 flush_rewrite_rules();
78 +}
79 +
80 +add_action( 'wp_initialize_site', __NAMESPACE__ . '\\handle_new_site_creation' );
81 +/**
82 + * Fires when a site's initialization routine should be executed.
83 + *
84 + * @link https://developer.wordpress.org/reference/hooks/wp_initialize_site/
85 + *
86 + * @param WP_Site $new_site New site object.
87 + *
88 + * @return void
89 + */
90 +function handle_new_site_creation( $new_site ) {
91 + switch_to_blog( $new_site->blog_id );
92 + maybe_set_default_settings();
93 + restore_current_blog();
70 94 }