PluginProbe
Post Duplicator / trunk
Post Duplicator vtrunk
3.0.16 trunk 1.1 2.0 2.2 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.3 2.30 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 All 52 releases
post-duplicator / includes / install.php

install.php in Post Duplicator trunk, at includes/install.php

79 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 namespace Mtphr\PostDuplicator\Install;
4
5 /**
6 * Install Function
7 *
8 * @since 1.0.0
9 * @package PostDuplicator
10 * @subpackage PostDuplicator/includes
11 * @author Metaphor Creations <joe@metaphorcreations.com>
12 */
13
14 // Exit if accessed directly
15 if ( ! defined( 'ABSPATH' ) ) exit;
16
17 /**
18 * Install
19 */
20
21 function install( $network_wide = false ) {
22 global $wpdb;
23
24 if( is_multisite() && $network_wide ) {
25
26 foreach( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) {
27
28 switch_to_blog( $blog_id );
29 run_install();
30 restore_current_blog();
31 }
32
33 } else {
34
35 run_install();
36 }
37 }
38 register_activation_hook( MTPHR_POST_DUPLICATOR_FILE, __NAMESPACE__ . '\install' );
39
40
41 /**
42 * Run the Install process
43 *
44 * @since 1.0
45 * @return void
46 */
47 function run_install() {
48
49 // Add Upgraded From Option
50 // $current_version = get_option( 'mtphr_postduplicator_version' );
51 // if ( $current_version ) {
52 // update_option( 'mtphr_postduplicator_version_upgraded_from', $current_version );
53 // }
54
55 // update_option( 'mtphr_postduplicator_version', MTPHR_POST_DUPLICATOR_VERSION );
56 }
57
58
59 /**
60 * When a new Blog is created in multisite, see if the plugin is network activated, and run the installer
61 *
62 * @since 1.0
63 * @param int $blog_id The Blog ID created
64 * @param int $user_id The User ID set as the admin
65 * @param string $domain The URL
66 * @param string $path Site Path
67 * @param int $site_id The Site ID
68 * @param array $meta Blog Meta
69 * @return void
70 */
71 function new_blog_created( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
72 if ( is_plugin_active_for_network( plugin_basename( MTPHR_POST_DUPLICATOR_FILE ) ) ) {
73 switch_to_blog( $blog_id );
74 run_install();
75 restore_current_blog();
76 }
77 }
78 add_action( 'wpmu_new_blog', __NAMESPACE__ . '\new_blog_created', 10, 6 );
79