Yoast_GA_Dashboards_Api_Options

Dashboards API options.

Defined (1)

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

/admin/dashboards/class-admin-dashboards-api-options.php  
  1. class Yoast_GA_Dashboards_Api_Options { 
  2.  
  3. /** 
  4. * Store this instance 
  5. * @var null 
  6. */ 
  7. private static $instance = null; 
  8.  
  9. /** 
  10. * @var string $access_token Store the access token 
  11. */ 
  12. private $access_token; 
  13.  
  14. /** 
  15. * @var array $options Store the options 
  16. */ 
  17. private $options; 
  18.  
  19. /** 
  20. * Construct on the dashboards class for GA 
  21. */ 
  22. protected function __construct() { 
  23. $this->set_options(); 
  24.  
  25. /** 
  26. * Get the instance 
  27. * @return Yoast_GA_Dashboards 
  28. */ 
  29. public static function get_instance() { 
  30. if ( is_null( self::$instance ) ) { 
  31. self::$instance = new self(); 
  32.  
  33. return self::$instance; 
  34.  
  35. /** 
  36. * Set the API options 
  37. */ 
  38. public function set_options() { 
  39. $this->options = Yoast_Google_Analytics::get_instance()->get_options(); 
  40.  
  41. $this->set_access_token(); 
  42.  
  43. /** 
  44. * Set the access token if we have one 
  45. */ 
  46. private function set_access_token() { 
  47. if ( isset( $this->options['ga_oauth']['access_token']['oauth_token'] ) && isset( $this->options['ga_oauth']['access_token']['oauth_token_secret'] ) ) { 
  48. $this->access_token = $this->options['ga_oauth']['access_token']; 
  49.  
  50. /** 
  51. * Get the API options 
  52. * @return mixed 
  53. */ 
  54. public function get_options() { 
  55. return $this->options; 
  56.  
  57. /** 
  58. * Get the access token from the options API, false on fail 
  59. * @return bool 
  60. */ 
  61. public function get_access_token() { 
  62. if ( ! empty( $this->access_token ) ) { 
  63. return $this->access_token; 
  64. else { 
  65. return false; 
  66.