cac-addon-pro.php
6.0 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* The Admin Columns Pro plugin class
*
* @since 1.0
*/
class CAC_Addon_Pro {
/**
* Basename of the plugin, retrieved through plugin_basename function
*
* @since 1.0
* @access private
* @var string
*/
private $plugin_basename;
/**
* License manager class instance
*
* @since 1.0
* @access private
* @var Codepress_Licence_Manager_Settings
*/
private $licence_manager;
/**
* @since 3.6
*/
private $network_settings_page;
/**
* @since 1.0
*/
function __construct() {
$this->plugin_basename = plugin_basename( __FILE__ );
$this->define_constants();
// Load modules
$this->init();
// 3rd party integrations
$this->third_party();
// Hooks
add_action( 'init', array( $this, 'localize' ) );
add_action( 'cac/loaded', array( $this, 'init_after_cac_loaded' ) );
add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 1, 2 );
add_action( 'wp_loaded', array( $this, 'after_setup' ) );
add_action( 'network_admin_menu', array( $this, 'network_settings_menu' ) );
}
/**
* Define constants
*
* @since 3.1.2
*/
public function define_constants() {
define( 'CAC_PRO_VERSION', ACP_VERSION );
define( 'CAC_PRO_URL', plugin_dir_url( __FILE__ ) );
define( 'CAC_PRO_DIR', plugin_dir_path( __FILE__ ) );
}
/**
* Handle localization
*
* @since 1.0.1
* @uses load_plugin_textdomain()
*/
public function localize() {
load_plugin_textdomain( 'codepress-admin-columns', false, dirname( $this->plugin_basename ) . '/languages/' );
}
/**
* Fire callbacks for admin columns setup completion
*
* @since 2.2
*/
public function after_setup() {
/**
* Fires when Admin Columns is fully loaded
* Use this for setting up addon functionality
*
* @since 2.0
* @param CPAC $cpac_instance Main Admin Columns plugin class instance
*/
do_action( 'cac/pro/loaded', $this );
}
/**
* General plugin initialization, loading plugin module files
*
* @since 1.0
*/
public function init() {
if ( ! class_exists( 'CAC_Export_Import', false ) ) {
include_once 'classes/export-import/export-import.php';
}
if ( ! class_exists( 'CAC_Addon_Filtering', false ) ) {
include_once 'classes/filtering/filtering.php';
}
if ( ! class_exists( 'CAC_Addon_Sortable', false ) ) {
include_once 'classes/sortable/sortable.php';
}
if ( ! class_exists( 'CAC_Storage_Model_Taxonomy', false ) ) {
include_once 'classes/taxonomy/taxonomy.php';
}
if ( ! class_exists( 'CPAC_Storage_Model_MS_User', false ) ) {
include_once 'classes/ms-user/ms-user.php';
}
if ( ! class_exists( 'CACIE_Addon_InlineEdit', false ) ) {
include_once 'classes/inline-edit/cac-addon-inline-edit.php';
}
if ( ! class_exists( 'CACIE_Addon_Columns', false ) ) {
include_once 'classes/columns/cac-addon-columns.php';
}
}
/**
* Load third party add-ons
*
* @since 3.4.1
*/
public function third_party() {
include_once 'classes/third-party/bbpress.php';
include_once 'classes/third-party/wordpress-seo.php';
}
/**
* Init callback after main plugin (CPAC) has been fully loaded.
*
* @since 1.0
*/
public function init_after_cac_loaded( $cpac ) {
if ( ! class_exists('Codepress_Licence_Manager_Settings') ) {
include_once 'classes/licence-manager-settings.php';
// When used into Admin Columns Pro use it's root path...
$this->licence_manager = new Codepress_Licence_Manager_Settings( ACP_FILE, $cpac, $this );
if ( defined( 'ACP_LICENCE' ) ) {
$this->licence_manager->set_licence_key( ACP_LICENCE );
}
}
}
/**
* @since 1.0
* @see filter:plugin_action_links
*/
public function add_settings_link( $links, $file ) {
if ( ( ! $this->is_cpac_enabled() ) || ( $file != plugin_basename( __FILE__ ) ) ) {
return $links;
}
array_unshift( $links, '<a href="' . admin_url("options-general.php") . '?page=codepress-admin-columns&tab=settings">' . __( 'Settings' ) . '</a>' );
return $links;
}
/**
* Check if main plugin is enabled
*
* @since 1.0.3
*/
public function is_cpac_enabled() {
return class_exists( 'CPAC', false );
}
/**
* Get licence manager
*
* @since 3.1.1
*/
public function get_licence_manager() {
return $this->licence_manager;
}
/**
* @since 3.6
*/
public function get_network_settings_page() {
return $this->network_settings_page;
}
/**
* Add network settings page
*
* @since 3.6
*/
public function network_settings_menu() {
$this->network_settings_page = add_submenu_page( 'settings.php', __( 'Admin Columns Settings', 'codepress-admin-columns' ), __( 'Admin Columns', 'codepress-admin-columns' ), 'manage_admin_columns', 'codepress-admin-columns', array( $this, 'network_display' ), false, 98 );
}
/**
* Displays network settings page
*
* @since 3.6
*/
public function network_display() {
if ( $groups = apply_filters( 'cac/network_settings/groups', array() ) ) : ?>
<div id="cpac" class="wrap">
<h1>Admin Columns</h1>
<table class="form-table cpac-form-table settings">
<tbody>
<?php
if ( $groups ) :
foreach ( $groups as $id => $group ) :
$defaults = array(
'title' => '',
'description' => '',
);
$group = (object) array_merge( $defaults, $group );
?>
<tr>
<th scope="row">
<h3><?php echo $group->title; ?></h3>
<p><?php echo $group->description; ?></p>
</th>
<td class="padding-22">
<?php
// Use this Hook to add additonal fields to the group
do_action( "cac/settings/groups/row={$id}" );
?>
</td>
</tr>
<?php
endforeach;
endif;
?>
</tbody>
</table>
</div>
<?php
endif;
}
}
new CAC_Addon_Pro();