Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 3 |
CRAP | n/a |
0 / 0 |
|
| sensei_onboarding_mods | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
42 | |||
| sensei_hide_anyone_register_warning | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
12 | |||
| sensei_wpcomsh_allow_custom_wp_options | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * File for all Atomic Sensei-onboarding specific changes. |
| 4 | * |
| 5 | * @package wpcomsh |
| 6 | */ |
| 7 | |
| 8 | /** |
| 9 | * Run all sensei mods. |
| 10 | * |
| 11 | * @return void |
| 12 | */ |
| 13 | function sensei_onboarding_mods() { |
| 14 | if ( 'sensei' === get_option( 'site_intent' ) && ! get_option( 'sensei_flow_setup' ) ) { |
| 15 | |
| 16 | update_option( 'sensei_flow_setup', 1 ); |
| 17 | |
| 18 | // Deactivate Crowdsignal Plugins |
| 19 | if ( is_plugin_active( 'polldaddy/polldaddy.php' ) ) { |
| 20 | deactivate_plugins( 'polldaddy/polldaddy.php' ); |
| 21 | } |
| 22 | if ( is_plugin_active( 'crowdsignal-forms/crowdsignal-forms.php' ) ) { |
| 23 | deactivate_plugins( 'crowdsignal-forms/crowdsignal-forms.php' ); |
| 24 | } |
| 25 | |
| 26 | // Create Default Sensei Pages. |
| 27 | if ( is_plugin_active( 'sensei-lms/sensei-lms.php' ) ) { |
| 28 | \Sensei_Setup_Wizard::instance()->pages->create_pages(); |
| 29 | } |
| 30 | |
| 31 | // Allow site user registration |
| 32 | update_option( 'users_can_register', 1 ); |
| 33 | |
| 34 | // Set usage tracking to true |
| 35 | $sensei_settings = get_option( 'sensei-settings' ); |
| 36 | $sensei_settings['sensei_usage_tracking_enabled'] = true; |
| 37 | update_option( 'sensei-settings', $sensei_settings ); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | add_action( 'admin_init', 'sensei_onboarding_mods' ); |
| 42 | |
| 43 | /** |
| 44 | * Hide "Anyone can register" warning. |
| 45 | * |
| 46 | * Since the `sensei_onboarding_mods` updates the `users_can_register` to `1`, |
| 47 | * it starts displaying a notice. This function hides it. |
| 48 | */ |
| 49 | function sensei_hide_anyone_register_warning() { |
| 50 | if ( is_plugin_active( 'sensei-lms/sensei-lms.php' ) && 'subscriber' === get_option( 'default_role' ) ) { |
| 51 | remove_action( 'admin_notices', 'wpcomsh_anyone_register_warning' ); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | add_action( 'admin_init', 'sensei_hide_anyone_register_warning' ); |
| 56 | |
| 57 | /** |
| 58 | * Allow Sensei Home task complete option to be synced so we can use this status for the My Home Checklist |
| 59 | * |
| 60 | * @param array $options Jetpack sync allowed options. |
| 61 | * @return array |
| 62 | */ |
| 63 | function sensei_wpcomsh_allow_custom_wp_options( $options ) { |
| 64 | $options[] = 'sensei_home_tasks_list_is_completed'; |
| 65 | return $options; |
| 66 | } |
| 67 | add_filter( 'jetpack_sync_options_whitelist', 'sensei_wpcomsh_allow_custom_wp_options' ); |