1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* LSX_Sharing |
4
|
|
|
* |
5
|
|
|
* @package lsx-sharing |
6
|
|
|
*/ |
|
|
|
|
7
|
|
|
namespace lsx\sharing; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* LSX Sharing class. |
11
|
|
|
* |
12
|
|
|
* @package lsx-sharing |
13
|
|
|
*/ |
14
|
|
|
class Sharing { |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Holds class instance |
19
|
|
|
* |
20
|
|
|
* @since 1.0.0 |
21
|
|
|
* |
22
|
|
|
* @var object \lsx\search\Sharing() |
23
|
|
|
*/ |
24
|
|
|
protected static $instance = null; |
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Holds class instance |
28
|
|
|
* |
29
|
|
|
* @since 1.0.0 |
30
|
|
|
* |
31
|
|
|
* @var object \lsx\search\classes\Admin() |
32
|
|
|
*/ |
33
|
|
|
public $admin = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* If we are using the new options or not. |
37
|
|
|
* |
38
|
|
|
* @var boolean |
39
|
|
|
*/ |
40
|
|
|
public $is_new_options = false; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* The options for the plugin. |
44
|
|
|
* |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
public $options = array(); |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Constructor. |
51
|
|
|
*/ |
52
|
|
|
public function __construct() { |
|
|
|
|
53
|
|
|
add_action('init', array( $this, 'set_options' ), 50); |
|
|
|
|
54
|
|
|
$this->load_vendors(); |
55
|
|
|
$this->load_includes(); |
56
|
|
|
$this->load_classes(); |
57
|
|
|
} |
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Return an instance of this class. |
61
|
|
|
* |
62
|
|
|
* @since 1.0.0 |
63
|
|
|
* |
64
|
|
|
* @return object \lsx\member_directory\search\Admin() A single instance of this class. |
65
|
|
|
*/ |
66
|
|
|
public static function get_instance() { |
67
|
|
|
// If the single instance hasn't been set, set it now. |
|
|
|
|
68
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
69
|
|
|
self::$instance = new self(); |
70
|
|
|
} |
|
|
|
|
71
|
|
|
return self::$instance; |
72
|
|
|
} |
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Loads the plugin functions. |
76
|
|
|
*/ |
77
|
|
|
private function load_vendors() { |
78
|
|
|
// Configure custom fields. |
|
|
|
|
79
|
|
|
if ( ! class_exists('CMB2') ) { |
|
|
|
|
80
|
|
|
include_once LSX_SHARING_PATH . 'vendor/CMB2/init.php'; |
81
|
|
|
} |
82
|
|
|
} |
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Loads the plugin functions. |
85
|
|
|
*/ |
86
|
|
|
private function load_includes() { |
87
|
|
|
include_once LSX_SHARING_PATH . '/includes/functions.php'; |
|
|
|
|
88
|
|
|
} |
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Loads the plugin functions. |
91
|
|
|
*/ |
92
|
|
|
private function load_classes() { |
93
|
|
|
include_once LSX_SHARING_PATH . '/classes/class-admin.php'; |
|
|
|
|
94
|
|
|
global $lsx_sharing_admin; |
95
|
|
|
$this->admin = \lsx\sharing\classes\Admin::get_instance(); |
96
|
|
|
$lsx_sharing_admin; |
97
|
|
|
|
98
|
|
|
include_once LSX_SHARING_PATH . '/classes/class-frontend.php'; |
99
|
|
|
$this->frontend = \lsx\sharing\classes\Frontend::get_instance(); |
|
|
|
|
100
|
|
|
global $lsx_sharing; |
101
|
|
|
$lsx_sharing = $this->frontend->output; |
102
|
|
|
|
103
|
|
|
include_once LSX_SHARING_PATH . '/classes/deprecated/class-lsx-sharing.php'; |
104
|
|
|
} |
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Set options. |
107
|
|
|
*/ |
108
|
|
|
public function set_options() { |
109
|
|
|
if ( function_exists('tour_operator') ) { |
|
|
|
|
110
|
|
|
$this->options = get_option('_lsx-to_settings', false); |
|
|
|
|
111
|
|
|
} else { |
|
|
|
|
112
|
|
|
$this->options = get_option('_lsx_settings', false); |
|
|
|
|
113
|
|
|
|
114
|
|
|
if ( false === $this->options ) { |
|
|
|
|
115
|
|
|
$this->options = get_option('_lsx_lsx-settings', false); |
|
|
|
|
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
$new_options = get_option('lsx-sharing-settings'); |
|
|
|
|
120
|
|
|
if ( ! empty($new_options) ) { |
|
|
|
|
121
|
|
|
if ( '' !== $new_options && false !== $new_options ) { |
|
|
|
|
122
|
|
|
$this->is_new_options = true; |
123
|
|
|
$this->options = $new_options; |
124
|
|
|
} |
125
|
|
|
} |
126
|
|
|
} |
|
|
|
|
127
|
|
|
} |
128
|
|
|
|