PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.9
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.9
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / multisite / class-hustle-multisite.php
wordpress-popup / inc / multisite Last commit date
class-hustle-multisite.php 3 years ago
class-hustle-multisite.php
61 lines
1 <?php
2 /**
3 * File for the Hustle_Multisite class.
4 *
5 * @package Hustle
6 * @since 4.4.7
7 */
8
9 if ( ! class_exists( 'Hustle_Multisite' ) ) :
10 /**
11 * Class Hustle_Multisite.
12 */
13 class Hustle_Multisite {
14
15 /**
16 * Hustle_Multisite site class constructor.
17 */
18 public function __construct() {
19
20 // add action to clone modules to new site.
21 add_action( 'wp_insert_site', array( $this, 'clone_modules_to_new_site' ), 10, 1 );
22
23 }
24 /**
25 * Clone modules to the new site by ids.
26 *
27 * @param WP_Site $new_site - New site object.
28 * @return void
29 */
30 public function clone_modules_to_new_site( $new_site ) {
31 if ( class_exists( 'Hustle_Model' ) && ! empty( $new_site->id ) ) {
32 $module_ids = apply_filters( 'hustle_clone_modules_to_new_site', array() );
33 if ( empty( $module_ids ) ) {
34 return;
35 }
36 foreach ( $module_ids as $module_id ) {
37 $module = Hustle_Model::get_module( $module_id );
38 try {
39 // if module id is invalid go to next module id.
40 if ( ! $module->id ) {
41 continue;
42 }
43 $data = $module->clone_module(); // clone module data.
44 switch_to_blog( $new_site->id );
45 Hustle_Db::maybe_create_tables(); // Create Hustle custom tables.
46 $result = $module->save(); // Save the module.
47 if ( $result && ! is_wp_error( $result ) ) {
48
49 $module->update_module( $data );
50 }
51 restore_current_blog();
52 } catch ( Exception $e ) {
53 error_log( 'There is something wrong with cloning modules to the new site' );// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
54 }
55 }
56 }
57 }
58
59 }
60 endif;
61