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,87 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Choice_Post_Type.
*/
class WPSEO_Config_Field_Choice_Post_Type extends WPSEO_Config_Field_Choice {
/**
* Post type.
*
* @var string
*/
protected $post_type;
/**
* WPSEO_Config_Field_Choice_Post_Type constructor.
*
* @param string $post_type The post type to add.
* @param string $label Label to show (translated post type).
*/
public function __construct( $post_type, $label ) {
parent::__construct( 'postType' . ucfirst( $post_type ) );
$this->post_type = $post_type;
/* Translators: %1$s expands to the name of the post type. The options given to the user are "visible" and "hidden" */
$this->set_property( 'label', sprintf( __( 'Search engines should show "%1$s" in search results:', 'wordpress-seo' ), $label ) );
$this->add_choice( 'true', __( 'Yes', 'wordpress-seo' ) );
$this->add_choice( 'false', __( 'No', 'wordpress-seo' ) );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_custom_lookup(
$this->get_identifier(),
[ $this, 'get_data' ],
[ $this, 'set_data' ]
);
}
/**
* Get the post type of this field.
*
* @return string Post type.
*/
public function get_post_type() {
return $this->post_type;
}
/**
* Retrieves the data.
*
* @return bool
*/
public function get_data() {
$key = 'noindex-' . $this->get_post_type();
if ( WPSEO_Options::get( $key, false ) === false ) {
return 'true';
}
return 'false';
}
/**
* Set new data.
*
* @param string $visible Visible (true) or hidden (false).
*
* @return bool
*/
public function set_data( $visible ) {
$post_type = $this->get_post_type();
return WPSEO_Options::set( 'noindex-' . $post_type, ( $visible === 'false' ) );
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Choice.
*/
class WPSEO_Config_Field_Choice extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Choice constructor.
*
* @param string $field Field name to use.
*/
public function __construct( $field ) {
parent::__construct( $field, 'Choice' );
$this->properties['choices'] = [];
}
/**
* Add a choice to the properties.
*
* @param string $value Value op the option.
* @param string $label Label to display for the value.
* @param string $aria_label Optional. Aria label text to use.
*/
public function add_choice( $value, $label, $aria_label = '' ) {
$choice = [
'label' => $label,
];
if ( $aria_label ) {
$choice['screenReaderText'] = $aria_label;
}
$this->properties['choices'][ $value ] = $choice;
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Configurator
*/
/**
* Class WPSEO_Config_Field_Company_Info_Missing.
*/
class WPSEO_Config_Field_Company_Info_Missing extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Company_Info_Missing constructor.
*
* @codeCoverageIgnore This is only using WPSEO_Config_Field and WPSEO_Utils functionality.
*/
public function __construct() {
parent::__construct( 'publishingEntityCompanyInfo', 'CompanyInfoMissing' );
$l10n_data = WPSEO_Language_Utils::get_knowledge_graph_company_info_missing_l10n();
$this->set_property( 'message', $l10n_data['message'] );
$this->set_property( 'link', $l10n_data['URL'] );
$this->set_requires( 'publishingEntityType', 'company' );
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Configurator
*/
/**
* Class WPSEO_Config_Field_Company_Logo.
*/
class WPSEO_Config_Field_Company_Logo extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Company_Logo constructor.
*/
public function __construct() {
parent::__construct( 'publishingEntityCompanyLogo', 'MediaUpload' );
$this->set_property( 'label', __( 'Provide an image of the organization logo', 'wordpress-seo' ) );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Sets the adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'company_logo' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Configurator
*/
/**
* Class WPSEO_Config_Field_Company_Name.
*/
class WPSEO_Config_Field_Company_Name extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Company_Name constructor.
*/
public function __construct() {
parent::__construct( 'publishingEntityCompanyName', 'Input' );
$this->set_property( 'label', __( 'The name of the organization', 'wordpress-seo' ) );
$this->set_property( 'autoComplete', 'organization' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Sets the adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'company_name' );
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Configurator
*/
/**
* Class WPSEO_Config_Field_Company_Or_Person.
*/
class WPSEO_Config_Field_Company_Or_Person extends WPSEO_Config_Field_Choice {
/**
* WPSEO_Config_Field_Company_Or_Person constructor.
*/
public function __construct() {
parent::__construct( 'publishingEntityType' );
$this->set_property( 'label', __( 'Does your site represent a person or an organization?', 'wordpress-seo' ) );
$this->set_property( 'description', __( 'This information will be used in Google\'s Knowledge Graph Card, the big block of information you see on the right side of the search results.', 'wordpress-seo' ) );
$this->add_choice( 'company', __( 'Organization', 'wordpress-seo' ) );
$this->add_choice( 'person', __( 'Person', 'wordpress-seo' ) );
}
/**
* Sets the adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'company_or_person' );
}
}

View File

@@ -0,0 +1,91 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Environment.
*/
class WPSEO_Config_Field_Environment extends WPSEO_Config_Field_Choice {
/**
* WPSEO_Config_Field_Environment constructor.
*/
public function __construct() {
parent::__construct( 'environment_type' );
$this->set_property( 'label', __( 'Please specify if your site is under construction or already active.', 'wordpress-seo' ) );
$this->set_property( 'description', __( 'Choose under construction if you want to keep the site out of the index of search engines. Don\'t forget to activate it once you\'re ready to publish your site.', 'wordpress-seo' ) );
$this->add_choice( 'production', __( 'Option A: My site is live and ready to be indexed', 'wordpress-seo' ) );
$this->add_choice( 'staging', __( 'Option B: My site is under construction and should not be indexed', 'wordpress-seo' ) );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_custom_lookup(
$this->get_identifier(),
[ $this, 'get_data' ],
[ $this, 'set_data' ]
);
}
/**
* Gets the option that is set for this field.
*
* @return string The value for the environment_type wpseo option.
*/
public function get_data() {
return WPSEO_Options::get( 'environment_type' );
}
/**
* Set new data.
*
* @param string $environment_type The site's environment type.
*
* @return bool Returns whether the value is successfully set.
*/
public function set_data( $environment_type ) {
$return = true;
if ( $this->get_data() !== $environment_type ) {
$return = WPSEO_Options::set( 'environment_type', $environment_type );
if ( ! $this->set_indexation( $environment_type ) ) {
return false;
}
}
return $return;
}
/**
* Set the WordPress Search Engine Visibility option based on the environment type.
*
* @param string $environment_type The environment the site is running in.
*
* @return bool Returns if the options is set successfully.
*/
protected function set_indexation( $environment_type ) {
$new_blog_public_value = 0;
$current_blog_public_value = get_option( 'blog_public' );
if ( $environment_type === 'production' ) {
$new_blog_public_value = 1;
}
if ( $current_blog_public_value !== $new_blog_public_value ) {
update_option( 'blog_public', $new_blog_public_value );
return true;
}
return ( get_option( 'blog_public' ) === $new_blog_public_value );
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Mailchimp_Signup.
*/
class WPSEO_Config_Field_Mailchimp_Signup extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Mailchimp_Signup constructor.
*/
public function __construct() {
parent::__construct( 'mailchimpSignup', 'MailchimpSignup' );
$current_user = wp_get_current_user();
$user_email = ( $current_user->ID > 0 ) ? $current_user->user_email : '';
$signup_text = sprintf(
/* translators: %1$s expands to Yoast SEO for WordPress, %2$s expands to Yoast */
__( 'Sign up for our newsletter if you would like to keep up-to-date about %1$s, other cool plugins by %2$s, and interesting news and tips from the world of SEO.', 'wordpress-seo' ),
'Yoast SEO for WordPress',
'Yoast'
);
$gdpr_notice = sprintf(
/* translators: %1$s expands Yoast, %2$s expands to an opening anchor tag, %3$s expands to a closing anchor tag. */
__( '%1$s respects your privacy. Read our %2$sprivacy policy%3$s on how we handle your personal information.', 'wordpress-seo' ),
'Yoast',
'<a target="_blank" rel="noopener noreferrer" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/gdpr-config-wizard' ) . '">',
'</a>'
);
$this->set_property( 'label', $signup_text );
$this->set_property( 'decoration', plugin_dir_url( WPSEO_FILE ) . 'images/newsletter-collage.png' );
$this->set_property( 'mailchimpActionUrl', 'https://yoast.us1.list-manage.com/subscribe/post-json?u=ffa93edfe21752c921f860358&id=972f1c9122' );
$this->set_property( 'currentUserEmail', $user_email );
$this->set_property( 'freeAccountNotice', __( 'Includes a free MyYoast account which gives you access to our free SEO for Beginners course!', 'wordpress-seo' ) );
$this->set_property( 'GDPRNotice', sprintf( '<small>%s</small>', $gdpr_notice ) );
}
/**
* Get the data.
*
* @return array
*/
public function get_data() {
return [
'hasSignup' => $this->has_mailchimp_signup(),
];
}
/**
* Checks if the user has entered their email for mailchimp already.
*
* @return bool
*/
protected function has_mailchimp_signup() {
$user_meta = get_user_meta( get_current_user_id(), WPSEO_Config_Component_Mailchimp_Signup::META_NAME, true );
return ( ! empty( $user_meta ) );
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Multiple_Authors.
*/
class WPSEO_Config_Field_Multiple_Authors extends WPSEO_Config_Field_Choice {
/**
* WPSEO_Config_Field_Multiple_Authors constructor.
*/
public function __construct() {
parent::__construct( 'multipleAuthors' );
$this->set_property( 'label', __( 'Does, or will, your site have multiple authors?', 'wordpress-seo' ) );
$this->set_property( 'description', __( 'If you choose no, your author archives will be deactivated to prevent duplicate content issues.', 'wordpress-seo' ) );
$this->add_choice( 'yes', __( 'Yes', 'wordpress-seo' ) );
$this->add_choice( 'no', __( 'No', 'wordpress-seo' ) );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_custom_lookup(
$this->get_identifier(),
[ $this, 'get_data' ],
[ $this, 'set_data' ]
);
}
/**
* Get the data from the stored options.
*
* @return null|string
*/
public function get_data() {
if ( WPSEO_Options::get( 'has_multiple_authors', false ) ) {
$value = WPSEO_Options::get( 'has_multiple_authors' );
}
if ( ! isset( $value ) || is_null( $value ) ) {
// If there are more than one users with level > 1 default to multiple authors.
$user_criteria = [
'fields' => 'IDs',
'who' => 'authors',
];
$users = get_users( $user_criteria );
$value = count( $users ) > 1;
}
return ( $value ) ? 'yes' : 'no';
}
/**
* Set the data in the options.
*
* @param string $data The data to set for the field.
*
* @return bool Returns true or false for successful storing the data.
*/
public function set_data( $data ) {
$value = ( $data === 'yes' );
// Set multiple authors option.
$result_multiple_authors = WPSEO_Options::set( 'has_multiple_authors', $value );
/*
* Set disable author archives option. When multiple authors is set to true,
* the disable author option has to be false. Because of this the $value is inversed.
*/
$result_author_archives = WPSEO_Options::set( 'disable-author', ! $value );
return ( $result_multiple_authors === true && $result_author_archives === true );
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\Configurator
*/
/**
* Class WPSEO_Config_Field_Person_Name.
*/
class WPSEO_Config_Field_Person extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Company_Or_Person constructor.
*/
public function __construct() {
parent::__construct( 'publishingEntityPersonId', 'WordPressUserSelector' );
$this->set_property( 'label', __( 'The person', 'wordpress-seo' ) );
$this->set_requires( 'publishingEntityType', 'person' );
}
/**
* Sets the adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'company_or_person_user_id' );
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Post_Type_Visibility.
*/
class WPSEO_Config_Field_Post_Type_Visibility extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Post_Type_Visibility constructor.
*/
public function __construct() {
parent::__construct( 'postTypeVisibility', 'HTML' );
$copy = __( 'Please specify what content types you would like to appear in search engines. If you do not know the differences between these, it\'s best to choose the default settings.', 'wordpress-seo' );
$html = '<p>' . esc_html( $copy ) . '</p><br/>';
$this->set_property( 'html', $html );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_Facebook.
*/
class WPSEO_Config_Field_Profile_URL_Facebook extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_Facebook constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlFacebook', 'Input' );
$this->set_property( 'label', __( 'Facebook Page URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/www\.facebook\.com\/([^/]+)\/$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'facebook_site' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_Instagram.
*/
class WPSEO_Config_Field_Profile_URL_Instagram extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_Instagram constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlInstagram', 'Input' );
$this->set_property( 'label', __( 'Instagram URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/www\.instagram\.com\/([^/]+)\/$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'instagram_url' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_LinkedIn.
*/
class WPSEO_Config_Field_Profile_URL_LinkedIn extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_LinkedIn constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlLinkedIn', 'Input' );
$this->set_property( 'label', __( 'LinkedIn URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/www\.linkedin\.com\/in\/([^/]+)$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'linkedin_url' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_MySpace.
*/
class WPSEO_Config_Field_Profile_URL_MySpace extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_MySpace constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlMySpace', 'Input' );
$this->set_property( 'label', __( 'MySpace URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/myspace\.com\/([^/]+)\/$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'myspace_url' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_Pinterest.
*/
class WPSEO_Config_Field_Profile_URL_Pinterest extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_Pinterest constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlPinterest', 'Input' );
$this->set_property( 'label', __( 'Pinterest URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/www\.pinterest\.com\/([^/]+)\/$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'pinterest_url' );
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_Twitter.
*/
class WPSEO_Config_Field_Profile_URL_Twitter extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_Twitter constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlTwitter', 'Input' );
$this->set_property( 'label', __( 'Twitter Username', 'wordpress-seo' ) );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'twitter_site' );
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_YouTube
*/
class WPSEO_Config_Field_Profile_URL_Wikipedia extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_YouTube constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlWikipedia', 'Input' );
$this->set_property( 'label', __( 'Wikipedia URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/([a-z\-]+)\.wikipedia\.org\/([^/]+)$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Sets the adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*
* @return void
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'wikipedia_url' );
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Profile_URL_YouTube.
*/
class WPSEO_Config_Field_Profile_URL_YouTube extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Profile_URL_YouTube constructor.
*/
public function __construct() {
parent::__construct( 'profileUrlYouTube', 'Input' );
$this->set_property( 'label', __( 'YouTube URL', 'wordpress-seo' ) );
$this->set_property( 'pattern', '^https:\/\/www\.youtube\.com\/([^/]+)$' );
$this->set_requires( 'publishingEntityType', 'company' );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'youtube_url' );
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Separator.
*/
class WPSEO_Config_Field_Separator extends WPSEO_Config_Field_Choice {
/**
* WPSEO_Config_Field_Separator constructor.
*/
public function __construct() {
parent::__construct( 'separator' );
$this->set_property( 'label', __( 'Title Separator', 'wordpress-seo' ) );
$this->set_property( 'explanation', __( 'Choose the symbol to use as your title separator. This will display, for instance, between your post title and site name. Symbols are shown in the size they\'ll appear in the search results.', 'wordpress-seo' ) );
$this->add_choices();
}
/**
* Adds the title separator choices.
*/
protected function add_choices() {
$choices = WPSEO_Option_Titles::get_instance()->get_separator_options_for_display();
foreach ( $choices as $key => $value ) {
$this->add_choice( $key, $value['label'], $value['aria_label'] );
}
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'separator' );
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Site_Name.
*/
class WPSEO_Config_Field_Site_Name extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Site_Name constructor.
*/
public function __construct() {
parent::__construct( 'siteName', 'Input' );
$this->set_property( 'label', __( 'Website name', 'wordpress-seo' ) );
$this->set_property( 'explanation', __( 'Google shows your website\'s name in the search results, if you want to change it, you can do that here.', 'wordpress-seo' ) );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_custom_lookup(
$this->get_identifier(),
[ $this, 'get_data' ],
[ $this, 'set_data' ]
);
}
/**
* Get the data from the stored options.
*
* @return null|string
*/
public function get_data() {
if ( WPSEO_Options::get( 'website_name', false ) ) {
return WPSEO_Options::get( 'website_name' );
}
return get_bloginfo( 'name' );
}
/**
* Set the data in the options.
*
* @param string $data The data to set for the field.
*
* @return bool Returns true or false for successful storing the data.
*/
public function set_data( $data ) {
return WPSEO_Options::set( 'website_name', $data );
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Site_Type.
*/
class WPSEO_Config_Field_Site_Type extends WPSEO_Config_Field_Choice {
/**
* WPSEO_Config_Field_Site_Type constructor.
*/
public function __construct() {
parent::__construct( 'siteType' );
/* translators: %1$s resolves to the home_url of the blog. */
$this->set_property( 'label', sprintf( __( 'What does the site %1$s represent?', 'wordpress-seo' ), get_home_url() ) );
$this->add_choice( 'blog', __( 'A blog', 'wordpress-seo' ) );
$this->add_choice( 'shop', __( 'An online shop', 'wordpress-seo' ) );
$this->add_choice( 'news', __( 'A news channel', 'wordpress-seo' ) );
$this->add_choice( 'smallBusiness', __( 'A small offline business', 'wordpress-seo' ) );
$this->add_choice( 'corporate', __( 'A corporation', 'wordpress-seo' ) );
$this->add_choice( 'portfolio', __( 'A portfolio', 'wordpress-seo' ) );
$this->add_choice( 'other', __( 'Something else', 'wordpress-seo' ) );
}
/**
* Set adapter.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
$adapter->add_option_lookup( $this->get_identifier(), 'site_type' );
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Success_Message.
*/
class WPSEO_Config_Field_Success_Message extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Success_Message constructor.
*/
public function __construct() {
parent::__construct( 'successMessage', 'FinalStep' );
$success_message = sprintf(
/* translators: %1$s expands to Yoast SEO. */
__( '%1$s will now take care of all the needed technical optimization of your site. To really improve your site\'s performance in the search results, it\'s important to know everything our plugin has to offer. Sign up for our free %1$s plugin training, in which you\'ll learn how to use %1$s and how it can help you make the best of your website!', 'wordpress-seo' ),
'Yoast SEO'
);
$this->set_property( 'title', __( 'You\'ve done it!', 'wordpress-seo' ) );
$this->set_property( 'message', $success_message );
$this->set_property( 'href', WPSEO_Shortlinker::get( 'https://yoa.st/3rp' ) );
/* translators: %1$s expands to Yoast SEO. */
$img_alt = __( '%1$s video tutorial', 'wordpress-seo' );
$img_args = [
'src' => plugin_dir_url( WPSEO_FILE ) . ( 'images/Yoast_Academy_video.png' ),
'alt' => sprintf( $img_alt, 'Yoast SEO' ),
];
$this->set_property( 'image', $img_args );
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Holds the suggestions for the 'You might also like' page in the wizard.
*/
class WPSEO_Config_Field_Suggestions extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Suggestions constructor.
*/
public function __construct() {
parent::__construct( 'suggestions', 'Suggestions' );
$this->properties['suggestions'] = [];
}
/**
* Adds a suggestion to the properties.
*
* @param string $title The title of the choice.
* @param string $copy The text explaining the choice.
* @param array $button The button details.
* @param array $video URL and title of the video accompanying the choice.
*/
public function add_suggestion( $title, $copy, $button, array $video = [] ) {
$suggestion = [
'title' => $title,
'copy' => $copy,
'button' => $button,
];
if ( ! empty( $video ) ) {
$suggestion['video'] = $video;
}
$this->properties['suggestions'][] = $suggestion;
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Title_Intro.
*/
class WPSEO_Config_Field_Title_Intro extends WPSEO_Config_Field {
/**
* WPSEO_Config_Field_Social_Profiles_Intro constructor.
*/
public function __construct() {
parent::__construct( 'titleIntro', 'HTML' );
$html = __( 'On this page, you can change the name of your site and choose which separator to use. The separator will display, for instance, between your post title and site name. Symbols are shown in the size they\'ll appear in the search results. Choose the one that fits your brand best or takes up the least space in the snippets.', 'wordpress-seo' );
$html = '<p>' . esc_html( $html ) . '</p>';
$this->set_property( 'html', $html );
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Upsell_Configuration_Service.
*/
class WPSEO_Config_Field_Upsell_Configuration_Service extends WPSEO_Config_Field {
/**
* HTML tags allowed in the upsell text.
*
* @var array
*/
private $allowed_html = [
'a' => [
'href' => [],
'target' => [ '_blank' ],
],
];
/**
* WPSEO_Config_Field_Upsell_Configuration_Service constructor.
*/
public function __construct() {
parent::__construct( 'upsellConfigurationService', 'HTML' );
$intro_text = sprintf(
/* translators: %1$s expands to Yoast SEO. */
__( 'Welcome to the %1$s configuration wizard. In a few simple steps we\'ll help you configure your SEO settings to match your website\'s needs!', 'wordpress-seo' ),
'Yoast SEO'
);
$upsell_text = sprintf(
/* Translators: %1$s expands to Yoast SEO, %2$s expands to Yoast SEO Premium, %3$s opens the link, %4$s closes the link. */
__( 'While we strive to make setting up %1$s as easy as possible, we understand it can be daunting. If youd rather have us set up %1$s for you (and get a copy of %2$s in the process), order our %3$s%1$s configuration service%4$s here!', 'wordpress-seo' ),
'Yoast SEO',
'Yoast SEO Premium',
'<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/configuration-package' ) . '">',
'</a>'
);
$html = '<p>' . esc_html( $intro_text ) . '</p>';
$html .= '<p><em>' . wp_kses( $upsell_text, $this->allowed_html ) . '</em></p>';
$this->set_property( 'html', $html );
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field_Upsell_Site_Review.
*/
class WPSEO_Config_Field_Upsell_Site_Review extends WPSEO_Config_Field {
/**
* HTML tags allowed in the upsell site review text.
*
* @var array
*/
private $allowed_html = [
'a' => [
'href' => [],
'target' => [ '_blank' ],
],
];
/**
* WPSEO_Config_Field_Upsell_Site_Review constructor.
*/
public function __construct() {
parent::__construct( 'upsellSiteReview', 'HTML' );
$upsell_text = sprintf(
/* translators: %1$s will be a link to a review explanation page. Text between %2$s and %3$s will be a link to an SEO copywriting course page. */
__( 'If you want more help creating awesome content, check out our %2$sSEO copywriting course%3$s. Do you want to know all about the features of the plugin, consider doing our %1$s!', 'wordpress-seo' ),
'<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/yoastseotraining' ) . '" target="_blank">Yoast SEO for WordPress training</a>',
'<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/configuration-wizard-copywrite-course-link' ) . '" target="_blank">',
'</a>'
);
$html = '<p>' . wp_kses( $upsell_text, $this->allowed_html ) . '</p>';
$this->set_property( 'html', $html );
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* WPSEO plugin file.
*
* @package WPSEO\Admin\ConfigurationUI
*/
/**
* Class WPSEO_Config_Field.
*/
class WPSEO_Config_Field {
/**
* Field name.
*
* @var string
*/
protected $field;
/**
* Component to use.
*
* @var string
*/
protected $component;
/**
* Properties of this field.
*
* @var array
*/
protected $properties = [];
/**
* Field requirements.
*
* @var array
*/
protected $requires = [];
/**
* Value of this field.
*
* @var array|mixed
*/
protected $data = [];
/**
* WPSEO_Config_Field constructor.
*
* @param string $field The field name.
* @param string $component The component to use.
*/
public function __construct( $field, $component ) {
$this->field = $field;
$this->component = $component;
}
/**
* Get the identifier.
*
* @return string
*/
public function get_identifier() {
return $this->field;
}
/**
* Get the component.
*
* @return string
*/
public function get_component() {
return $this->component;
}
/**
* Set a property value.
*
* @param string $name Property to set.
* @param mixed $value Value to apply.
*/
public function set_property( $name, $value ) {
$this->properties[ $name ] = $value;
}
/**
* Get all the properties.
*
* @return array
*/
public function get_properties() {
return $this->properties;
}
/**
* Get the data.
*
* @return mixed
*/
public function get_data() {
return $this->data;
}
/**
* Array representation of this object.
*
* @return array
*/
public function to_array() {
$output = [
'componentName' => $this->get_component(),
];
$properties = $this->get_properties();
if ( $properties ) {
$output['properties'] = $properties;
}
$requires = $this->get_requires();
if ( ! empty( $requires ) ) {
$output['requires'] = $requires;
}
return $output;
}
/**
* Set the adapter to use.
*
* @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on.
*/
public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) {
}
/**
* Requires another field to have a certain value.
*
* @param string $field Field to check for a certain value.
* @param mixed $value Value of the field.
*/
public function set_requires( $field, $value ) {
$this->requires = [
'field' => $field,
'value' => $value,
];
}
/**
* Get the required field settings (if present).
*
* @return array
*/
public function get_requires() {
return $this->requires;
}
}