WPSEO_Config_Field_Site_Name

Class WPSEO_Config_Field_Site_Name.

Defined (1)

The class is defined in the following location(s).

/admin/config-ui/fields/class-field-site-name.php  
  1. class WPSEO_Config_Field_Site_Name extends WPSEO_Config_Field { 
  2.  
  3. /** 
  4. * WPSEO_Config_Field_Site_Name constructor. 
  5. */ 
  6. public function __construct() { 
  7. parent::__construct( 'siteName', 'Input' ); 
  8.  
  9. $this->set_property( 'label', __( 'Website name', 'wordpress-seo' ) ); 
  10. $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' ) ); 
  11.  
  12. /** 
  13. * Set adapter 
  14. * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to register lookup on. 
  15. */ 
  16. public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { 
  17. $adapter->add_custom_lookup( 
  18. $this->get_identifier(),  
  19. array( $this, 'get_data' ),  
  20. array( $this, 'set_data' ) 
  21. ); } 
  22.  
  23. /** 
  24. * Get the data from the stored options. 
  25. * @return null|string 
  26. */ 
  27. public function get_data() { 
  28. $option = WPSEO_Options::get_option( 'wpseo' ); 
  29. if ( ! empty( $option['website_name'] ) ) { 
  30. return $option['website_name']; 
  31.  
  32. return get_bloginfo( 'name' ); 
  33.  
  34. /** 
  35. * Set the data in the options. 
  36. * @param {string} $data The data to set for the field. 
  37. * @return bool Returns true or false for successful storing the data. 
  38. */ 
  39. public function set_data( $data ) { 
  40. $value = $data; 
  41.  
  42. $option = WPSEO_Options::get_option( 'wpseo' ); 
  43. $option['website_name'] = $value; 
  44.  
  45. update_option( 'wpseo', $option ); 
  46.  
  47. // Check if everything got saved properly. 
  48. $saved_option = WPSEO_Options::get_option( 'wpseo' ); 
  49.  
  50. return ( $saved_option['website_name'] === $option['website_name'] );