| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * A generic activation / de-activation class compatble with multisite |
| 8 | 5 | * |
| @@ -24,10 +21,10 @@ | ||
| 24 | 21 | // Manages plugin activation and deactivation |
| 25 | 22 | register_activation_hook( $plugin_basename, array( $this, 'activate' ) ); |
| 26 | 23 | register_deactivation_hook( $plugin_basename, array( $this, 'deactivate' ) ); |
| 27 | 24 | |
| 28 | - // Site creation on multisite. | |
| 29 | - add_action( 'wp_insert_site', array( $this, 'new_site' ) ); | |
| 25 | + // Blog creation on multisite | |
| 26 | + add_action( 'wpmu_new_blog', array( $this, 'wpmu_new_blog' ), 5 ); // Before WP attempts to send mails which can break on some PHP versions | |
| 30 | 27 | } |
| 31 | 28 | |
| 32 | 29 | /** |
| 33 | 30 | * Allows to detect plugin deactivation |
| @@ -36,9 +33,9 @@ | ||
| 36 | 33 | * |
| 37 | 34 | * @return bool true if the plugin is currently beeing deactivated |
| 38 | 35 | */ |
| 39 | 36 | public function is_deactivation() { |
| 40 | - return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' === $_GET['action'] && $this->plugin_basename === $_GET['plugin']; // phpcs:ignore WordPress.Security.NonceVerification | |
| 37 | + return isset( $_GET['action'], $_GET['plugin'] ) && 'deactivate' == $_GET['action'] && $this->plugin_basename == $_GET['plugin']; | |
| 41 | 38 | } |
| 42 | 39 | |
| 43 | 40 | /** |
| 44 | 41 | * Activation or deactivation for all blogs |
| @@ -106,16 +103,16 @@ | ||
| 106 | 103 | // Can be overriden in child class |
| 107 | 104 | } |
| 108 | 105 | |
| 109 | 106 | /** |
| 110 | - * Site creation on multisite ( to set default options ) | |
| 107 | + * Blog creation on multisite ( to set default options ) | |
| 111 | 108 | * |
| 112 | - * @since 2.6.8 | |
| 109 | + * @since 0.9.4 | |
| 113 | 110 | * |
| 114 | - * @param WP_Site $new_site New site object. | |
| 111 | + * @param int $blog_id | |
| 115 | 112 | */ |
| 116 | - public function new_site( $new_site ) { | |
| 117 | - switch_to_blog( $new_site->id ); | |
| 113 | + public function wpmu_new_blog( $blog_id ) { | |
| 114 | + switch_to_blog( $blog_id ); | |
| 118 | 115 | $this->_activate(); |
| 119 | 116 | restore_current_blog(); |
| 120 | 117 | } |
| 121 | 118 | } |