WPSEO_Configuration_Components

Class WPSEO_Configuration_Components.

Defined (1)

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

/admin/config-ui/class-configuration-components.php  
  1. class WPSEO_Configuration_Components { 
  2.  
  3. /** @var WPSEO_Config_Component[] List of registered components */ 
  4. protected $components = array(); 
  5.  
  6. /** @var WPSEO_Configuration_Options_Adapter Adapter */ 
  7. protected $adapter; 
  8.  
  9. /** 
  10. * Add default components. 
  11. */ 
  12. public function initialize() { 
  13. $this->add_component( new WPSEO_Config_Component_Connect_Google_Search_Console() ); 
  14. $this->add_component( new WPSEO_Config_Component_Mailchimp_Signup() ); 
  15. $this->add_component( new WPSEO_Config_Component_Configuration_Choices() ); 
  16. $this->add_component( new WPSEO_Config_Component_Suggestions() ); 
  17.  
  18. /** 
  19. * Add a component 
  20. * @param WPSEO_Config_Component $component Component to add. 
  21. */ 
  22. public function add_component( WPSEO_Config_Component $component ) { 
  23. $this->components[] = $component; 
  24.  
  25. /** 
  26. * Sets the storage to use. 
  27. * @param WPSEO_Configuration_Storage $storage Storage to use. 
  28. */ 
  29. public function set_storage( WPSEO_Configuration_Storage $storage ) { 
  30. $this->set_adapter( $storage->get_adapter() ); 
  31.  
  32. foreach ( $this->components as $component ) { 
  33. $storage->add_field( $component->get_field() ); 
  34.  
  35. /** 
  36. * Sets the adapter to use. 
  37. * @param WPSEO_Configuration_Options_Adapter $adapter Adapter to use. 
  38. */ 
  39. public function set_adapter( WPSEO_Configuration_Options_Adapter $adapter ) { 
  40. $this->adapter = $adapter; 
  41.  
  42. foreach ( $this->components as $component ) { 
  43. $adapter->add_custom_lookup( 
  44. $component->get_field()->get_identifier(),  
  45. array( 
  46. $component,  
  47. 'get_data',  
  48. ),  
  49. array( 
  50. $component,  
  51. 'set_data',  
  52. );