Fixed issues with multisite installation (#11)
This commit is contained in:
parent
8a35182d81
commit
8b9ce4c570
@ -47,7 +47,7 @@ The plugin is capable of handling multisite installations.
|
|||||||
### Requirements ###
|
### Requirements ###
|
||||||
* PHP 5.5 or above
|
* PHP 5.5 or above
|
||||||
* WordPress 4.4 or above
|
* WordPress 4.4 or above
|
||||||
* Statify plugin installed and activated (tested up to 1.5.1)
|
* Statify plugin installed and activated (tested up to 1.5.4)
|
||||||
|
|
||||||
## Frequently Asked Questions ##
|
## Frequently Asked Questions ##
|
||||||
|
|
||||||
@ -82,6 +82,9 @@ Because of this, an IP blacklist can only be applied while processing the reques
|
|||||||
|
|
||||||
## Changelog ##
|
## Changelog ##
|
||||||
|
|
||||||
|
### 1.4.3 / unreleased ###
|
||||||
|
* Fix issues with multisite installation (#11)
|
||||||
|
|
||||||
### 1.4.2 / 12.11.2017 ###
|
### 1.4.2 / 12.11.2017 ###
|
||||||
* Minor code fixes
|
* Minor code fixes
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
* @author Stefan Kalscheuer <stefan@stklcode.de>
|
||||||
*
|
*
|
||||||
* @package Statify_Blacklist
|
* @package Statify_Blacklist
|
||||||
* @version 1.4.2
|
* @version 1.4.3-alpha
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Robo\Exception\TaskException;
|
use Robo\Exception\TaskException;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "stklcode/statify-blacklist",
|
"name": "stklcode/statify-blacklist",
|
||||||
"version": "1.4.2",
|
"version": "1.4.3-alpha",
|
||||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"wordpress",
|
"wordpress",
|
||||||
|
@ -39,11 +39,12 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $sites as $site ) {
|
foreach ( $sites as $site ) {
|
||||||
switch_to_blog( $site['blog_id'] );
|
if ( is_array( $site ) ) {
|
||||||
add_option(
|
$site_id = $site['blog_id'];
|
||||||
'statify-blacklist',
|
} else {
|
||||||
self::default_options()
|
$site_id = $site->blog_id;
|
||||||
);
|
}
|
||||||
|
self::install_site( $site_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_current_blog();
|
restore_current_blog();
|
||||||
@ -55,6 +56,22 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the plugin for a single site on Multisite.
|
||||||
|
*
|
||||||
|
* @since 1.4.3
|
||||||
|
*
|
||||||
|
* @param integer $site_id Site ID.
|
||||||
|
*/
|
||||||
|
public static function install_site( $site_id ) {
|
||||||
|
switch_to_blog( (int) $site_id );
|
||||||
|
add_option(
|
||||||
|
'statify-blacklist',
|
||||||
|
self::default_options()
|
||||||
|
);
|
||||||
|
restore_current_blog();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin uninstall handler.
|
* Plugin uninstall handler.
|
||||||
@ -75,8 +92,12 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $sites as $site ) {
|
foreach ( $sites as $site ) {
|
||||||
switch_to_blog( $site['blog_id'] );
|
if ( is_array( $site ) ) {
|
||||||
delete_option( 'statify-blacklist' );
|
$site_id = $site['blog_id'];
|
||||||
|
} else {
|
||||||
|
$site_id = $site->blog_id;
|
||||||
|
}
|
||||||
|
self::uninstall_site( $site_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_to_blog( $old );
|
switch_to_blog( $old );
|
||||||
@ -85,6 +106,19 @@ class StatifyBlacklist_System extends StatifyBlacklist {
|
|||||||
delete_option( 'statify-blacklist' );
|
delete_option( 'statify-blacklist' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the plugin for a single site on Multisite.
|
||||||
|
*
|
||||||
|
* @since 1.4.3
|
||||||
|
*
|
||||||
|
* @param integer $site_id Site ID.
|
||||||
|
*/
|
||||||
|
public static function uninstall_site( $site_id ) {
|
||||||
|
$old = get_current_blog_id();
|
||||||
|
switch_to_blog( (int) $site_id );
|
||||||
|
delete_option( 'statify-blacklist' );
|
||||||
|
switch_to_blog( $old );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upgrade plugin options.
|
* Upgrade plugin options.
|
||||||
|
@ -90,8 +90,8 @@ class StatifyBlacklist {
|
|||||||
load_plugin_textdomain( 'statifyblacklist', false, STATIFYBLACKLIST_DIR . '/lang/' );
|
load_plugin_textdomain( 'statifyblacklist', false, STATIFYBLACKLIST_DIR . '/lang/' );
|
||||||
|
|
||||||
// Add actions.
|
// Add actions.
|
||||||
add_action( 'wpmu_new_blog', array( 'StatifyBlacklist_Install', 'init_site' ) );
|
add_action( 'wpmu_new_blog', array( 'StatifyBlacklist_System', 'install_site' ) );
|
||||||
add_action( 'delete_blog', array( 'StatifyBlacklist_System', 'init_site' ) );
|
add_action( 'delete_blog', array( 'StatifyBlacklist_System', 'uninstall_site' ) );
|
||||||
add_filter( 'plugin_row_meta', array( 'StatifyBlacklist_Admin', 'plugin_meta_link' ), 10, 2 );
|
add_filter( 'plugin_row_meta', array( 'StatifyBlacklist_Admin', 'plugin_meta_link' ), 10, 2 );
|
||||||
|
|
||||||
if ( is_multisite() ) {
|
if ( is_multisite() ) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "statify-blacklist",
|
"name": "statify-blacklist",
|
||||||
"version": "1.4.2",
|
"version": "1.4.3-alpha",
|
||||||
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
"description": "A blacklist extension for the famous Statify WordPress plugin",
|
||||||
"author": "Stefan Kalscheuer",
|
"author": "Stefan Kalscheuer",
|
||||||
"license": "GPL-2.0+",
|
"license": "GPL-2.0+",
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Plugin Name: Statify Blacklist
|
* Plugin Name: Statify Blacklist
|
||||||
* Plugin URI: https://wordpress.org/plugins/statify-blacklist/
|
* Plugin URI: https://wordpress.org/plugins/statify-blacklist/
|
||||||
* Description: Extension for the Statify plugin to add a customizable blacklists.
|
* Description: Extension for the Statify plugin to add a customizable blacklists.
|
||||||
* Version: 1.4.2
|
* Version: 1.4.3-alpha
|
||||||
* Author: Stefan Kalscheuer (@stklcode)
|
* Author: Stefan Kalscheuer (@stklcode)
|
||||||
* Author URI: https://www.stklcode.de
|
* Author URI: https://www.stklcode.de
|
||||||
* Text Domain: statify-blacklist
|
* Text Domain: statify-blacklist
|
||||||
|
Loading…
x
Reference in New Issue
Block a user