forked from LiveCarta/LiveCartaWP
Changed source root directory
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* WPSEO plugin file.
|
||||
*
|
||||
* @package WPSEO\Admin\Formatter
|
||||
*/
|
||||
|
||||
use Yoast\WP\SEO\Config\Schema_Types;
|
||||
use Yoast\WP\SEO\Editors\Application\Analysis_Features\Enabled_Analysis_Features_Repository;
|
||||
use Yoast\WP\SEO\Editors\Application\Integrations\Integration_Information_Repository;
|
||||
|
||||
/**
|
||||
* This class forces needed methods for the metabox localization.
|
||||
*/
|
||||
class WPSEO_Metabox_Formatter {
|
||||
|
||||
/**
|
||||
* Object that provides formatted values.
|
||||
*
|
||||
* @var WPSEO_Metabox_Formatter_Interface
|
||||
*/
|
||||
private $formatter;
|
||||
|
||||
/**
|
||||
* Setting the formatter property.
|
||||
*
|
||||
* @param WPSEO_Metabox_Formatter_Interface $formatter Object that provides the formatted values.
|
||||
*/
|
||||
public function __construct( WPSEO_Metabox_Formatter_Interface $formatter ) {
|
||||
$this->formatter = $formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the values.
|
||||
*
|
||||
* @return array<string, string|array<string|int|bool>|bool|int>
|
||||
*/
|
||||
public function get_values() {
|
||||
$defaults = $this->get_defaults();
|
||||
$values = $this->formatter->get_values();
|
||||
|
||||
return ( $values + $defaults );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns array with all the values always needed by a scraper object.
|
||||
*
|
||||
* @return array<string, string|array<string|int|bool>|bool|int> Default settings for the metabox.
|
||||
*/
|
||||
private function get_defaults() {
|
||||
$schema_types = new Schema_Types();
|
||||
|
||||
$defaults = [
|
||||
'author_name' => get_the_author_meta( 'display_name' ),
|
||||
'keyword_usage' => [],
|
||||
'title_template' => '',
|
||||
'metadesc_template' => '',
|
||||
'schema' => [
|
||||
'displayFooter' => WPSEO_Capability_Utils::current_user_can( 'wpseo_manage_options' ),
|
||||
'pageTypeOptions' => $schema_types->get_page_type_options(),
|
||||
'articleTypeOptions' => $schema_types->get_article_type_options(),
|
||||
],
|
||||
'twitterCardType' => 'summary_large_image',
|
||||
/**
|
||||
* Filter to determine if the markers should be enabled or not.
|
||||
*
|
||||
* @param bool $showMarkers Should the markers being enabled. Default = true.
|
||||
*/
|
||||
'show_markers' => apply_filters( 'wpseo_enable_assessment_markers', true ),
|
||||
];
|
||||
|
||||
$integration_information_repo = YoastSEO()->classes->get( Integration_Information_Repository::class );
|
||||
|
||||
$enabled_integrations = $integration_information_repo->get_integration_information();
|
||||
$defaults = array_merge( $defaults, $enabled_integrations );
|
||||
$enabled_features_repo = YoastSEO()->classes->get( Enabled_Analysis_Features_Repository::class );
|
||||
|
||||
$enabled_features = $enabled_features_repo->get_enabled_features()->parse_to_legacy_array();
|
||||
return array_merge( $defaults, $enabled_features );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* WPSEO plugin file.
|
||||
*
|
||||
* @package WPSEO\Admin\Formatter
|
||||
*/
|
||||
|
||||
use Yoast\WP\SEO\Editors\Application\Seo\Post_Seo_Information_Repository;
|
||||
|
||||
/**
|
||||
* This class provides data for the post metabox by return its values for localization.
|
||||
*/
|
||||
class WPSEO_Post_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
|
||||
|
||||
/**
|
||||
* Holds the WordPress Post.
|
||||
*
|
||||
* @var WP_Post
|
||||
*/
|
||||
private $post;
|
||||
|
||||
/**
|
||||
* The permalink to follow.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $permalink;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param WP_Post|array $post Post object.
|
||||
* @param array $options Title options to use.
|
||||
* @param string $structure The permalink to follow.
|
||||
*/
|
||||
public function __construct( $post, array $options, $structure ) {
|
||||
$this->post = $post;
|
||||
$this->permalink = $structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the social templates should be used.
|
||||
*
|
||||
* @deprecated 23.1
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function use_social_templates() {
|
||||
_deprecated_function( __METHOD__, 'Yoast SEO 23.1' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translated values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_values() {
|
||||
|
||||
$values = [
|
||||
'metaDescriptionDate' => '',
|
||||
];
|
||||
|
||||
if ( $this->post instanceof WP_Post ) {
|
||||
|
||||
/** @var Post_Seo_Information_Repository $repo */
|
||||
$repo = YoastSEO()->classes->get( Post_Seo_Information_Repository::class );
|
||||
$repo->set_post( $this->post );
|
||||
|
||||
$values_to_set = [
|
||||
'isInsightsEnabled' => $this->is_insights_enabled(),
|
||||
];
|
||||
|
||||
$values = ( $values_to_set + $values );
|
||||
$values = ( $repo->get_seo_data() + $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter: 'wpseo_post_edit_values' - Allows changing the values Yoast SEO uses inside the post editor.
|
||||
*
|
||||
* @param array $values The key-value map Yoast SEO uses inside the post editor.
|
||||
* @param WP_Post $post The post opened in the editor.
|
||||
*/
|
||||
return apply_filters( 'wpseo_post_edit_values', $values, $this->post );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the insights feature is enabled for this post.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_insights_enabled() {
|
||||
return WPSEO_Options::get( 'enable_metabox_insights', false );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* WPSEO plugin file.
|
||||
*
|
||||
* @package WPSEO\Admin\Formatter
|
||||
*/
|
||||
|
||||
use Yoast\WP\SEO\Editors\Application\Seo\Term_Seo_Information_Repository;
|
||||
|
||||
/**
|
||||
* This class provides data for the term metabox by return its values for localization.
|
||||
*/
|
||||
class WPSEO_Term_Metabox_Formatter implements WPSEO_Metabox_Formatter_Interface {
|
||||
|
||||
/**
|
||||
* The term the metabox formatter is for.
|
||||
*
|
||||
* @var WP_Term|stdClass
|
||||
*/
|
||||
private $term;
|
||||
|
||||
/**
|
||||
* The term's taxonomy.
|
||||
*
|
||||
* @var stdClass
|
||||
*/
|
||||
private $taxonomy;
|
||||
|
||||
/**
|
||||
* Whether we must return social templates values.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $use_social_templates = false;
|
||||
|
||||
/**
|
||||
* Array with the WPSEO_Titles options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* WPSEO_Taxonomy_Scraper constructor.
|
||||
*
|
||||
* @param stdClass $taxonomy Taxonomy.
|
||||
* @param WP_Term|stdClass $term Term.
|
||||
*/
|
||||
public function __construct( $taxonomy, $term ) {
|
||||
$this->taxonomy = $taxonomy;
|
||||
$this->term = $term;
|
||||
|
||||
$this->use_social_templates = $this->use_social_templates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the social templates should be used.
|
||||
*
|
||||
* @return bool Whether the social templates should be used.
|
||||
*/
|
||||
public function use_social_templates() {
|
||||
return WPSEO_Options::get( 'opengraph', false ) === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the translated values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_values() {
|
||||
$values = [];
|
||||
|
||||
// Todo: a column needs to be added on the termpages to add a filter for the keyword, so this can be used in the focus keyphrase doubles.
|
||||
if ( is_object( $this->term ) && property_exists( $this->term, 'taxonomy' ) ) {
|
||||
$values = [
|
||||
'taxonomy' => $this->term->taxonomy,
|
||||
'semrushIntegrationActive' => 0,
|
||||
'wincherIntegrationActive' => 0,
|
||||
'isInsightsEnabled' => $this->is_insights_enabled(),
|
||||
];
|
||||
|
||||
$repo = YoastSEO()->classes->get( Term_Seo_Information_Repository::class );
|
||||
$repo->set_term( $this->term );
|
||||
$values = ( $repo->get_seo_data() + $values );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the insights feature is enabled for this taxonomy.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_insights_enabled() {
|
||||
return WPSEO_Options::get( 'enable_metabox_insights', false );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* WPSEO plugin file.
|
||||
*
|
||||
* @package WPSEO\Admin\Formatter
|
||||
*/
|
||||
|
||||
/**
|
||||
* Interface to force get_values.
|
||||
*/
|
||||
interface WPSEO_Metabox_Formatter_Interface {
|
||||
|
||||
/**
|
||||
* Returns formatter values.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_values();
|
||||
}
|
||||
Reference in New Issue
Block a user