| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Polylang |
| 4 |
* |
| 5 |
* /!\ THE CONSTANTS `POLYLANG_BASENAME` AND `POLYLANG_VERSION` MUST BE DEFINED. |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* A generic activation class compatible with multisite. |
| 10 |
* |
| 11 |
* @since 3.8 |
| 12 |
*/ |
| 13 |
abstract class PLL_Abstract_Activate extends PLL_Abstract_Activable { |
| 14 |
/** |
| 15 |
* Adds the required hooks. |
| 16 |
* |
| 17 |
* @since 3.8 |
| 18 |
* |
| 19 |
* @return void |
| 20 |
*/ |
| 21 |
public static function add_hooks(): void { |
| 22 |
// Plugin activation. |
| 23 |
register_activation_hook( static::get_plugin_basename(), array( static::class, 'do_for_all_blogs' ) ); |
| 24 |
|
| 25 |
// Site creation on multisite. |
| 26 |
add_action( 'wp_initialize_site', array( static::class, 'new_site' ), 50 ); // After WP (prio 10). |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Site creation on multisite (to set default options). |
| 31 |
* |
| 32 |
* @since 2.6.8 |
| 33 |
* @since 3.8 Moved from the class `PLL_Install_Base`. |
| 34 |
* |
| 35 |
* @param WP_Site $new_site New site object. |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
public static function new_site( $new_site ): void { |
| 39 |
switch_to_blog( $new_site->id ); |
| 40 |
static::process(); |
| 41 |
restore_current_blog(); |
| 42 |
} |
| 43 |
} |
| 44 |
|