PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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