Peter’s Login Redirect - Version 2.9.8

Version Description

  • Added multisite support.
Download this release

Release Info

Developer Collizo4sky
Plugin Icon 128x128 Peter’s Login Redirect
Version 2.9.8
Comparing to
See all releases

Code changes from version 2.9.7 to 2.9.8

Files changed (2) hide show
  1. readme.txt +5 -2
  2. wplogin_redirect.php +87 -4
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate link: https://profilepress.net/pricing
4
  Tags: login, logout, redirect, admin, administration, dashboard, users, authentication
5
  Requires at least: 4.0
6
  Requires PHP: 5.4
7
- Tested up to: 5.4
8
- Stable tag: 2.9.7
9
  License: GPL-2.0+
10
 
11
  Redirect users to different locations after logging in and logging out.
@@ -160,6 +160,9 @@ Be sure to rawurlencode the returned variable if necessary.
160
 
161
  == Changelog ==
162
 
 
 
 
163
  = 2.9.7 =
164
  * Added option to redirect to any url specified.
165
 
4
  Tags: login, logout, redirect, admin, administration, dashboard, users, authentication
5
  Requires at least: 4.0
6
  Requires PHP: 5.4
7
+ Tested up to: 5.7
8
+ Stable tag: 2.9.8
9
  License: GPL-2.0+
10
 
11
  Redirect users to different locations after logging in and logging out.
160
 
161
  == Changelog ==
162
 
163
+ = 2.9.8 =
164
+ * Added multisite support.
165
+
166
  = 2.9.7 =
167
  * Added option to redirect to any url specified.
168
 
wplogin_redirect.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://www.theblog.ca/wplogin-redirect
5
  Description: Redirect users to different locations after logging in. Define a set of rules for specific users, user with specific roles, users with specific capabilities, and a blanket rule for all other users. This is all managed in Settings > Login/logout redirects.
6
  Author: Peter Keung
7
  Author URI: http://www.theblog.ca
8
- Version: 2.9.7
9
  Text Domain: peters-login-redirect
10
  Domain Path: /languages/
11
  */
@@ -23,7 +23,7 @@ global $rul_db_addresses;
23
  global $rul_version;
24
  // Name of the database table that will hold group information and moderator rules
25
  $rul_db_addresses = $wpdb->prefix . 'login_redirects';
26
- $rul_version = '2.9.7';
27
 
28
  // doing this so we can pass current user logging out since it is no longer active after logout
29
  if ( ! function_exists('wp_logout')) :
@@ -338,6 +338,7 @@ class rulRedirectPostRegistration
338
  $rul_url = rulRedirectPostRegistration::get_redirect_url($requested_redirect_to);
339
  if ($rul_url) {
340
  rulRedirectFunctionCollection::rul_trigger_allowed_host($rul_url);
 
341
  return $rul_url;
342
  }
343
 
@@ -1311,9 +1312,91 @@ if (is_admin()) {
1311
  add_action('admin_menu', 'rul_addoptionsmenu', 1);
1312
  }
1313
 
1314
- register_activation_hook(__FILE__, 'rul_install');
1315
- register_uninstall_hook(__FILE__, 'rul_uninstall');
1316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1317
 
1318
  add_filter('login_redirect', 'peters_redirect_wrapper', 999999999, 3);
1319
  add_filter('registration_redirect', array('rulRedirectPostRegistration', 'post_registration_wrapper'), 10, 2);
5
  Description: Redirect users to different locations after logging in. Define a set of rules for specific users, user with specific roles, users with specific capabilities, and a blanket rule for all other users. This is all managed in Settings > Login/logout redirects.
6
  Author: Peter Keung
7
  Author URI: http://www.theblog.ca
8
+ Version: 2.9.8
9
  Text Domain: peters-login-redirect
10
  Domain Path: /languages/
11
  */
23
  global $rul_version;
24
  // Name of the database table that will hold group information and moderator rules
25
  $rul_db_addresses = $wpdb->prefix . 'login_redirects';
26
+ $rul_version = '2.9.8';
27
 
