Merged in feature/from-pantheon (pull request #16)

code from pantheon

* code from pantheon
This commit is contained in:
Tony Volpe
2024-01-10 17:03:02 +00:00
parent 054b4fffc9
commit 4eb982d7a8
16492 changed files with 3475854 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use Yoast\WP\SEO\Conditionals\Admin\Post_Conditional;
use Yoast\WP\SEO\Conditionals\Conditional;
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
/**
* Conditional that is met when the AI editor integration should be active.
*/
class Ai_Editor_Conditional implements Conditional {
/**
* Holds the Post_Conditional.
*
* @var Post_Conditional
*/
private $post_conditional;
/**
* Holds the Current_Page_Helper.
*
* @var Current_Page_Helper
*/
private $current_page_helper;
/**
* Constructs Ai_Editor_Conditional.
*
* @param Post_Conditional $post_conditional The Post_Conditional.
* @param Current_Page_Helper $current_page_helper The Current_Page_Helper.
*/
public function __construct( Post_Conditional $post_conditional, Current_Page_Helper $current_page_helper ) {
$this->post_conditional = $post_conditional;
$this->current_page_helper = $current_page_helper;
}
/**
* Returns `true` when the AI editor integration should be active.
*
* @return bool `true` when the AI editor integration should be active.
*/
public function is_met() {
return $this->post_conditional->is_met() || $this->is_elementor_editor();
}
/**
* Returns `true` when the page is the elementor editor.
*
* @return bool `true` when the page is the elementor editor.
*/
private function is_elementor_editor() {
if ( $this->current_page_helper->get_current_admin_page() !== 'post.php' ) {
return false;
}
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['action'] ) && \is_string( $_GET['action'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
if ( \wp_unslash( $_GET['action'] ) === 'elementor' ) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use Yoast\WP\SEO\Conditionals\Conditional;
use Yoast\WP\SEO\Helpers\Options_Helper;
/**
* Conditional that is only met when the Algolia integration is enabled.
*/
class Algolia_Enabled_Conditional implements Conditional {
/**
* The options helper.
*
* @var Options_Helper
*/
private $options_helper;
/**
* Algolia_Enabled_Conditional constructor.
*
* @param Options_Helper $options_helper The options helper.
*/
public function __construct( Options_Helper $options_helper ) {
$this->options_helper = $options_helper;
}
/**
* Returns whether or not this conditional is met.
*
* @return bool Whether or not the conditional is met.
*/
public function is_met() {
return $this->options_helper->get( 'algolia_integration_active' ) === true;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use Yoast\WP\SEO\Conditionals\Conditional;
use Yoast\WP\SEO\Helpers\Options_Helper;
/**
* Cornerstone_Enabled_Conditional class.
*/
class Cornerstone_Enabled_Conditional implements Conditional {
/**
* The options helper.
*
* @var Options_Helper
*/
protected $options_helper;
/**
* Cornerstone_Enabled_Conditional constructor.
*
* @codeCoverageIgnore
*
* @param Options_Helper $options_helper The options helper.
*/
public function __construct( Options_Helper $options_helper ) {
$this->options_helper = $options_helper;
}
/**
* Returns `true` when the cornerstone content feature is enabled.
*
* @return bool `true` when the cornerstone content feature is enabled.
*/
public function is_met() {
return $this->options_helper->get( 'enable_cornerstone_content' );
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use Yoast\WP\SEO\Conditionals\Conditional;
/**
* Conditional that is only met when Easy Digital Downloads is active.
*/
class EDD_Conditional implements Conditional {
/**
* Returns `true` when the Easy Digital Downloads plugin is installed and activated.
*
* @return bool `true` when the Easy Digital Downloads plugin is installed and activated.
*/
public function is_met() {
return \class_exists( 'Easy_Digital_Downloads' );
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use WPSEO_Metabox_Analysis_Inclusive_Language;
use Yoast\WP\SEO\Conditionals\Conditional;
/**
* Inclusive_Language_Enabled_Conditional class.
*
* phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
*/
class Inclusive_Language_Enabled_Conditional implements Conditional {
/**
* Returns `true` when the inclusive language analysis is enabled.
*
* @return bool `true` when the inclusive language analysis is enabled.
*/
public function is_met() {
$analysis_inclusive_language = new WPSEO_Metabox_Analysis_Inclusive_Language();
return $analysis_inclusive_language->is_enabled();
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use WPSEO_Options;
use Yoast\WP\SEO\Conditionals\Feature_Flag_Conditional;
/**
* Checks if the YOAST_SEO_SOCIAL_TEMPLATES constant is set.
*/
class Social_Templates_Conditional extends Feature_Flag_Conditional {
/**
* Returns whether or not this conditional is met.
*
* @return bool Whether or not the conditional is met.
*/
public function is_met() {
return parent::is_met() && WPSEO_Options::get( 'opengraph', true ) === 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.
*/
protected function get_feature_flag() {
return 'SOCIAL_TEMPLATES';
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Yoast\WP\SEO\Premium\Conditionals;
use Yoast\WP\SEO\Conditionals\Conditional;
/**
* Conditional that is only met when on a term overview page or during an ajax request.
*
* phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded
*/
class Term_Overview_Or_Ajax_Conditional implements Conditional {
/**
* Returns whether or not this conditional is met.
*
* @return bool Whether or not the conditional is met.
*/
public function is_met() {
global $pagenow;
return $pagenow === 'edit-tags.php' || \wp_doing_ajax();
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace Yoast\WP\SEO\Conditionals;
use Yoast\WP\SEO\Helpers\Zapier_Helper;
/**
* Conditional that is only met when the Zapier integration is enabled.
*/
class Zapier_Enabled_Conditional implements Conditional {
/**
* The Zapier helper.
*
* @var Zapier_Helper
*/
private $zapier;
/**
* Zapier_Enabled_Conditional constructor.
*
* @param Zapier_Helper $zapier The Zapier helper.
*/
public function __construct( Zapier_Helper $zapier ) {
$this->zapier = $zapier;
}
/**
* Returns whether or not this conditional is met.
*
* @return bool Whether or not the conditional is met.
*/
public function is_met() {
return $this->zapier->is_enabled();
}
}