khaihihi
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
@@ -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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user