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