| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Internals |
| 6 |
* @since 3.6 |
| 7 |
*/ |
| 8 |
|
| 9 |
/** |
| 10 |
* This class checks if the wpseo option doesn't exists. In the case it doesn't it will set a property that is |
| 11 |
* accessible via a method to check if the installation is fresh. |
| 12 |
*/ |
| 13 |
class WPSEO_Installation { |
| 14 |
|
| 15 |
/** |
| 16 |
* Checks if Yoast SEO is installed for the first time. |
| 17 |
*/ |
| 18 |
public function __construct() { |
| 19 |
$is_first_install = $this->is_first_install(); |
| 20 |
|
| 21 |
if ( $is_first_install && WPSEO_Utils::is_api_available() ) { |
| 22 |
add_action( 'wpseo_activate', [ $this, 'set_first_install_options' ] ); |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* When the option doesn't exist, it should be a new install. |
| 28 |
* |
| 29 |
* @return bool |
| 30 |
*/ |
| 31 |
private function is_first_install() { |
| 32 |
return ( get_option( 'wpseo' ) === false ); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Sets the options on first install for showing the installation notice and disabling of the settings pages. |
| 37 |
* |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function set_first_install_options() { |
| 41 |
$options = get_option( 'wpseo' ); |
| 42 |
|
| 43 |
$options['show_onboarding_notice'] = true; |
| 44 |
$options['first_activated_on'] = time(); |
| 45 |
$options['first_activated_by'] = get_current_user_id(); |
| 46 |
|
| 47 |
update_option( 'wpseo', $options ); |
| 48 |
} |
| 49 |
} |
| 50 |
|