-
Notifications
You must be signed in to change notification settings - Fork 0
/
clue-client.php
executable file
·110 lines (94 loc) · 2.97 KB
/
clue-client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* Plugin entry point.
*
* @package Clue_Client
* @author Aaron Arney <[email protected]>
* @link https://leapsparkagency.com
* @since 1.0.0
*
* @wordpress-plugin
* Plugin Name: Clue Client
* Plugin URI: https://leapsparkagency.com
* Description: The client companion for the Clue event log application.
* Version: 1.3.0
* Author: Leap Spark Agency
* Author URI: https://leapsparkagency.com
* License: MS Reference
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: clue-client
* Domain Path: /languages
*/
namespace Clue;
if ( ! defined( 'WPINC' ) ) {
die();
}
if ( version_compare( phpversion(), '7.0.22', '<' ) ) {
echo 'Clue Client requires PHP version 7.0.22 or greater.';
die();
}
define( 'CLUE_CLIENT', '1.3.0' );
// TODO: Edit this with your endpoint
define( 'CLUE_API_ENDPOINT', 'https://clue.localtunel.me/api/v1/event' );
register_activation_hook( __FILE__, function () {
require_once plugin_dir_path( __FILE__ ) . 'core/activator.class.php';
Core\Activator::activate();
} );
register_deactivation_hook( __FILE__, function () {
require_once plugin_dir_path( __FILE__ ) . 'core/deactivator.class.php';
Core\Deactivator::deactivate();
} );
/**
* Autoloading strategy for plugin classes.
*
* The classes will be called in the format of a fully qualified namespace, such as:
*
* Clue\Core\Triggers\User
*
* In order to fetch the class a few things have to be in place:
* [1] First of all we need to make sure we are only trying to load classes pertaining to this namespace
* or else this loader will try and load WordPress classes as well.
* [2] The folder structure needs to match the namespace structure. We have to strip `Clue` to match ours.
* [3] Next, to appease Linux the path has to be lowercase.
* [4] Lastly, we need to append `class` to the file name.
*
* @since 1.1.0
*/
spl_autoload_register( function ( $class ) {
// [1]
if ( strpos( $class, 'Clue' ) !== false ) {
$remove_prepend = str_replace( 'Clue\\', '', $class ); // [1]
$path = str_replace('\\', '/', strtolower( $remove_prepend ) ); // [2]
include_once plugin_dir_path( __FILE__ ) . $path . '.class.php'; // [3]
}
} );
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 1.0.0
*/
function run_clue_client() {
$triggers = array(
'Category',
'Core',
'Editor',
'Export',
'Import',
'Media',
'Menu',
'Option',
'Plugin',
'Post',
'Theme',
'User',
);
$Http = new Core\Utils\Http();
$Papertrail = new Core\Utils\Papertrail( $Http );
$plugin = new Core\Client( new Core\Loader(), $Papertrail, $triggers );
$plugin->run();
}
run_clue_client();