Файловый менеджер - Редактировать - /home/kunzqhe/photostocker/2/config-ui.tar
Ðазад
class-configuration-service.php 0000644 00000010604 15154772352 0012701 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Service. */ class WPSEO_Configuration_Service { /** * Class holding the onboarding wizard configuration. * * @var WPSEO_Configuration_Structure */ protected $structure; /** * Class holding the onboarding wizard components. * * @var WPSEO_Configuration_Components */ protected $components; /** * Class handling the onboarding wizard persistence. * * @var WPSEO_Configuration_Storage */ protected $storage; /** * Class handling the onboarding wizard endpoint. * * @var WPSEO_Configuration_Endpoint */ protected $endpoint; /** * Adapter that converts onboarding wizard configuration to WordPress options. * * @var WPSEO_Configuration_Options_Adapter */ protected $adapter; /** * Class handling the onboarding wizard endpoint. * * @var WPSEO_Configuration_Translations */ protected $translations; /** * Hook into the REST API and switch language. */ public function initialize() { $this->set_default_providers(); $this->endpoint->register(); } /** * Set default handlers. */ public function set_default_providers() { $this->set_storage( new WPSEO_Configuration_Storage() ); $this->set_options_adapter( new WPSEO_Configuration_Options_Adapter() ); $this->set_components( new WPSEO_Configuration_Components() ); $this->set_endpoint( new WPSEO_Configuration_Endpoint() ); $this->set_structure( new WPSEO_Configuration_Structure() ); $this->set_translations( new WPSEO_Configuration_Translations( \get_user_locale() ) ); } /** * Set storage handler. * * @param WPSEO_Configuration_Storage $storage Storage handler to use. */ public function set_storage( WPSEO_Configuration_Storage $storage ) { $this->storage = $storage; } /** * Set endpoint handler. * * @param WPSEO_Configuration_Endpoint $endpoint Endpoint implementation to use. */ public function set_endpoint( WPSEO_Configuration_Endpoint $endpoint ) { $this->endpoint = $endpoint; $this->endpoint->set_service( $this ); } /** * Set the options adapter. * * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to use. */ public function set_options_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { $this->adapter = $adapter; } /** * Set components provider. * * @param WPSEO_Configuration_Components $components Component provider to use. */ public function set_components( WPSEO_Configuration_Components $components ) { $this->components = $components; } /** * Set structure provider. * * @param WPSEO_Configuration_Structure $structure Structure provider to use. */ public function set_structure( WPSEO_Configuration_Structure $structure ) { $this->structure = $structure; } /** * Sets the translations object. * * @param WPSEO_Configuration_Translations $translations The translations object. */ public function set_translations( WPSEO_Configuration_Translations $translations ) { $this->translations = $translations; } /** * Populate the configuration. */ protected function populate_configuration() { // Switch to the user locale with fallback to the site locale. switch_to_locale( \get_user_locale() ); // Make sure we have our translations available. wpseo_load_textdomain(); $this->structure->initialize(); $this->storage->set_adapter( $this->adapter ); $this->storage->add_default_fields(); $this->components->initialize(); $this->components->set_storage( $this->storage ); // @todo: check if this is really needed, since the switch happens only in the API. restore_current_locale(); } /** * Used by endpoint to retrieve configuration. * * @return array List of settings. */ public function get_configuration() { $this->populate_configuration(); $fields = $this->storage->retrieve(); $steps = $this->structure->retrieve(); $translations = $this->translations->retrieve(); return [ 'fields' => $fields, 'steps' => $steps, 'translations' => $translations, ]; } /** * Used by endpoint to store changes. * * @param WP_REST_Request $request Request from the REST API. * * @return array List of feedback per option if saving succeeded. */ public function set_configuration( WP_REST_Request $request ) { $this->populate_configuration(); return $this->storage->store( $request->get_json_params() ); } } class-configuration-endpoint.php 0000644 00000004027 15154772352 0013063 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Endpoint. */ class WPSEO_Configuration_Endpoint { /** * Holds the REST namespace. * * @var string */ const REST_NAMESPACE = 'yoast/v1'; /** * Holds the endpoint to retrieve from. * * @var string */ const ENDPOINT_RETRIEVE = 'configurator'; /** * Holds the endpoint to store to. * * @var string */ const ENDPOINT_STORE = 'configurator'; /** * Holds the capability that can retrieve from the endpoint. * * @var string */ const CAPABILITY_RETRIEVE = 'wpseo_manage_options'; /** * Holds the capability that can store to the endpoint. * * @var string */ const CAPABILITY_STORE = 'wpseo_manage_options'; /** * Service to use. * * @var WPSEO_Configuration_Service */ protected $service; /** * Sets the service to use. * * @param WPSEO_Configuration_Service $service Service to use. */ public function set_service( WPSEO_Configuration_Service $service ) { $this->service = $service; } /** * Register REST routes. */ public function register() { // Register fetch config. $route_args = [ 'methods' => 'GET', 'callback' => [ $this->service, 'get_configuration' ], 'permission_callback' => [ $this, 'can_retrieve_data' ], ]; register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_RETRIEVE, $route_args ); // Register save changes. $route_args = [ 'methods' => 'POST', 'callback' => [ $this->service, 'set_configuration' ], 'permission_callback' => [ $this, 'can_save_data' ], ]; register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_STORE, $route_args ); } /** * Permission callback implementation. * * @return bool */ public function can_retrieve_data() { return current_user_can( self::CAPABILITY_RETRIEVE ); } /** * Permission callback implementation. * * @return bool */ public function can_save_data() { return current_user_can( self::CAPABILITY_STORE ); } } class-configuration-components.php 0000644 00000003071 15154772352 0013426 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Components. */ class WPSEO_Configuration_Components { /** * List of registered components. * * @var WPSEO_Config_Component[] */ protected $components = []; /** * Adapter. * * @var WPSEO_Configuration_Options_Adapter */ protected $adapter; /** * Add default components. */ public function initialize() { $this->add_component( new WPSEO_Config_Component_Mailchimp_Signup() ); $this->add_component( new WPSEO_Config_Component_Suggestions() ); } /** * Add a component. * * @param WPSEO_Config_Component $component Component to add. */ public function add_component( WPSEO_Config_Component $component ) { $this->components[] = $component; } /** * Sets the storage to use. * * @param WPSEO_Configuration_Storage $storage Storage to use. */ public function set_storage( WPSEO_Configuration_Storage $storage ) { $this->set_adapter( $storage->get_adapter() ); foreach ( $this->components as $component ) { $storage->add_field( $component->get_field() ); } } /** * Sets the adapter to use. * * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to use. */ public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { $this->adapter = $adapter; foreach ( $this->components as $component ) { $adapter->add_custom_lookup( $component->get_field()->get_identifier(), [ $component, 'get_data', ], [ $component, 'set_data', ] ); } } } factories/class-factory-post-type.php 0000644 00000004147 15154772352 0013771 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Configurator */ /** * Class WPSEO_Config_Factory_Post_Type. */ class WPSEO_Config_Factory_Post_Type { /** * List of fields. * * @var WPSEO_Config_Field_Choice_Post_Type[] */ protected static $fields = []; /** * Retrieves a list of fields. * * @return WPSEO_Config_Field_Choice_Post_Type[] List of fields. */ public function get_fields() { if ( empty( self::$fields ) ) { $fields = []; // WPSEO_Post_type::get_accessible_post_types() should *not* be used to get a similar experience from the settings. $post_types = get_post_types( [ 'public' => true ], 'objects' ); $post_types = WPSEO_Post_Type::filter_attachment_post_type( $post_types ); if ( ! empty( $post_types ) ) { foreach ( $post_types as $post_type => $post_type_object ) { $label = $this->decode_html_entities( $post_type_object->label ); $field = new WPSEO_Config_Field_Choice_Post_Type( $post_type, $label ); $this->add_custom_properties( $post_type, $field ); $fields[] = $field; } } self::$fields = $fields; } return self::$fields; } /** * Add custom properties for specific post types. * * @param string $post_type Post type of field that is being added. * @param WPSEO_Config_Field $field Field that corresponds to the post type. */ private function add_custom_properties( $post_type, $field ) { if ( $post_type === 'attachment' ) { $field->set_property( 'explanation', __( 'WordPress automatically generates an URL for each media item in the library. Enabling this will allow for google to index the generated URL.', 'wordpress-seo' ) ); } } /** * Replaces the HTML entity with it's actual symbol. * * Because we do not not know what consequences it will have if we convert every HTML entity, * we will only replace the characters that we have known problems with in text's. * * @param string $text The text to decode. * * @return string String with decoded HTML entities. */ private function decode_html_entities( $text ) { return str_replace( ''', '’', $text ); } } class-configuration-options-adapter.php 0000644 00000011627 15154772352 0014360 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Options_Adapter. * * Convert Configuration settings to WPSEO Options. * * @since 3.6 */ class WPSEO_Configuration_Options_Adapter { /** * Holds the option type value that indicates: WordPress. * * @var string */ const OPTION_TYPE_WORDPRESS = 'wordpress'; /** * Holds the option type value that indicates: Yoast. * * @var string */ const OPTION_TYPE_YOAST = 'yoast'; /** * Holds the option type value that indicates: Custom. * * @var string */ const OPTION_TYPE_CUSTOM = 'custom'; /** * List of registered lookups. * * @var array */ protected $lookup = []; /** * Add a lookup for a WordPress native option. * * @param string $class_name Class to bind to an option. * @param string $option Option name to use. * * @throws InvalidArgumentException Thrown when invalid input is provided. */ public function add_wordpress_lookup( $class_name, $option ) { if ( ! is_string( $option ) ) { throw new InvalidArgumentException( 'WordPress option must be a string.' ); } $this->add_lookup( $class_name, self::OPTION_TYPE_WORDPRESS, $option ); } /** * Add a lookup for a Yoast option. * * @param string $class_name Class to bind to the lookup. * @param string $key Key in the option group to bind to. * * @throws InvalidArgumentException Thrown when invalid input is provided. */ public function add_option_lookup( $class_name, $key ) { $test = WPSEO_Options::get( $key ); if ( is_null( $test ) ) { /* translators: %1$s resolves to the option name passed to the lookup registration */ throw new InvalidArgumentException( sprintf( __( 'Yoast option %1$s not found.', 'wordpress-seo' ), $key ) ); } $this->add_lookup( $class_name, self::OPTION_TYPE_YOAST, $key ); } /** * Add a lookup for a custom implementation. * * @param string $class_name Class to bind to the lookup. * @param callable $callback_get Callback to retrieve data. * @param callable $callback_set Callback to save data. * * @throws InvalidArgumentException Thrown when invalid input is provided. */ public function add_custom_lookup( $class_name, $callback_get, $callback_set ) { if ( ! is_callable( $callback_get ) || ! is_callable( $callback_set ) ) { throw new InvalidArgumentException( 'Custom option must be callable.' ); } $this->add_lookup( $class_name, self::OPTION_TYPE_CUSTOM, [ $callback_get, $callback_set ] ); } /** * Add a field lookup. * * @param string $class_name Class to add lookup for. * @param string $type Type of lookup. * @param string|array $option Implementation of the lookup. * * @throws Exception Thrown when invalid input is provided. */ protected function add_lookup( $class_name, $type, $option ) { $this->lookup[ $class_name ] = [ 'type' => $type, 'option' => $option, ]; } /** * Get the data for the provided field. * * @param WPSEO_Config_Field $field Field to get data for. * * @return mixed */ public function get( WPSEO_Config_Field $field ) { $identifier = $field->get_identifier(); // Lookup option and retrieve value. $type = $this->get_option_type( $identifier ); $option = $this->get_option( $identifier ); switch ( $type ) { case self::OPTION_TYPE_WORDPRESS: return get_option( $option ); case self::OPTION_TYPE_YOAST: return WPSEO_Options::get( $option ); case self::OPTION_TYPE_CUSTOM: return call_user_func( $option[0] ); } return null; } /** * Save data from a field. * * @param WPSEO_Config_Field $field Field to use for lookup. * @param mixed $value Value to save to the lookup of the field. * * @return bool */ public function set( WPSEO_Config_Field $field, $value ) { $identifier = $field->get_identifier(); // Lookup option and retrieve value. $type = $this->get_option_type( $identifier ); $option = $this->get_option( $identifier ); switch ( $type ) { case self::OPTION_TYPE_WORDPRESS: return update_option( $option, $value ); case self::OPTION_TYPE_YOAST: return WPSEO_Options::set( $option, $value ); case self::OPTION_TYPE_CUSTOM: return call_user_func( $option[1], $value ); } return false; } /** * Get the lookup type for a specific class. * * @param string $class_name Class to get the type of. * * @return string|null */ protected function get_option_type( $class_name ) { if ( ! isset( $this->lookup[ $class_name ] ) ) { return null; } return $this->lookup[ $class_name ]['type']; } /** * Get the option for a specific class. * * @param string $class_name Class to get the option of. * * @return string|array|null */ protected function get_option( $class_name ) { if ( ! isset( $this->lookup[ $class_name ] ) ) { return null; } return $this->lookup[ $class_name ]['option']; } } fields/class-field-site-type.php 0000644 00000002440 15154772352 0012645 0 ustar 00 <?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' ); } } fields/class-field-site-name.php 0000644 00000002616 15154772352 0012611 0 ustar 00 <?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 string|null */ 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 ); } } fields/class-field-profile-url-facebook.php 0000644 00000001550 15154772352 0014732 0 ustar 00 <?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' ); } } fields/class-field-separator.php 0000644 00000002345 15154772352 0012726 0 ustar 00 <?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' ); } } fields/class-field-profile-url-wikipedia.php 0000644 00000001603 15154772352 0015126 0 ustar 00 <?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' ); } } fields/class-field-company-name.php 0000644 00000001515 15154772352 0013310 0 ustar 00 <?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' ); } } fields/class-field-title-intro.php 0000644 00000001434 15154772352 0013176 0 ustar 00 <?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 ); } } fields/class-field-environment.php 0000644 00000005107 15154772352 0013271 0 ustar 00 <?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 ); } } fields/class-field-choice.php 0000644 00000001557 15154772352 0012164 0 ustar 00 <?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; } } fields/class-field-company-logo.php 0000644 00000001447 15154772352 0013334 0 ustar 00 <?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' ); } } fields/class-field-choice-post-type.php 0000644 00000003664 15154772352 0014127 0 ustar 00 <?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' ) ); } } fields/class-field.php 0000644 00000005003 15154772352 0010722 0 ustar 00 <?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; } } fields/class-field-company-info-missing.php 0000644 00000001357 15154772352 0014776 0 ustar 00 <?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' ); } } fields/class-field-company-or-person.php 0000644 00000002131 15154772352 0014307 0 ustar 00 <?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' ); } } fields/class-field-multiple-authors.php 0000644 00000004461 15154772352 0014245 0 ustar 00 <?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 string|null */ 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 ); } } fields/class-field-profile-url-myspace.php 0000644 00000001526 15154772352 0014625 0 ustar 00 <?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' ); } } fields/class-field-tracking.php 0000644 00000003066 15154772352 0012531 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Config_Field_Tracking. */ class WPSEO_Config_Field_Tracking extends WPSEO_Config_Field_Choice { /** * WPSEO_Config_Field_Tracking constructor. */ public function __construct() { parent::__construct( 'tracking' ); $this->set_property( 'label', __( 'Can we collect anonymous information about your website and its usage?', 'wordpress-seo' ) ); $this->add_choice( 'no', __( 'No, I don\'t want to allow you to track my site data.', 'wordpress-seo' ) ); $this->add_choice( 'yes', __( 'Yes, you can track my site\'s data!', '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() { $tracking = WPSEO_Options::get( 'tracking' ); if ( $tracking ) { return 'yes'; } return 'no'; } /** * Set new data. * * @param string $tracking The site's environment type. * * @return bool Returns whether the value is successfully set. */ public function set_data( $tracking ) { $return = true; if ( $this->get_data() !== $tracking ) { $return = WPSEO_Options::set( 'tracking', $tracking ); } return $return; } } fields/class-field-success-message.php 0000644 00000002503 15154772352 0014014 0 ustar 00 <?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 ); } } fields/class-field-profile-url-instagram.php 0000644 00000001551 15154772352 0015147 0 ustar 00 <?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' ); } } fields/class-field-mailchimp-signup.php 0000644 00000004423 15154772352 0014173 0 ustar 00 <?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 ) ); } } fields/class-field-profile-url-pinterest.php 0000644 00000001551 15154772352 0015177 0 ustar 00 <?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' ); } } fields/class-field-tracking-intro.php 0000644 00000001754 15154772352 0013664 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Config_Field_Tracking_Intro. */ class WPSEO_Config_Field_Tracking_Intro extends WPSEO_Config_Field { /** * WPSEO_Config_Field_Tracking_Intro constructor. */ public function __construct() { parent::__construct( 'trackingIntro', 'HTML' ); $html = '<p>' . esc_html__( 'At Yoast, we are always keen on providing the very best experience for you. To do so, we\'d like to collect some data about which other plugins and themes you have installed, and which features you use and don\'t use. Be assured that we\'ll never resell that data. And of course, as always, we won\'t collect any personal data about you or your visitors!', 'wordpress-seo' ) . '</p>'; $html .= '<p><a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/usage-tracking' ) . '" target="_blank">' . esc_html__( 'Read more about our usage tracking.', 'wordpress-seo' ) . '</a></p>'; $this->set_property( 'html', $html ); } } fields/class-field-profile-url-twitter.php 0000644 00000001421 15154772352 0014660 0 ustar 00 <?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' ); } } fields/class-field-profile-url-linkedin.php 0000644 00000001544 15154772352 0014761 0 ustar 00 <?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' ); } } fields/class-field-post-type-visibility.php 0000644 00000001243 15154772352 0015053 0 ustar 00 <?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 ); } } fields/class-field-person.php 0000644 00000001431 15154772352 0012227 0 ustar 00 <?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' ); } } fields/class-field-profile-url-youtube.php 0000644 00000001531 15154772352 0014654 0 ustar 00 <?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' ); } } fields/class-field-suggestions.php 0000644 00000001757 15154772352 0013306 0 ustar 00 <?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; } } class-configuration-page.php 0000644 00000016066 15154772352 0012165 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin */ /** * Loads the Yoast configuration wizard. */ class WPSEO_Configuration_Page { /** * Admin page identifier. * * @var string */ const PAGE_IDENTIFIER = 'wpseo_configurator'; /** * Sets the hooks when the user has enough rights and is on the right page. */ public function set_hooks() { if ( ! ( $this->is_config_page() && current_user_can( WPSEO_Configuration_Endpoint::CAPABILITY_RETRIEVE ) ) ) { return; } if ( $this->should_add_notification() ) { $this->add_notification(); } // Register the page for the wizard. add_action( 'admin_menu', [ $this, 'add_wizard_page' ] ); add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] ); add_action( 'admin_init', [ $this, 'render_wizard_page' ] ); } /** * Check if the configuration is finished. If so, just remove the notification. */ public function catch_configuration_request() { $configuration_page = filter_input( INPUT_GET, 'configuration' ); $page = filter_input( INPUT_GET, 'page' ); if ( ! ( $configuration_page === 'finished' && ( $page === WPSEO_Admin::PAGE_IDENTIFIER ) ) ) { return; } $this->remove_notification(); $this->remove_notification_option(); wp_safe_redirect( admin_url( 'admin.php?page=' . WPSEO_Admin::PAGE_IDENTIFIER ) ); exit; } /** * Registers the page for the wizard. */ public function add_wizard_page() { add_dashboard_page( '', '', 'wpseo_manage_options', self::PAGE_IDENTIFIER, '' ); } /** * Renders the wizard page and exits to prevent the WordPress UI from loading. */ public function render_wizard_page() { $this->show_wizard(); exit; } /** * Enqueues the assets needed for the wizard. */ public function enqueue_assets() { wp_enqueue_media(); if ( ! wp_script_is( 'wp-element', 'registered' ) && function_exists( 'gutenberg_register_scripts_and_styles' ) ) { gutenberg_register_scripts_and_styles(); } /* * Print the `forms.css` WP stylesheet before any Yoast style, this way * it's easier to override selectors with the same specificity later. */ wp_enqueue_style( 'forms' ); $asset_manager = new WPSEO_Admin_Asset_Manager(); $asset_manager->register_assets(); $asset_manager->enqueue_script( 'configuration-wizard' ); $asset_manager->enqueue_style( 'yoast-components' ); $config = $this->get_config(); $asset_manager->localize_script( 'configuration-wizard', 'yoastWizardConfig', $config ); $yoast_components_l10n = new WPSEO_Admin_Asset_Yoast_Components_L10n(); $yoast_components_l10n->localize_script( 'configuration-wizard' ); } /** * Setup Wizard Header. */ public function show_wizard() { $this->enqueue_assets(); $dashboard_url = admin_url( '/admin.php?page=wpseo_dashboard' ); $wizard_title = sprintf( /* translators: %s expands to Yoast SEO. */ __( '%s › Configuration Wizard', 'wordpress-seo' ), 'Yoast SEO' ); ?> <!DOCTYPE html> <!--[if IE 9]> <html class="ie9" <?php language_attributes(); ?> > <![endif]--> <!--[if !(IE 9) ]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> <head> <meta name="viewport" content="width=device-width, initial-scale=1"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title><?php echo esc_html( $wizard_title ); ?></title> <?php wp_print_head_scripts(); wp_print_styles( 'yoast-seo-yoast-components' ); /** * Is called before the closing </head> tag in the Yoast Configuration wizard. * * Allows users to add their own scripts or styles. * * @since 4.0 */ do_action( 'wpseo_configuration_wizard_head' ); ?> </head> <body class="wp-admin wp-core-ui"> <div id="wizard"></div> <div role="contentinfo" class="yoast-wizard-return-link-container"> <a class="button yoast-wizard-return-link" href="<?php echo esc_url( $dashboard_url ); ?>"> <span aria-hidden="true" class="dashicons dashicons-no"></span> <?php esc_html_e( 'Close the Wizard', 'wordpress-seo' ); ?> </a> </div> <?php wp_print_media_templates(); wp_print_footer_scripts(); /** * Is called before the closing </body> tag in the Yoast Configuration wizard. * * Allows users to add their own scripts. * * @since 4.0 */ do_action( 'wpseo_configuration_wizard_footer' ); wp_print_scripts( 'yoast-seo-configuration-wizard' ); ?> </body> </html> <?php } /** * Get the API config for the wizard. * * @return array The API endpoint config. */ public function get_config() { $config = [ 'namespace' => WPSEO_Configuration_Endpoint::REST_NAMESPACE, 'endpoint_retrieve' => WPSEO_Configuration_Endpoint::ENDPOINT_RETRIEVE, 'endpoint_store' => WPSEO_Configuration_Endpoint::ENDPOINT_STORE, 'nonce' => wp_create_nonce( 'wp_rest' ), 'root' => esc_url_raw( rest_url() ), 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'finishUrl' => admin_url( 'admin.php?page=wpseo_dashboard&configuration=finished' ), ]; return $config; } /** * Checks if the current page is the configuration page. * * @return bool */ protected function is_config_page() { return ( filter_input( INPUT_GET, 'page' ) === self::PAGE_IDENTIFIER ); } /** * Adds a notification to the notification center. */ private function add_notification() { $notification_center = Yoast_Notification_Center::get(); $notification_center->add_notification( self::get_notification() ); } /** * Removes the notification from the notification center. */ private function remove_notification() { $notification_center = Yoast_Notification_Center::get(); $notification_center->remove_notification( self::get_notification() ); } /** * Gets the notification. * * @return Yoast_Notification */ private static function get_notification() { $message = __( 'The configuration wizard helps you to easily configure your site to have the optimal SEO settings.', 'wordpress-seo' ); $message .= '<br/>'; $message .= sprintf( /* translators: %1$s resolves to Yoast SEO, %2$s resolves to the starting tag of the link to the wizard, %3$s resolves to the closing link tag */ __( 'We have detected that you have not finished this wizard yet, so we recommend you to %2$sstart the configuration wizard to configure %1$s%3$s.', 'wordpress-seo' ), 'Yoast SEO', '<a href="' . admin_url( '?page=' . self::PAGE_IDENTIFIER ) . '">', '</a>' ); $notification = new Yoast_Notification( $message, [ 'type' => Yoast_Notification::WARNING, 'id' => 'wpseo-dismiss-onboarding-notice', 'capabilities' => 'wpseo_manage_options', 'priority' => 0.8, ] ); return $notification; } /** * When the notice should be shown. * * @return bool */ private function should_add_notification() { return ( WPSEO_Options::get( 'show_onboarding_notice' ) === true ); } /** * Remove the options that triggers the notice for the configuration wizard. */ private function remove_notification_option() { WPSEO_Options::set( 'show_onboarding_notice', false ); } } class-configuration-storage.php 0000644 00000011033 15154772352 0012702 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Storage. */ class WPSEO_Configuration_Storage { /** * Holds the configuration options adapter. * * @var \WPSEO_Configuration_Options_Adapter */ protected $adapter; /** * Holds the configuration fields. * * @var \WPSEO_Config_Field[] */ protected $fields = []; /** * Add default fields. */ public function add_default_fields() { $fields = [ new WPSEO_Config_Field_Success_Message(), new WPSEO_Config_Field_Mailchimp_Signup(), new WPSEO_Config_Field_Environment(), new WPSEO_Config_Field_Site_Type(), new WPSEO_Config_Field_Multiple_Authors(), new WPSEO_Config_Field_Title_Intro(), new WPSEO_Config_Field_Site_Name(), new WPSEO_Config_Field_Separator(), new WPSEO_Config_Field_Profile_URL_Facebook(), new WPSEO_Config_Field_Profile_URL_Twitter(), new WPSEO_Config_Field_Profile_URL_Instagram(), new WPSEO_Config_Field_Profile_URL_LinkedIn(), new WPSEO_Config_Field_Profile_URL_MySpace(), new WPSEO_Config_Field_Profile_URL_Pinterest(), new WPSEO_Config_Field_Profile_URL_YouTube(), new WPSEO_Config_Field_Profile_URL_Wikipedia(), new WPSEO_Config_Field_Company_Or_Person(), new WPSEO_Config_Field_Company_Info_Missing(), new WPSEO_Config_Field_Company_Name(), new WPSEO_Config_Field_Company_Logo(), new WPSEO_Config_Field_Person(), new WPSEO_Config_Field_Post_Type_Visibility(), new WPSEO_Config_Field_Tracking_Intro(), new WPSEO_Config_Field_Tracking(), ]; $post_type_factory = new WPSEO_Config_Factory_Post_Type(); $fields = array_merge( $fields, $post_type_factory->get_fields() ); foreach ( $fields as $field ) { $this->add_field( $field ); } } /** * Allow for field injections. * * @param WPSEO_Config_Field $field Field to add to the stack. */ public function add_field( WPSEO_Config_Field $field ) { $this->fields[] = $field; if ( isset( $this->adapter ) ) { $field->set_adapter( $this->adapter ); } } /** * Set the adapter to use. * * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to use. */ public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { $this->adapter = $adapter; foreach ( $this->fields as $field ) { $field->set_adapter( $this->adapter ); } } /** * Retrieve the current adapter. * * @return WPSEO_Configuration_Options_Adapter */ public function get_adapter() { return $this->adapter; } /** * Retrieve the registered fields. * * @return array List of settings. */ public function retrieve() { $output = []; foreach ( $this->fields as $field ) { $build = $field->to_array(); $data = $this->get_field_data( $field ); if ( ! is_null( $data ) ) { $build['data'] = $data; } $output[ $field->get_identifier() ] = $build; } return $output; } /** * Save the data. * * @param array $data_to_store Data provided by the API which needs to be processed for saving. * * @return string Results */ public function store( $data_to_store ) { $output = []; foreach ( $this->fields as $field ) { $field_identifier = $field->get_identifier(); if ( ! array_key_exists( $field_identifier, $data_to_store ) ) { continue; } $field_data = []; if ( isset( $data_to_store[ $field_identifier ] ) ) { $field_data = $data_to_store[ $field_identifier ]; } $result = $this->adapter->set( $field, $field_data ); $build = [ 'result' => $result, ]; // Set current data to object to be displayed. $data = $this->get_field_data( $field ); if ( ! is_null( $data ) ) { $build['data'] = $data; } $output[ $field_identifier ] = $build; } return $output; } /** * Filter out null input values. * * @param mixed $input Input to test against. * * @return bool */ protected function is_not_null( $input ) { return ! is_null( $input ); } /** * Get data from a specific field. * * @param WPSEO_Config_Field $field Field to get data for. * * @return array|mixed */ protected function get_field_data( WPSEO_Config_Field $field ) { $data = $this->adapter->get( $field ); if ( is_array( $data ) ) { $defaults = $field->get_data(); // Remove 'null' values from input. $data = array_filter( $data, [ $this, 'is_not_null' ] ); // Merge defaults with data. $data = array_merge( $defaults, $data ); } if ( is_null( $data ) ) { // Get default if no data was set. $data = $field->get_data(); return $data; } return $data; } } class-configuration-structure.php 0000644 00000006610 15154772352 0013303 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Structure */ class WPSEO_Configuration_Structure { /** * Registered steps. * * @var array */ protected $steps = []; /** * List of fields for each configuration step. * * This list does not include the fields for the 'postTypeVisibility' * step as that list will be generated on the fly. * * @var array */ private $fields = [ 'environment_type' => [ 'environment_type' ], 'siteType' => [ 'siteType' ], 'publishingEntity' => [ 'publishingEntity', 'publishingEntityType', 'publishingEntityCompanyInfo', 'publishingEntityCompanyName', 'publishingEntityCompanyLogo', 'publishingEntityPersonId', 'profileUrlFacebook', 'profileUrlTwitter', 'profileUrlInstagram', 'profileUrlLinkedIn', 'profileUrlMySpace', 'profileUrlPinterest', 'profileUrlYouTube', 'profileUrlWikipedia', ], 'multipleAuthors' => [ 'multipleAuthors' ], 'titleTemplate' => [ 'titleIntro', 'siteName', 'separator', ], 'tracking' => [ 'trackingIntro', 'tracking', ], 'newsletter' => [ 'mailchimpSignup', 'suggestions', ], 'success' => [ 'successMessage' ], ]; /** * WPSEO_Configuration_Structure constructor. */ public function initialize() { $this->add_step( 'environment-type', __( 'Environment', 'wordpress-seo' ), $this->fields['environment_type'] ); $this->add_step( 'site-type', __( 'Site type', 'wordpress-seo' ), $this->fields['siteType'] ); $this->add_step( 'publishing-entity', __( 'Organization or person', 'wordpress-seo' ), $this->fields['publishingEntity'] ); $fields = [ 'postTypeVisibility' ]; $post_type_factory = new WPSEO_Config_Factory_Post_Type(); foreach ( $post_type_factory->get_fields() as $post_type_field ) { $fields[] = $post_type_field->get_identifier(); } $this->add_step( 'post-type-visibility', __( 'Search engine visibility', 'wordpress-seo' ), $fields ); $this->add_step( 'multiple-authors', __( 'Multiple authors', 'wordpress-seo' ), $this->fields['multipleAuthors'] ); $this->add_step( 'title-template', __( 'Title settings', 'wordpress-seo' ), $this->fields['titleTemplate'] ); /* translators: %s expands to Yoast SEO */ $this->add_step( 'tracking', sprintf( __( 'Help us improve %s', 'wordpress-seo' ), 'Yoast SEO' ), $this->fields['tracking'] ); $this->add_step( 'newsletter', __( 'Continue learning', 'wordpress-seo' ), $this->fields['newsletter'], true, true ); $this->add_step( 'success', __( 'Success!', 'wordpress-seo' ), $this->fields['success'], true, true ); } /** * Add a step to the structure * * @param string $identifier Identifier for this step. * @param string $title Title to display for this step. * @param array $fields Fields to use on the step. * @param bool $navigation Show navigation buttons. * @param bool $full_width Wheter the step content is full width or not. */ protected function add_step( $identifier, $title, $fields, $navigation = true, $full_width = false ) { $this->steps[ $identifier ] = [ 'title' => $title, 'fields' => $fields, 'hideNavigation' => ! (bool) $navigation, 'fullWidth' => $full_width, ]; } /** * Retrieve the registered steps. * * @return array */ public function retrieve() { return $this->steps; } } class-configuration-translations.php 0000644 00000002357 15154772352 0013770 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Class WPSEO_Configuration_Structure. */ class WPSEO_Configuration_Translations { /** * Registered steps. * * @var array */ protected $translations = []; /** * The locale. * * @var string */ protected $locale; /** * Sets the translations based on the file. * * @param string $locale The locale to retrieve the translations for. */ public function __construct( $locale ) { $this->locale = $locale; $this->translations = $this->get_translations_from_file(); } /** * Retrieve the translations. * * @return array */ public function retrieve() { return $this->translations; } /** * Retrieves the translations from the JSON-file. * * @return array Array with the translations. */ protected function get_translations_from_file() { $file = WPSEO_PATH . 'languages/yoast-components-' . $this->locale . '.json'; if ( file_exists( $file ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Retrieving a local file. $file = file_get_contents( $file ); if ( is_string( $file ) && $file !== '' ) { return json_decode( $file, true ); } } return []; } } components/interface-component.php 0000644 00000001174 15154772352 0013420 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Config Component interface. */ interface WPSEO_Config_Component { /** * Get onboarding wizard component identifier. * * @return string */ public function get_identifier(); /** * Get onboarding wizard component data. * * @return mixed */ public function get_data(); /** * Save changes. * * @param array $data Data provided by the API. * * @return mixed */ public function set_data( $data ); /** * Get onboarding wizard component field. * * @return WPSEO_Config_Field */ public function get_field(); } components/class-component-mailchimp-signup.php 0000644 00000003077 15154772352 0016035 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Represents the mailchimp signup components. */ class WPSEO_Config_Component_Mailchimp_Signup implements WPSEO_Config_Component { /** * The name of the mailchimp signup meta key. * * @var string */ const META_NAME = 'wpseo-has-mailchimp-signup'; /** * Gets the component identifier. * * @return string */ public function get_identifier() { return 'MailchimpSignup'; } /** * Gets the field. * * @return WPSEO_Config_Field_Mailchimp_Signup */ public function get_field() { return new WPSEO_Config_Field_Mailchimp_Signup(); } /** * Get the data for the field. * * @return mixed */ public function get_data() { $data = [ 'hasSignup' => $this->has_mailchimp_signup(), ]; return $data; } /** * Save data. * * @param array $data Data containing changes. * * @return mixed */ public function set_data( $data ) { $has_saved = false; if ( ! empty( $data['hasSignup'] ) ) { // Saves the user meta. update_user_meta( get_current_user_id(), self::META_NAME, true ); $has_saved = ( $data['hasSignup'] === $this->has_mailchimp_signup() ); } // Collect results to return to the configurator. $results = [ 'hasSignup' => $has_saved, ]; return $results; } /** * 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(), self::META_NAME, true ); return ( ! empty( $user_meta ) ); } } components/class-component-suggestions.php 0000644 00000010016 15154772352 0015130 0 ustar 00 <?php /** * WPSEO plugin file. * * @package WPSEO\Admin\ConfigurationUI */ /** * Represents the configuration suggestions component. */ class WPSEO_Config_Component_Suggestions implements WPSEO_Config_Component { /** * Gets the component identifier. * * @return string */ public function get_identifier() { return 'Suggestions'; } /** * Gets the field. * * @return WPSEO_Config_Field */ public function get_field() { $field = new WPSEO_Config_Field_Suggestions(); // Only show Premium upsell when we are not inside a Premium install. if ( ! YoastSEO()->helpers->product->is_premium() ) { $field->add_suggestion( /* translators: %s resolves to Yoast SEO Premium */ sprintf( __( 'Outrank the competition with %s', 'wordpress-seo' ), 'Yoast SEO Premium' ), /* translators: %1$s resolves to Yoast SEO Premium */ sprintf( __( 'Do you want to outrank your competition? %1$s gives you awesome additional features that\'ll help you to set up your SEO strategy like a professional. Add synonyms and related keywords, use our Premium SEO analysis, the redirect manager and our internal linking tool. %1$s will also give you access to premium support.', 'wordpress-seo' ), 'Yoast SEO Premium' ), [ 'label' => __( 'Upgrade to Premium', 'wordpress-seo' ), 'type' => 'primary', 'href' => WPSEO_Shortlinker::get( 'https://yoa.st/wizard-suggestion-premium' ), ], [ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/video-yoast-seo-premium' ), 'title' => sprintf( /* translators: %1$s expands to Yoast SEO Premium. */ __( '%1$s video', 'wordpress-seo' ), 'Yoast SEO Premium' ), ] ); } $field->add_suggestion( __( 'Find out what words your audience uses to find you', 'wordpress-seo' ), sprintf( /* translators: %1$s resolves to Keyword research training */ __( 'Keyword research is essential in any SEO strategy. You decide the search terms you want to be found for, and figure out what words your audience uses to find you. Great keyword research tells you what content you need to start ranking for the terms you want to rank for. Make sure your efforts go into the keywords you actually have a chance at ranking for! The %1$s walks you through this process, step by step.', 'wordpress-seo' ), 'Keyword research training' ), [ 'label' => 'Keyword research training', 'type' => 'link', 'href' => WPSEO_Shortlinker::get( 'https://yoa.st/3lg' ), ], [ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/3lf' ), 'title' => sprintf( /* translators: %1$s expands to Keyword research training. */ __( '%1$s video', 'wordpress-seo' ), 'Keyword research training' ), ] ); // When we are running in Yoast SEO Premium and don't have Local SEO installed, show Local SEO as suggestion. if ( YoastSEO()->helpers->product->is_premium() && ! defined( 'WPSEO_LOCAL_FILE' ) ) { $field->add_suggestion( __( 'Attract more customers near you', 'wordpress-seo' ), /* translators: %1$s resolves to Local SEO */ sprintf( __( 'If you want to outrank the competition in a specific town or region, check out our %1$s plugin! You’ll be able to easily insert Google maps, opening hours, contact information and a store locator. Besides that %1$s helps you to improve the usability of your contact page.', 'wordpress-seo' ), 'Local SEO' ), [ 'label' => 'Local SEO', 'type' => 'link', 'href' => WPSEO_Shortlinker::get( 'https://yoa.st/wizard-suggestion-local-seo' ), ], [ 'url' => WPSEO_Shortlinker::get( 'https://yoa.st/video-localseo' ), 'title' => sprintf( /* translators: %1$s expands to Local SEO. */ __( '%1$s video', 'wordpress-seo' ), 'Local SEO' ), ] ); } return $field; } /** * Get the data for the field. * * @return array */ public function get_data() { return []; } /** * Save data. * * @param array $data Data containing changes. * * @return bool */ public function set_data( $data ) { return true; } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка