PluginProbe
Patchstack – WordPress & Plugins Security / 2.3.7
Patchstack – WordPress & Plugins Security v2.3.7
2.3.7 trunk 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.16 2.1.17 2.1.18 2.1.19 2.1.2 2.1.20 2.1.21 2.1.22 2.1.23 2.1.24 2.1.25 2.1.3 2.1.4 2.1.5 2.1.6 All 49 releases
patchstack / includes / multisite.php

multisite.php in Patchstack – WordPress & Plugins Security 2.3.7, at includes/multisite.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Do not allow the file to be called directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * This class is used to handle anything multisite related.
10 */
11 class P_Multisite extends P_Core {
12 /**
13 * Add the actions required for the multisite functionality.
14 *
15 * @param Patchstack $core
16 * @return void
17 */
18 public function __construct( $core ) {
19 parent::__construct( $core );
20 if ( ! is_super_admin() ) {
21 return;
22 }
23
24 // When we need to re-run the migration of a specific site.
25 if ( isset( $_GET['site'], $_GET['PatchstackNonce'] ) && wp_verify_nonce( $_GET['PatchstackNonce'], 'patchstack-migration' ) ) {
26 $this->run_migration();
27 }
28 }
29
30 /**
31 * This will be called when the network admin clicks on the "Sites" button.
32 * It will show all sites.
33 *
34 * @return void
35 */
36 public function sites_section_callback() {
37 require_once dirname( __FILE__ ) . '/views/pages/multisite-table.php';
38 }
39
40 /**
41 * Re-run the migration for a specific multisite site.
42 *
43 * @return void
44 */
45 private function run_migration( ) {
46 // Must be a number.
47 if ( ! isset( $_GET['site'] ) || ! is_scalar( $_GET['site'] ) || ! ctype_digit( (string) $_GET['site'] ) ) {
48 exit;
49 }
50
51 // Site must be valid and exists.
52 $site = function_exists( 'get_site' ) ? get_site( $_GET['site'] ) : null;
53 if ( is_null( $site ) ) {
54 exit;
55 }
56
57 // Perform base migration.
58 $this->plugin->activation->migrate( null, $site->id );
59
60 // Perform specific version migrations.
61 $versions = array('3.0.1', '3.0.2');
62 foreach ( $versions as $version ) {
63 $this->plugin->activation->migrate( $version, $site->id );
64 }
65
66 wp_safe_redirect( add_query_arg( [ 'success' => '1', 'site' => $site->id ], remove_query_arg( [ 'PatchstackNonce', 'site' ] ) ) );
67 exit;
68 }
69 }
70