| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Metabox |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Represents the inclusive language analysis. |
| 10 |
*/ |
| 11 |
class WPSEO_Metabox_Analysis_Inclusive_Language implements WPSEO_Metabox_Analysis { |
| 12 |
|
| 13 |
/** |
| 14 |
* Whether this analysis is enabled. |
| 15 |
* |
| 16 |
* @return bool Whether or not this analysis is enabled. |
| 17 |
*/ |
| 18 |
public function is_enabled() { |
| 19 |
return $this->is_globally_enabled() && $this->is_user_enabled() && $this->is_current_version_supported() |
| 20 |
&& YoastSEO()->helpers->language->has_inclusive_language_support( WPSEO_Language_Utils::get_language( get_locale() ) ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Whether or not this analysis is enabled by the user. |
| 25 |
* |
| 26 |
* @return bool Whether or not this analysis is enabled by the user. |
| 27 |
*/ |
| 28 |
public function is_user_enabled() { |
| 29 |
return ! get_the_author_meta( 'wpseo_inclusive_language_analysis_disable', get_current_user_id() ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Whether or not this analysis is enabled globally. |
| 34 |
* |
| 35 |
* @return bool Whether or not this analysis is enabled globally. |
| 36 |
*/ |
| 37 |
public function is_globally_enabled() { |
| 38 |
return WPSEO_Options::get( 'inclusive_language_analysis_active', false ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Whether the inclusive language analysis should be loaded in Free. |
| 43 |
* |
| 44 |
* It should always be loaded when Premium is not active. If Premium is active, it depends on the version. Some Premium |
| 45 |
* versions also have inclusive language code (when it was still a Premium only feature) which would result in rendering |
| 46 |
* the analysis twice. In those cases, the analysis should be only loaded from the Premium side. |
| 47 |
* |
| 48 |
* @return bool Whether or not the inclusive language analysis should be loaded. |
| 49 |
*/ |
| 50 |
private function is_current_version_supported() { |
| 51 |
$is_premium = YoastSEO()->helpers->product->is_premium(); |
| 52 |
$premium_version = YoastSEO()->helpers->product->get_premium_version(); |
| 53 |
|
| 54 |
return ! $is_premium |
| 55 |
|| version_compare( $premium_version, '19.6-RC0', '>=' ) |
| 56 |
|| version_compare( $premium_version, '19.2', '==' ); |
| 57 |
} |
| 58 |
} |
| 59 |
|