This commit is contained in:
KhaiNguyen
2020-02-13 10:39:37 +07:00
commit 59401cb805
12867 changed files with 4646216 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
<?php
/**
* Yoast SEO plugin file.
*
* @package Yoast\YoastSEO\Conditionals
*/
namespace Yoast\WP\SEO\Conditionals;
/**
* Conditional that is only met when in the admin.
*/
class Admin_Conditional implements Conditional {
/**
* Returns whether or not this conditional is met.
*
* @return boolean Whether or not the conditional is met.
*/
public function is_met() {
return \is_admin();
}
}

View File

@@ -0,0 +1,23 @@
<?php
/**
* Yoast SEO plugin file.
*
* @package Yoast\YoastSEO\Conditionals
*/
namespace Yoast\WP\SEO\Conditionals;
/**
* Conditional interface, used to prevent integrations from loading.
*
* @package Yoast\WP\SEO\Conditionals
*/
interface Conditional {
/**
* Returns whether or not this conditional is met.
*
* @return boolean Whether or not the conditional is met.
*/
public function is_met();
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Yoast SEO plugin file.
*
* @package Yoast\YoastSEO\Conditionals
*/
namespace Yoast\WP\SEO\Conditionals;
/**
* Abstract class for creating conditionals based on feature flags.
*/
abstract class Feature_Flag_Conditional implements Conditional {
/**
* Returns whether or not this conditional is met.
*
* @return boolean Whether or not the conditional is met.
*/
public function is_met() {
$feature_flag = \strtoupper( $this->get_feature_flag() );
return \defined( 'YOAST_SEO_' . $feature_flag ) && \constant( 'YOAST_SEO_' . $feature_flag ) === true;
}
/**
* Returns the name of the feature flag.
* 'YOAST_SEO_' is automatically prepended to it and it will be uppercased.
*
* @return string the name of the feature flag.
*/
abstract protected function get_feature_flag();
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* Yoast SEO plugin file.
*
* @package Yoast\YoastSEO\Conditionals
*/
namespace Yoast\WP\SEO\Conditionals;
/**
* Conditional for the indexables feature flag.
*/
class Indexables_Feature_Flag_Conditional extends Feature_Flag_Conditional {
/**
* @inheritdoc
*/
protected function get_feature_flag() {
return 'indexables';
}
}

View File

@@ -0,0 +1,23 @@
<?php
/**
* Yoast SEO plugin file.
*
* @package Yoast\YoastSEO\Conditionals
*/
namespace Yoast\WP\SEO\Conditionals;
/**
* Trait for integrations that do not have any conditionals.
*/
trait No_Conditionals {
/**
* Returns an empty array, meaning no conditionals are required to load whatever uses this trait.
*
* @return array The conditionals that must be met to load this.
*/
public static function get_conditionals() {
return [];
}
}