28
  // doing this so we can pass current user logging out since it is no longer active after logout
29
  if ( ! function_exists('wp_logout')) :
338
  $rul_url = rulRedirectPostRegistration::get_redirect_url($requested_redirect_to);
339
  if ($rul_url) {
340
  rulRedirectFunctionCollection::rul_trigger_allowed_host($rul_url);
341
+
342
  return $rul_url;
343
  }
344
 
1312
  add_action('admin_menu', 'rul_addoptionsmenu', 1);
1313
  }
1314
 
 
 
1315
 
1316
+ function rul_activate_plugin($networkwide)
1317
+ {
1318
+ // Executes when plugin is activated
1319
+ global $wpdb, $rul_db_addresses;
1320
+
1321
+ if (function_exists('is_multisite') && is_multisite() && $networkwide) {
1322
+ $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1323
+ foreach ($blogs as $blog) {
1324
+ switch_to_blog($blog);
1325
+ $rul_db_addresses = $wpdb->prefix . 'login_redirects';
1326
+ rul_install();
1327
+ }
1328
+ restore_current_blog();
1329
+ } else {
1330
+ rul_install();
1331
+ }
1332
+ }
1333
+
1334
+ function rul_deactivate_plugin($networkwide)
1335
+ {
1336
+ global $wpdb;
1337
+
1338
+ if (function_exists('is_multisite') && is_multisite() && $networkwide) {
1339
+ $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1340
+ foreach ($blogs as $blog) {
1341
+ switch_to_blog($blog);
1342
+ }
1343
+ restore_current_blog();
1344
+ }
1345
+ }
1346
+
1347
+ function rul_uninstall_plugin()
1348
+ {
1349
+ // Executes when plugin is deleted
1350
+ global $wpdb, $rul_db_addresses;
1351
+ if (function_exists('is_multisite') && is_multisite()) {
1352
+ $blogs = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
1353
+ foreach ($blogs as $blog) {
1354
+ switch_to_blog($blog);
1355
+ $rul_db_addresses = $wpdb->prefix . 'login_redirects';
1356
+ rul_uninstall();
1357
+ }
1358
+ restore_current_blog();
1359
+ } else {
1360
+ rul_uninstall();
1361
+ }
1362
+ }
1363
+
1364
+ function rul_site_added($blog)
1365
+ {
1366
+ // Executes when a site’s initialization routine should be executed.
1367
+ global $wpdb, $rul_db_addresses;
1368
+
1369
+ if ( ! is_int($blog)) {
1370
+ $blog = $blog->id;
1371
+ }
1372
+
1373
+ switch_to_blog($blog);
1374
+ $rul_db_addresses = $wpdb->prefix . 'login_redirects';
1375
+ rul_install();
1376
+ restore_current_blog();
1377
+ }
1378
+
1379
+ function rul_drop_tables($tables)
1380
+ {
1381
+ global $wpdb;
1382
+ $tables[] = $wpdb->prefix . 'login_redirects';
1383
+
1384
+ return $tables;
1385
+ }
1386
+
1387
+ register_activation_hook(__FILE__, 'rul_activate_plugin');
1388
+ register_deactivation_hook(__FILE__, 'rul_deactivate_plugin');
1389
+ register_uninstall_hook(__FILE__, 'rul_uninstall_plugin');
1390
+ add_filter('wpmu_drop_tables', 'rul_drop_tables');
1391
+ add_action('activate_blog', 'rul_site_added');
1392
+
1393
+ // Wpmu_new_blog has been deprecated in 5.1 and replaced by wp_insert_site.
1394
+ global $wp_version;
1395
+ if (version_compare($wp_version, '5.1', '<')) {
1396
+ add_action('wpmu_new_blog', 'rul_site_added');
1397
+ } else {
1398
+ add_action('wp_initialize_site', 'rul_site_added', 99);
1399
+ }
1400
 
1401
  add_filter('login_redirect', 'peters_redirect_wrapper', 999999999, 3);
1402
  add_filter('registration_redirect', array('rulRedirectPostRegistration', 'post_registration_wrapper'), 10, 2);