| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WPGetAPI |
| 4 |
* Plugin URI: https://wordpress.org/plugins/wpgetapi/ |
| 5 |
* Description: A plugin to get data from external API's. |
| 6 |
* Author: wpgetapi |
| 7 |
* Author URI: https://wpgetapi.com/ |
| 8 |
* Version: 1.0.0 |
| 9 |
* Text Domain: wpgetapi |
| 10 |
* Domain Path: /languages/ |
| 11 |
* License: GPL2 or later |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
// Exit if accessed directly. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 17 |
|
| 18 |
/** |
| 19 |
* Main Class. |
| 20 |
* |
| 21 |
* @since 1.0.0 |
| 22 |
*/ |
| 23 |
final class WpGetApi { |
| 24 |
|
| 25 |
/** |
| 26 |
* @var The one true instance |
| 27 |
* @since 1.0.0 |
| 28 |
*/ |
| 29 |
protected static $_instance = null; |
| 30 |
|
| 31 |
public $version = '1.0.0'; |
| 32 |
|
| 33 |
/** |
| 34 |
* Main Instance. |
| 35 |
*/ |
| 36 |
public static function instance() { |
| 37 |
if ( is_null( self::$_instance ) ) { |
| 38 |
self::$_instance = new self(); |
| 39 |
} |
| 40 |
return self::$_instance; |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Throw error on object clone. |
| 45 |
* |
| 46 |
* @since 1.0.0 |
| 47 |
* @access protected |
| 48 |
* @return void |
| 49 |
*/ |
| 50 |
public function __clone() { |
| 51 |
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wpgetapi' ), '1.0.0' ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Disable unserializing of the class. |
| 56 |
* @since 1.0.0 |
| 57 |
*/ |
| 58 |
public function __wakeup() { |
| 59 |
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'wpgetapi' ), '1.0.0' ); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* |
| 64 |
* @since 1.0.0 |
| 65 |
*/ |
| 66 |
public function __construct() { |
| 67 |
|
| 68 |
$this->define_constants(); |
| 69 |
$this->includes(); |
| 70 |
|
| 71 |
do_action( 'wpgetapi_loaded' ); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Define Constants. |
| 76 |
* @since 1.0.0 |
| 77 |
*/ |
| 78 |
private function define_constants() { |
| 79 |
$this->define( 'WPGETAPIDIR',plugin_dir_path( __FILE__ ) ); |
| 80 |
$this->define( 'WPGETAPIURL',plugin_dir_url( __FILE__ ) ); |
| 81 |
$this->define( 'WPGETAPIBASENAME', plugin_basename( __FILE__ ) ); |
| 82 |
$this->define( 'WPGETAPIVERSION', $this->version ); |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Define constant if not already set. |
| 87 |
* @since 1.0.0 |
| 88 |
*/ |
| 89 |
private function define( $name, $value ) { |
| 90 |
if ( ! defined( $name ) ) { |
| 91 |
define( $name, $value ); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
/** |
| 97 |
* Include required files. |
| 98 |
* @since 1.0.0 |
| 99 |
*/ |
| 100 |
public function includes() { |
| 101 |
|
| 102 |
require_once ( WPGETAPIDIR . '/lib/cmb2/init.php' ); |
| 103 |
|
| 104 |
include_once ( WPGETAPIDIR . 'includes/class-encryption.php' ); |
| 105 |
include_once ( WPGETAPIDIR . 'includes/class-admin-options.php' ); |
| 106 |
|
| 107 |
include_once ( WPGETAPIDIR . 'includes/functions.php' ); |
| 108 |
include_once ( WPGETAPIDIR . 'includes/class-enqueues.php' ); |
| 109 |
include_once ( WPGETAPIDIR . 'includes/class-api.php' ); |
| 110 |
|
| 111 |
include_once ( WPGETAPIDIR . 'frontend/functions.php' ); |
| 112 |
|
| 113 |
} |
| 114 |
|
| 115 |
} |
| 116 |
|
| 117 |
|
| 118 |
/** |
| 119 |
* Run the plugin. |
| 120 |
*/ |
| 121 |
function WpGetApi() { |
| 122 |
return WpGetApi::instance(); |
| 123 |
} |
| 124 |
WpGetApi(); |