plugin_basename( SWATCHLINE_FILE ), 'ajax' => admin_url( 'admin-ajax.php' ), 'action' => self::ACTION, 'nonce' => wp_create_nonce( self::ACTION ), 'error' => __( 'Your choice could not be saved, so Swatchline was not deactivated. Reload the page and try again.', 'swatchline' ), ) ) . ';', 'before' ); } public function template(): void { if ( ! self::can() ) { return; } ?> $choice ) ); } /** * This site's answer (an option), so deactivating Swatchline on one site of a network never * decides for the sites still using it. Only while Swatchline is active for the whole network * (deactivated, and later deleted, from Network Admin) is the answer the network's (a site * option), and uninstall.php then applies it to every site. */ public static function set( string $choice ): void { if ( self::network_wide() ) { update_site_option( self::OPTION, $choice ); } else { update_option( self::OPTION, $choice, false ); } } /** Whether Swatchline is network-activated (so it is being deactivated for the whole network). */ public static function network_wide(): bool { if ( ! is_multisite() ) { return false; } if ( ! function_exists( 'is_plugin_active_for_network' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active_for_network( plugin_basename( SWATCHLINE_FILE ) ); } /** On activation: an earlier "delete" answer must not outlive a reactivation. */ public static function reset(): void { delete_option( self::OPTION ); if ( is_multisite() ) { delete_site_option( self::OPTION ); } } }