/wp-content/plugins/wordpress-seo/vendor/yoast/api-libs/class-api-libs.php

https://bitbucket.org/carloskikea/helpet · PHP · 49 lines · 16 code · 7 blank · 26 comment · 2 complexity · 35262d1c9fd3d5f258c535e19feb8ecc MD5 · raw file

  1. <?php
  2. /**
  3. * Include this class to use the Yoast_Api_Libs, you can include this as a submodule in your project
  4. * and you just have to autoload this class
  5. *
  6. *
  7. * NAMING CONVENTIONS
  8. * - Register 'oauth' by using $this->register_api_library()
  9. * - Create folder 'oauth'
  10. * - Create file 'class-api-oauth.php'
  11. * - Class name should be 'Yoast_Api_Oauth'
  12. */
  13. class Yoast_Api_Libs {
  14. /**
  15. * Current version number of the API-libs
  16. */
  17. const version = '2.0';
  18. /**
  19. * Check if minimal required version is met.
  20. *
  21. * @param string $minimal_required_version
  22. *
  23. * @throws Exception
  24. */
  25. public function __construct( $minimal_required_version ) {
  26. $this->load_google();
  27. if ( ! version_compare( self::version, $minimal_required_version, '>=' )) {
  28. throw new Exception( 'required_version' );
  29. }
  30. }
  31. /**
  32. * Loading the google api library which will set the autoloader
  33. */
  34. private function load_google() {
  35. if ( ! class_exists('Yoast_Api_Google', false) ) {
  36. // Require the file
  37. require_once dirname( __FILE__ ) . '/' . 'class-api-google.php';
  38. // Initialize the Google API Class to set the autoloader
  39. new Yoast_Api_Google();
  40. }
  41. }
  42. }