@@ -132,9 +132,14 @@ public function __construct() {
132
132
133
133
if ( is_admin () ) {
134
134
/* Backend */
135
- add_action ( 'wpmu_new_blog ' , array ( __CLASS__ , 'install_later ' ) );
136
-
137
- add_action ( 'delete_blog ' , array ( __CLASS__ , 'uninstall_later ' ) );
135
+ if ( version_compare ( get_bloginfo ( 'version ' ), '5.1 ' , '< ' ) ) {
136
+ // The following hooks are deprecated since WP 5.1 (#246).
137
+ add_action ( 'wpmu_new_blog ' , array ( __CLASS__ , 'install_later ' ) );
138
+ add_action ( 'delete_blog ' , array ( __CLASS__ , 'uninstall_later ' ) );
139
+ } else {
140
+ add_action ( 'wp_initialize_site ' , array ( __CLASS__ , 'install_later ' ) );
141
+ add_action ( 'wp_delete_site ' , array ( __CLASS__ , 'uninstall_later ' ) );
142
+ }
138
143
139
144
add_action ( 'admin_init ' , array ( __CLASS__ , 'register_textdomain ' ) );
140
145
@@ -210,21 +215,21 @@ public static function on_activation() {
210
215
}
211
216
212
217
/**
213
- * Plugin installation on new MU blog .
218
+ * Plugin installation on new WPMS site .
214
219
*
215
- * @since 1.0
216
- * @change 1.0
220
+ * @since 1.0
221
+ * @since 2.4 supports WP_Site argument
217
222
*
218
- * @param integer $id Blog ID.
223
+ * @param int|WP_Site $new_site New site ID or object .
219
224
*/
220
- public static function install_later ( $ id ) {
225
+ public static function install_later ( $ new_site ) {
221
226
/* No network plugin */
222
227
if ( ! is_plugin_active_for_network ( CACHIFY_BASE ) ) {
223
228
return ;
224
229
}
225
230
226
231
/* Switch to blog */
227
- switch_to_blog ( $ id );
232
+ switch_to_blog ( is_int ( $ new_site ) ? $ new_site : $ new_site -> blog_id );
228
233
229
234
/* Install */
230
235
self ::_install_backend ();
@@ -281,21 +286,21 @@ public static function on_uninstall() {
281
286
}
282
287
283
288
/**
284
- * Uninstalling of the plugin for MU and network .
289
+ * Uninstalling of the plugin for WPMS site .
285
290
*
286
- * @since 1.0
287
- * @change 1.0
291
+ * @since 1.0
292
+ * @since 2.4 supports WP_Site argument
288
293
*
289
- * @param integer $id Blog ID.
294
+ * @param int|WP_Site $old_site Old site ID or object .
290
295
*/
291
- public static function uninstall_later ( $ id ) {
296
+ public static function uninstall_later ( $ old_site ) {
292
297
/* No network plugin */
293
298
if ( ! is_plugin_active_for_network ( CACHIFY_BASE ) ) {
294
299
return ;
295
300
}
296
301
297
302
/* Switch to blog */
298
- switch_to_blog ( $ id );
303
+ switch_to_blog ( is_int ( $ old_site ) ? $ old_site : $ old_site -> blog_id );
299
304
300
305
/* Install */
301
306
self ::_uninstall_backend ();
0 commit comments