-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspotim-comments.php
99 lines (83 loc) · 2.35 KB
/
spotim-comments.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
<?php
/**
* @package Spot
* @version 0.1
*/
/*
Plugin Name: Spot.IM
Plugin URI: http://spot.im
Description: Description for wp-spotim should be here
Author: Maor Chasen
Version: 1.0.4
Author URI: http://maorchasen.com/
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
final class WP_SpotIM {
private static $_instance;
const AUTH_OPTION = 'spotim_auth';
/**
* @return WP_SpotIM
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self;
self::$_instance->setup_constants();
self::$_instance->includes();
self::$_instance->dependencies();
}
return self::$_instance;
}
private function dependencies() {
$this->admin = new SpotIM_Admin;
$this->api = new SpotIM_API_Dispatcher;
// setup AJAX
$this->register_default_hooks();
// setup front-end
if ( ! is_admin() ) {
SpotIM_Frontend::setup();
}
}
/**
* Setup plugin constants
*
* @access private
* @since 1.0.4
* @return void
*/
private function setup_constants() {
// Plugin version
if ( ! defined( 'SPOTIM_AUTH_OPTION' ) ) {
define( 'SPOTIM_AUTH_OPTION', 'spotim_auth' );
}
}
private function includes() {
require_once 'inc/spotim-core-functions.php';
require_once 'inc/class-spotim-export.php';
require_once 'inc/class-spotim-export-conversation.php';
require_once 'inc/class-spotim-sync.php';
require_once 'inc/class-spotim-admin.php';
require_once 'inc/class-spotim-util.php';
require_once 'inc/class-spotim-frontend.php';
require_once 'inc/class-spotim-http-request.php';
require_once 'inc/class-spotim-api-base.php';
require_once 'inc/class-spotim-api-dispatcher.php';
$this->spotim_api = include( 'inc/class-spotim-api.php' );
}
public function register_default_hooks() {
// AJAX for JSON Export
add_action( 'wp_ajax_spot-generate-json', array( 'SpotIM_Export', 'generate_json' ) );
// create_spot, For when post is published
// $this->api->register_conversation(1173); die;
add_action( 'publish_post', array( $this->api, 'register_conversation' ) );
}
public static function activation_hook() {
// create a spot via API
self::instance()->api->initiate_setup();
}
}
function spotim_instance() {
return WP_SpotIM::instance();
}
add_action( 'plugins_loaded', 'spotim_instance' );
register_activation_hook( __FILE__, array( 'WP_SpotIM', 'activation_hook' ) );