-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclass.wmk.php
352 lines (333 loc) · 10.2 KB
/
class.wmk.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
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?php
/**
* Class to initiate all hooks for Wordpress Media Kit Plugin.
*
* @package Wordpress Media Kit
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @author Daniel Gundi
*/
if ( ! defined( 'ABSPATH' ) ) {
header('HTTP/1.0 403 Forbidden');
exit;
}
class WP_Media_Kit
{
private static $instance = null;
public static $magazine_cover_options_au;
public static function get_instance() {
if ( null == self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
private function __construct()
{
add_action('admin_enqueue_scripts', array($this,'load_backend_resources'));
add_action("admin_init", array($this,'admin_init'));
add_action("init", array($this,'register_mediakit_post_type'));
add_action('admin_menu', array($this,'add_new_menu_items'));
}
public function load_backend_resources() {
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');
wp_enqueue_style('wmk-admin-styles', plugin_dir_url(__FILE__) . 'static/css/admin-styles.css');
wp_enqueue_script('wmk-admin-scripts', plugin_dir_url(__FILE__) . 'static/js/admin-scripts.js', array('jquery','jquery-ui-droppable','jquery-ui-draggable', 'jquery-ui-sortable'));
wp_enqueue_media ();
wp_enqueue_script('moment-js', plugin_dir_url(__FILE__) . 'static/js/moment.js', array('jquery','jquery-ui-droppable','jquery-ui-draggable', 'jquery-ui-sortable'));
}
public function add_new_menu_items() {
add_submenu_page(
"edit.php?post_type=mediakit",
"Magazine Covers",
"Magazine Covers",
"manage_options",
"magazinecovers-options",
array('WMK_Magazine_Covers','display_magazinecovers_page'),
"dashicons-admin-page",
23
);
}
public function admin_init() {
$this->run_plugin();
WMK_Magazine_Covers::init_magazinecovers_page();
}
public function register_mediakit_post_type() {
$post_labels = array(
'name' => 'Media Kit', // Rename these to suit
'menu_name' => 'Media Kit',
'singular_name' => 'Media Kit',
'add_new' => 'Add '. 'Media Kit Page',
'add_new_item' => 'Add '. 'Media Kit Page',
'edit' => 'Edit',
'edit_item' => 'Edit Media Kit Page',
'new_item' => 'New Media Kit Page',
'view' => 'View Media Kit',
'view_item' => 'View Media Kit Page',
'search_items' => 'Search Media Kit Pages',
'not_found' => 'No Media Kit Pages',
'not_found_in_trash' => 'No Media Kit Pages found in Trash'
);
$posts_args = array(
'labels' => $post_labels,
'public' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
'has_archive' => true,
'supports' => array(
'title',
),
'menu_position' => 1,
'menu_icon' => 'dashicons-admin-post',
'taxonomies' => array('mediakit_category','post_tag')
);
register_post_type('mediakit', $posts_args);
register_taxonomy( 'mediakit-category', 'mediakit', array( 'hierarchical' => true, 'label' => 'Media Kit Categories', 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'mediakit/category','with_front' => FALSE )) );
flush_rewrite_rules();
}
private function run_plugin() {
$prefix = 'wmk_meta_';
$mediakit_sections = array(
array(
'id' => 'globalbrand',
'desc' => 'THE GLOBAL BUSINESS BRAND','mediakit',
'page' => 'mediakit'
),
array(
'id' => 'ournumbers',
'desc' => 'OUR NUMBERS',
'page' => 'mediakit'
),
array(
'id' => 'ouraudience',
'desc' => 'OUR AUDIENCE',
'page' => 'mediakit'
),
array(
'id' => 'executiveawards',
'desc' => 'Executive of the Year Awards',
'page' => 'mediakit'
),
array(
'id' => 'inspire',
'desc' => 'Inspire',
'page' => 'mediakit'
),
array(
'id' => 'innovate',
'desc' => 'Innovate',
'page' => 'mediakit'
),
array(
'id' => 'invest',
'desc' => 'Invest',
'page' => 'mediakit'
),
array(
'id' => 'indulge',
'desc' => 'Indulge',
'page' => 'mediakit'
),
array(
'id' => 'editorialcalendar',
'desc' => 'Editorial Calendar',
'page' => 'mediakit'
),
array(
'id' => 'displayrates',
'desc' => 'Display Rates',
'page' => 'mediakit'
),
array(
'id' => 'digitalrates',
'desc' => 'Digital Rates',
'page' => 'mediakit'
),
array(
'id' => 'videointerviews',
'desc' => 'Video Interviews',
'page' => 'mediakit'
),
);
$mediakit_fields = array(
array (
'id' => $prefix.'globalbrand_enable',
'label' => 'Enabled',
'desc' => 'Enable Global Brand Section',
'type' => 'checkbox',
'metabox' => 'globalbrand'
),
array (
'id' => $prefix.'globalbrand_main',
'label' => 'Editors Global Brand Content',
'desc' => 'Editors Global Brand Content',
'type' => 'editor',
'metabox' => 'globalbrand'
),
array (
'id' => $prefix.'ournumbers_enable',
'label' => 'Enabled',
'desc' => 'Enable Our Numbers Section',
'type' => 'checkbox',
'metabox' => 'ournumbers'
),
array (
'id' => $prefix.'ournumbers_main',
'label' => 'Our Numbers Main Content',
'desc' => 'Our Numbers Main Content',
'type' => 'editor',
'metabox' => 'ournumbers'
),
array (
'id' => $prefix.'ouraudience_enable',
'label' => 'Enabled',
'desc' => 'Enable Our Audience Section',
'type' => 'checkbox',
'metabox' => 'ouraudience'
),
array (
'id' => $prefix.'ouraudience_main',
'label' => 'Our Audience Main Content',
'desc' => 'Our Audience Main Content',
'type' => 'editor',
'metabox' => 'ouraudience'
),
array (
'id' => $prefix.'executiveawards_enable',
'label' => 'Enabled',
'desc' => 'Enable Executive Awards Section',
'type' => 'checkbox',
'metabox' => 'executiveawards'
),
array (
'id' => $prefix.'executiveawards_main',
'label' => 'Executive Awards Main Content',
'desc' => 'Executive Awards Main Content',
'type' => 'editor',
'metabox' => 'executiveawards'
),
array (
'id' => $prefix.'inspire_enable',
'label' => 'Enabled',
'desc' => 'Enable Inspire Section',
'type' => 'checkbox',
'metabox' => 'inspire'
),
array (
'id' => $prefix.'inspire_main',
'label' => 'Inspire Main Content',
'desc' => 'Inspire & Mission Main Content',
'type' => 'editor',
'metabox' => 'inspire'
),
array (
'id' => $prefix.'innovate_enable',
'label' => 'Enabled',
'desc' => 'Innovate Section',
'type' => 'checkbox',
'metabox' => 'innovate'
),
array (
'id' => $prefix.'innovate_main',
'label' => 'Innovate Main Content',
'desc' => 'Innovate Main Content',
'type' => 'editor',
'metabox' => 'innovate'
),
array (
'id' => $prefix.'invest_enable',
'label' => 'Enabled',
'desc' => 'Enable Invest Section',
'type' => 'checkbox',
'metabox' => 'invest'
),
array (
'id' => $prefix.'invest_main',
'label' => 'Invest Main Content',
'desc' => 'Invest Main Content',
'type' => 'editor',
'metabox' => 'invest'
),
array (
'id' => $prefix.'indulge_enable',
'label' => 'Enabled',
'desc' => 'Enable Indulge Section',
'type' => 'checkbox',
'metabox' => 'indulge'
),
array (
'id' => $prefix.'indulge_main',
'label' => 'Indulge Main Content',
'desc' => 'Indulge Main Content',
'type' => 'editor',
'metabox' => 'indulge'
),
array (
'id' => $prefix.'editorialcalendar_enable',
'label' => 'Enabled',
'desc' => 'Enable Editorial Calendar Section',
'type' => 'checkbox',
'metabox' => 'editorialcalendar'
),
array (
'id' => $prefix.'editorialcalendar_main',
'label' => 'Editorial Calendar Main Content',
'desc' => 'Editorial Calendar Main Content',
'type' => 'editor',
'metabox' => 'editorialcalendar'
),
array (
'id' => $prefix.'displayrates_enable',
'label' => 'Enabled',
'desc' => 'Enable Display Rates Section',
'type' => 'checkbox',
'metabox' => 'displayrates'
),
array (
'id' => $prefix.'displayrates_main',
'label' => 'Display Rates Main Content',
'desc' => 'Display Rates Main Content',
'type' => 'editor',
'metabox' => 'displayrates'
),
array (
'id' => $prefix.'digitalrates_enable',
'label' => 'Enabled',
'desc' => 'Enable Digital Rates Section',
'type' => 'checkbox',
'metabox' => 'digitalrates'
),
array (
'id' => $prefix.'digitalrates_main',
'label' => 'Digital Rates Main Content',
'desc' => 'Digital Rates Main Content',
'type' => 'editor',
'metabox' => 'digitalrates'
),
array (
'id' => $prefix.'videointerviews_enable',
'label' => 'Enabled',
'desc' => 'Enable Video Interviews Section',
'type' => 'checkbox',
'metabox' => 'videointerviews'
),
array (
'id' => $prefix.'videointerviews_main',
'label' => 'Video Interviews Main Content',
'desc' => 'Video Interviews Main Content',
'type' => 'editor',
'metabox' => 'videointerviews'
),
);
$mediakit_meta = new WMK_Post_Meta($mediakit_fields);
foreach ($mediakit_sections as $section) {
$mediakit_meta->add_meta_box($section['id'],$section['desc'],$section['page']);
}
}
public static function view($name,$args) {
$magazine_cover_options_au = $args;
$file = IW_WMK_ROOT_PATH . '/views/' . $name . '.php';
include($file);
}
}