Post Duplicator - Version 2.3

Version Description

Download this release

Release Info

Developer metaphorcreations
Plugin Icon 128x128 Post Duplicator
Version 2.3
Comparing to
See all releases

Code changes from version 2.2 to 2.3

includes/scripts.php CHANGED
@@ -1,23 +1,22 @@
1
  <?php
2
 
3
- // Load Metaboxer
4
- if( !function_exists('metaboxer_container') ) {
5
-
6
- add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
7
- /**
8
- * Load the metaboxer scripts
9
- *
10
- * @since 1.0
11
- */
12
- function mtphr_post_duplicator_metaboxer_scripts() {
13
 
14
  // Load the style sheet
15
  wp_register_style( 'mtphr-post-duplicator-metaboxer', MTPHR_POST_DUPLICATOR_URL.'/metaboxer/metaboxer.css', false, MTPHR_POST_DUPLICATOR_VERSION );
16
  wp_enqueue_style( 'mtphr-post-duplicator-metaboxer' );
17
 
18
  // Load the jQuery
19
- wp_register_script( 'mtphr-post-duplicator-metaboxer', MTPHR_POST_DUPLICATOR_URL.'/metaboxer/metaboxer.js', array('jquery'), MTPHR_POST_DUPLICATOR_VERSION, true );
20
- wp_enqueue_script( 'mtphr-post-duplicator-metaboxer' );
21
  }
22
  }
23
 
1
  <?php
2
 
3
+ add_action( 'admin_enqueue_scripts', 'mtphr_post_duplicator_metaboxer_scripts' );
4
+ /**
5
+ * Load the metaboxer scripts
6
+ *
7
+ * @since 1.0
8
+ */
9
+ function mtphr_post_duplicator_metaboxer_scripts( $hook ) {
10
+
11
+ if( $hook == 'tools_page_mtphr_post_duplicator_settings_menu' ) {
 
12
 
13
  // Load the style sheet
14
  wp_register_style( 'mtphr-post-duplicator-metaboxer', MTPHR_POST_DUPLICATOR_URL.'/metaboxer/metaboxer.css', false, MTPHR_POST_DUPLICATOR_VERSION );
15
  wp_enqueue_style( 'mtphr-post-duplicator-metaboxer' );
16
 
17
  // Load the jQuery
18
+ //wp_register_script( 'mtphr-post-duplicator-metaboxer', MTPHR_POST_DUPLICATOR_URL.'/metaboxer/metaboxer.js', array('jquery'), MTPHR_POST_DUPLICATOR_VERSION, true );
19
+ //wp_enqueue_script( 'mtphr-post-duplicator-metaboxer' );
20
  }
21
  }
22
 
m4c-postduplicator.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Post Duplicator
4
  Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
5
- Version: 2.2
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  License: GPL2
@@ -30,9 +30,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
 
31
  /**Define Widget Constants */
32
  if ( WP_DEBUG ) {
33
- define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.2-'.time() );
34
  } else {
35
- define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.2' );
36
  }
37
  define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
38
  define ( 'MTPHR_POST_DUPLICATOR_URL', plugins_url().'/post-duplicator' );
2
  /*
3
  Plugin Name: Post Duplicator
4
  Description: Creates functionality to duplicate any and all post types, including taxonomies & custom fields
5
+ Version: 2.3
6
  Author: Metaphor Creations
7
  Author URI: http://www.metaphorcreations.com
8
  License: GPL2
30
 
31
  /**Define Widget Constants */
32
  if ( WP_DEBUG ) {
33
+ define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.3-'.time() );
34
  } else {
35
+ define ( 'MTPHR_POST_DUPLICATOR_VERSION', '2.3' );
36
  }
37
  define ( 'MTPHR_POST_DUPLICATOR_DIR', plugin_dir_path(__FILE__) );
38
  define ( 'MTPHR_POST_DUPLICATOR_URL', plugins_url().'/post-duplicator' );
metaboxer/metaboxer.css CHANGED
@@ -1,30 +1,4 @@
1
- /* Table of Contents
2
-
3
- * Media Uploader
4
- * General
5
- * Fields
6
- * Labels
7
- * Content
8
-
9
- * File
10
- * Lists
11
- * Sorts
12
- * Code
13
- * Radio
14
- * Checkbox
15
- * WYSIWYG
16
- * Farbtastic
17
- * jQuery Slider
18
- * Pattern Select
19
- * Image Select
20
- * Attachments
21
- * Single Image
22
- * Clearfix
23
- * Custom
24
-
25
- */
26
-
27
- /* General
28
  ------------------------------------------------------------ */
29
 
30
  .mtphr-post-duplicator-metaboxer-admin-fields {
@@ -35,13 +9,15 @@
35
  }
36
  .mtphr-post-duplicator-metaboxer-appended {
37
  display: inline;
38
- margin-left: 10px;
 
 
 
 
 
39
  }
40
 
41
-
42
- /* Fields
43
- ------------------------------------------------------------ */
44
-
45
  .mtphr-post-duplicator-metaboxer-field {
46
  margin-bottom: 20px;
47
  }
@@ -51,10 +27,14 @@
51
  .mtphr-post-duplicator-metaboxer-field:last-child {
52
  margin-bottom: 20px;
53
  }
 
 
 
 
 
 
54
 
55
- /* Labels
56
- ------------------------------------------------------------ */
57
-
58
  .mtphr-post-duplicator-metaboxer-label {
59
  vertical-align: top;
60
  width: 20%;
@@ -77,8 +57,7 @@
77
  padding: 0;
78
  }
79
 
80
- /* Content
81
- ------------------------------------------------------------ */
82
  .mtphr-post-duplicator-metaboxer-field-content {
83
  width: 80%;
84
  vertical-align: top;
@@ -93,432 +72,39 @@
93
  width: auto;
94
  }
95
 
96
- /* File
97
- ------------------------------------------------------------ */
98
-
99
- .wp-core-ui .mtphr-post-duplicator-metaboxer-file-upload {
100
- display: none;
101
- }
102
- .mtphr-post-duplicator-metaboxer-file-table {
103
- width: 100%;
104
- }
105
- .mtphr-post-duplicator-metaboxer-file-display a {
106
- display: block;
107
- margin: 0;
108
- padding: 10px;
109
- background: #FEFEFE;
110
- border: 1px solid #EEE;
111
- white-space: normal;
112
- text-decoration: none;
113
-
114
- -webkit-border-radius: 5px;
115
- -moz-border-radius: 5px;
116
- border-radius: 5px;
117
- }
118
- .mtphr-post-duplicator-metaboxer-file-display img {
119
- display: block;
120
- float: left;
121
- margin-right: 10px;
122
- }
123
- .mtphr-post-duplicator-metaboxer-file-display span {
124
- text-decoration: none;
125
- }
126
- .mtphr-post-duplicator-metaboxer-file-delete {
127
- width: 16px;
128
- padding-top: 4px !important;
129
- }
130
- .mtphr-post-duplicator-metaboxer-file-delete a {
131
- display: block;
132
- text-indent: -9999px;
133
- width: 16px;
134
- height: 16px;
135
- background: url(images/minus-circle.png) no-repeat top;
136
- }
137
- .mtphr-post-duplicator-metaboxer-file-delete a:hover {
138
- background-position: 0 -16px;
139
- }
140
-
141
- /* List Item
142
- ------------------------------------------------------------ */
143
-
144
- .mtphr-post-duplicator-metaboxer-list > table {
145
- width: 100%;
146
- }
147
- .mtphr-post-duplicator-metaboxer-list th,
148
- .mtphr-post-duplicator-metaboxer-list td {
149
- text-align: left;
150
- vertical-align: top;
151
- padding: 0 3px;
152
- }
153
- .mtphr-post-duplicator-metaboxer-list input[type="text"],
154
- .mtphr-post-duplicator-metaboxer-list input[type="number"],
155
- .mtphr-post-duplicator-metaboxer-list input[type="email"],
156
- .mtphr-post-duplicator-metaboxer-list input[type="password"],
157
- .mtphr-post-duplicator-metaboxer-list textarea {
158
- width: 100%;
159
- }
160
- .mtphr-post-duplicator-metaboxer-list-item-handle,
161
- .mtphr-post-duplicator-metaboxer-list-item-add,
162
- .mtphr-post-duplicator-metaboxer-list-item-delete {
163
- width: 16px;
164
- padding-top: 4px !important;
165
- }
166
- .mtphr-post-duplicator-metaboxer-list-item-handle span,
167
- .mtphr-post-duplicator-metaboxer-list-item-add a,
168
- .mtphr-post-duplicator-metaboxer-list-item-delete a {
169
- display: block;
170
- text-indent: -9999px;
171
- width: 16px;
172
- height: 16px;
173
- }
174
- .mtphr-post-duplicator-metaboxer-list-item-handle span {
175
- background: url(images/arrow-resize-090.png) no-repeat top;
176
- }
177
- .mtphr-post-duplicator-metaboxer-list-item-add a {
178
- background: url(images/plus-circle.png) no-repeat top;
179
- }
180
- .mtphr-post-duplicator-metaboxer-list-item-delete a {
181
- background: url(images/minus-circle.png) no-repeat top;
182
- }
183
- .mtphr-post-duplicator-metaboxer-list-item-handle span:hover,
184
- .mtphr-post-duplicator-metaboxer-list-item-add a:hover,
185
- .mtphr-post-duplicator-metaboxer-list-item-delete a:hover {
186
- background-position: 0 -16px;
187
- }
188
-
189
- /* Sorts
190
- ------------------------------------------------------------ */
191
-
192
- .mtphr-post-duplicator-metaboxer-sort td {
193
- padding: 6px 3px;
194
- border-bottom: 1px dashed #CCC;
195
- }
196
- .mtphr-post-duplicator-metaboxer-sort td.mtphr-post-duplicator-metaboxer-sort-name {
197
- font-weight: bold;
198
- padding-right: 10px;
199
- }
200
- .mtphr-post-duplicator-metaboxer-sort td.mtphr-post-duplicator-metaboxer-sort-item-handle {
201
- width: 16px;
202
- padding-top: 2px !important;
203
- border: none;
204
- }
205
- .mtphr-post-duplicator-metaboxer-sort-item-handle span {
206
- display: block;
207
- text-indent: -9999px;
208
- width: 16px;
209
- height: 16px;
210
- background: url(images/arrow-resize-090.png) no-repeat top;
211
- }
212
- .mtphr-post-duplicator-metaboxer-sort-item-handle span:hover {
213
- background-position: 0 -16px;
214
  }
215
-
216
- /* Code
217
- ------------------------------------------------------------ */
218
-
219
- .mtphr-post-duplicator-metaboxer-code pre {
220
- margin: 0 0 5px 0;
221
- padding: 10px;
222
- background: #FFF;
223
- border: 1px solid #EEE;
224
- white-space: normal;
225
-
226
- -webkit-border-radius: 5px;
227
- -moz-border-radius: 5px;
228
- border-radius: 5px;
229
  }
230
- .mtphr-post-duplicator-metaboxer-code pre p {
231
- margin: 0;
232
  }
233
 
234
- /* Radio
235
  ------------------------------------------------------------ */
236
 
237
- .mtphr-post-duplicator-metaboxer-radio input {
238
  margin-top: 0;
239
  margin-right: 1px;
240
  }
241
 
242
- /* Checkbox
243
  ------------------------------------------------------------ */
244
 
245
- .mtphr-post-duplicator-metaboxer-checkbox input {
246
  margin-top: 0;
247
  margin-right: 1px;
248
  }
249
 
250
- /* Textarea
251
  ------------------------------------------------------------ */
252
 
253
  .mtphr-post-duplicator-metaboxer-textarea textarea {
254
  width: 96%;
255
  }
256
 
257
- /* WYSIWYG
258
- ------------------------------------------------------------ */
259
-
260
- .mtphr-post-duplicator-metaboxer-wysiwyg {
261
- max-width: 800px;
262
- }
263
- .mtphr-post-duplicator-metaboxer-wysiwyg .mceIframeContainer {
264
- background: #FFF;
265
- }
266
-
267
- /* Farbtastic
268
- ------------------------------------------------------------ */
269
-
270
- .farbtastic_cp {
271
- float: left;
272
- display: none;
273
- }
274
-
275
- /* jQuery Slider
276
- ------------------------------------------------------------ */
277
-
278
- .slider-value {
279
- display: inline;
280
- font-weight: bold;
281
- line-height: 12px;
282
- color: #3D759B;
283
- border: none !important;
284
- margin: 0 0 0 5px;
285
- padding: 0;
286
- }
287
-
288
- /* Pattern Select
289
- ------------------------------------------------------------ */
290
-
291
- .mtphr-post-duplicator-metaboxer-pattern_select select {
292
- margin-bottom: 5px;
293
- }
294
- .mtphr-post-duplicator-metaboxer-pattern-selection {
295
- width: 200px;
296
- height: 100px;
297
- background-repeat: repeat;
298
- }
299
-
300
- /* Image Select
301
- ------------------------------------------------------------ */
302
-
303
- .mtphr-post-duplicator-metaboxer-image-select {
304
- margin-bottom: 10px;
305
- }
306
- a.mtphr-post-duplicator-metaboxer-image-select-link {
307
- display: block;
308
- float: left;
309
- margin: 0 10px 10px 0;
310
- text-decoration: none;
311
- }
312
- a.mtphr-post-duplicator-metaboxer-image-select-link small {
313
- display: block;
314
- text-align: center;
315
- font-weight: bold;
316
- color: #333;
317
- }
318
- a.mtphr-post-duplicator-metaboxer-image-select-link img {
319
- opacity: .5;
320
- -webkit-transition: opacity .2s linear;
321
- -moz-transition: opacity .2s linear;
322
- -o-transition: opacity .2s linear;
323
- -ms-transition: opacity .2s linear;
324
- transition: opacity .2s linear;
325
- }
326
- a.mtphr-post-duplicator-metaboxer-image-select-link.selected img {
327
- opacity: 1;
328
- }
329
-
330
-
331
- /* Attachments
332
- ------------------------------------------------------------ */
333
-
334
- .mtphr-post-duplicator-metaboxer-attachment-container {
335
- margin: 0;
336
- padding: 0;
337
- }
338
- .mtphr-post-duplicator-metaboxer-attachment-buttons {
339
- margin-bottom: 10px;
340
- }
341
- .mtphr-post-duplicator-metaboxer-attachment-links {
342
- opacity: 0;
343
- -webkit-transition: opacity .2s linear;
344
- -moz-transition: opacity .2s linear;
345
- -o-transition: opacity .2s linear;
346
- -ms-transition: opacity .2s linear;
347
- transition: opacity .2s linear;
348
- }
349
- .mtphr-post-duplicator-metaboxer-gallery-attachment:hover .mtphr-post-duplicator-metaboxer-attachment-links,
350
- .mtphr-post-duplicator-metaboxer-single-attachment:hover .mtphr-post-duplicator-metaboxer-attachment-links {
351
- opacity: 1;
352
- }
353
- .mtphr-post-duplicator-metaboxer-attachment-preview,
354
- .mtphr-post-duplicator-metaboxer-attachment-settings,
355
- .mtphr-post-duplicator-metaboxer-attachment-delete {
356
- display: inline-block;
357
- opacity: .5;
358
- -webkit-transition: opacity .2s linear;
359
- -moz-transition: opacity .2s linear;
360
- -o-transition: opacity .2s linear;
361
- -ms-transition: opacity .2s linear;
362
- transition: opacity .2s linear;
363
- }
364
- .mtphr-post-duplicator-metaboxer-attachment-preview:hover,
365
- .mtphr-post-duplicator-metaboxer-attachment-settings:hover,
366
- .mtphr-post-duplicator-metaboxer-attachment-delete:hover {
367
- opacity: 1;
368
- }
369
- .mtphr-post-duplicator-metaboxer-attachment-preview {
370
- position: absolute;
371
- top: 10px;
372
- left: 10px;
373
- width: 17px;
374
- height: 17px;
375
- background: url(images/attachment-preview.png);
376
- }
377
- .mtphr-post-duplicator-metaboxer-attachment-settings {
378
- position: absolute;
379
- top: 10px;
380
- right: 10px;
381
- width: 17px;
382
- height: 17px;
383
- background: url(images/attachment-settings.png);
384
- }
385
- .mtphr-post-duplicator-metaboxer-attachment-delete {
386
- position: absolute;
387
- bottom: 10px;
388
- right: 10px;
389
- width: 14px;
390
- height: 14px;
391
- background: url(images/attachment-delete.png);
392
- }
393
- .mtphr-post-duplicator-metaboxer-attachment-mime-type {
394
- position: absolute;
395
- bottom: 10px;
396
- left: 10px;
397
- }
398
- .mtphr-post-duplicator-metaboxer-attachment-mime-type-vimeo {
399
- width: 20px;
400
- height: 20px;
401
- background: url(images/attachment-vimeo.png);
402
- }
403
- .mtphr-post-duplicator-metaboxer-attachment-mime-type-youtube {
404
- width: 20px;
405
- height: 23px;
406
- background: url(images/attachment-youtube.png);
407
- }
408
- .mtphr-post-duplicator-metaboxer-attachment-mime-type-audio {
409
- width: 20px;
410
- height: 20px;
411
- background: url(images/attachment-audio.png);
412
- }
413
- .mtphr-post-duplicator-metaboxer-attachment-mime-type-video {
414
- width: 20px;
415
- height: 20px;
416
- background: url(images/attachment-video.png);
417
- }
418
- .mtphr-post-duplicator-metaboxer-attachment-mime-type-image {
419
- width: 20px;
420
- height: 20px;
421
- background: url(images/attachment-image.png);
422
- }
423
- .mtphr-post-duplicator-metaboxer-gallery-attachment-container {
424
- width:100%;
425
- margin: 0;
426
- }
427
- .mtphr-post-duplicator-metaboxer-gallery-attachment {
428
- position: relative;
429
- float: left;
430
- width: 120px;
431
- height: 120px;
432
-
433
- margin: 0 10px 10px 0;
434
-
435
- -webkit-border-radius: 5px;
436
- -moz-border-radius: 5px;
437
- border-radius: 5px;
438
-
439
- -moz-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
440
- -webkit-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
441
- box-shadow: 0 0 1px #000;
442
-
443
- opacity: 1;
444
- -webkit-transition: opacity .2s linear;
445
- -moz-transition: opacity .2s linear;
446
- -o-transition: opacity .2s linear;
447
- -ms-transition: opacity .2s linear;
448
- transition: opacity .2s linear;
449
- }
450
- .mtphr-post-duplicator-metaboxer-gallery-attachment:active {
451
- opacity: .5;
452
- }
453
- .mtphr-post-duplicator-metaboxer-gallery-attachment-bg {
454
- width: 120px;
455
- height: 120px;
456
- background-position: center center;
457
- background-size: auto 120px;
458
- -webkit-border-radius: 5px;
459
- -moz-border-radius: 5px;
460
- border-radius: 5px;
461
- }
462
- .mtphr-post-duplicator-metaboxer-gallery-attachment-bg-youtube {
463
- background-size: auto 160px;
464
- }
465
- .mtphr-post-duplicator-metaboxer-gallery-attachment img {
466
- -webkit-border-radius: 5px;
467
- -moz-border-radius: 5px;
468
- border-radius: 5px;
469
- }
470
- .mtphr-post-duplicator-metaboxer-gallery-attachment:active .mtphr-post-duplicator-metaboxer-attachment-links {
471
- opacity: 0;
472
- }
473
- .attachment-mtphr-post-duplicator-metaboxer-gallery-thumb {
474
- cursor: move;
475
- -webkit-border-radius: 5px;
476
- -moz-border-radius: 5px;
477
- border-radius: 5px;
478
- }
479
-
480
- /* Single Image
481
- ------------------------------------------------------------ */
482
-
483
- .mtphr-post-duplicator-metaboxer-single-attachment {
484
- float: left;
485
- position: relative;
486
- margin: 0;
487
- padding: 0;
488
- }
489
- .mtphr-post-duplicator-metaboxer-single-attachment img {
490
- max-width: 90%;
491
- height: auto;
492
- padding: 20px;
493
- margin: 0;
494
-
495
- -webkit-border-radius: 5px;
496
- -moz-border-radius: 5px;
497
- border-radius: 5px;
498
-
499
- -moz-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
500
- -webkit-box-shadow: 2px 0 0px #000, inset 0 0 3px #DDD;
501
- box-shadow: 0 0 1px #000;
502
- }
503
-
504
- /* Clearfix
505
- ------------------------------------------------------------ */
506
-
507
- .clearfix {
508
- *zoom: 1;
509
- }
510
- .clearfix:before,
511
- .clearfix:after {
512
- display: table;
513
- content: "";
514
- }
515
- .clearfix:after {
516
- clear: both;
517
- }
518
-
519
- /* Custom
520
- ------------------------------------------------------------ */
521
-
522
- #mtphr_post_duplicator_global_settings .mtphr-post-duplicator-metaboxer-field-content {
523
- padding-bottom: 0;
524
- }
1
+ /* General - 1.0.2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  ------------------------------------------------------------ */
3
 
4
  .mtphr-post-duplicator-metaboxer-admin-fields {
9
  }
10
  .mtphr-post-duplicator-metaboxer-appended {
11
  display: inline;
12
+ margin-left: 20px;
13
+ }
14
+ .mtphr-post-duplicator-metaboxer-widget-field {
15
+ display: block;
16
+ margin: 0 0 1em;
17
+ padding: 0;
18
  }
19
 
20
+ /* Fields */
 
 
 
21
  .mtphr-post-duplicator-metaboxer-field {
22
  margin-bottom: 20px;
23
  }
27
  .mtphr-post-duplicator-metaboxer-field:last-child {
28
  margin-bottom: 20px;
29
  }
30
+ .mtphr-post-duplicator-metaboxer-field input[type="checkbox"] {
31
+ margin-top: 0;
32
+ }
33
+ .mtphr-post-duplicator-metaboxer-field input[type="radio"] {
34
+ margin-top:-1px;
35
+ }
36
 
37
+ /* Labels */
 
 
38
  .mtphr-post-duplicator-metaboxer-label {
39
  vertical-align: top;
40
  width: 20%;
57
  padding: 0;
58
  }
59
 
60
+ /* Content */
 
61
  .mtphr-post-duplicator-metaboxer-field-content {
62
  width: 80%;
63
  vertical-align: top;
72
  width: auto;
73
  }
74
 
75
+ /* Clearfix */
76
+ .clearfix {
77
+ *zoom: 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
+ .clearfix:before,
80
+ .clearfix:after {
81
+ display: table;
82
+ content: "";
 
 
 
 
 
 
 
 
 
 
83
  }
84
+ .clearfix:after {
85
+ clear: both;
86
  }
87
 
88
+ /* Checkbox
89
  ------------------------------------------------------------ */
90
 
91
+ .mtphr-post-duplicator-metaboxer-checkbox input {
92
  margin-top: 0;
93
  margin-right: 1px;
94
  }
95
 
96
+ /* Radio
97
  ------------------------------------------------------------ */
98
 
99
+ .mtphr-team-members-metaboxer-radio input {
100
  margin-top: 0;
101
  margin-right: 1px;
102
  }
103
 
104
+ /* Textarea - 1.0.1
105
  ------------------------------------------------------------ */
106
 
107
  .mtphr-post-duplicator-metaboxer-textarea textarea {
108
  width: 96%;
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
metaboxer/metaboxer.js CHANGED
@@ -1,383 +1,2 @@
1
- /* Table of Contents
2
-
3
- * File
4
- * Lists
5
- * Code
6
- * Metabox toggle
7
-
8
- */
9
-
10
-
11
-
12
-
13
  jQuery(document).ready( function($) {
14
-
15
-
16
-
17
-
18
- /**
19
- * Add file functionality.
20
- *
21
- * @since 1.0.0
22
- */
23
- if( $('.mtphr-post-duplicator-metaboxer-file').length > 0 ) {
24
- mtphr_post_duplicator_metaboxer_files();
25
- }
26
- function mtphr_post_duplicator_metaboxer_files() {
27
-
28
- // Loop through all files to initialize
29
- $('.mtphr-post-duplicator-metaboxer-file').each( function(index) {
30
-
31
- // If there currently isn't a value, show the upload button
32
- if( $(this).find('.mtphr-post-duplicator-metaboxer-file-value').val() == '' ) {
33
- $(this).find('.mtphr-post-duplicator-metaboxer-file-upload').css('display','inline-block');
34
- }
35
- });
36
-
37
- // Custom media upload functionality
38
- $('.mtphr-post-duplicator-metaboxer-file-upload').click(function() {
39
-
40
- // Save the container
41
- var $container = $(this).parent('.mtphr-post-duplicator-metaboxer-field-content');
42
-
43
- var send_attachment_bkp = wp.media.editor.send.attachment;
44
-
45
- wp.media.editor.send.attachment = function( props, attachment ) {
46
-
47
- // Set the field value
48
- $container.find('.mtphr-post-duplicator-metaboxer-file-value').val(attachment.id);
49
-
50
- // Create the display
51
- var data = {
52
- action: 'mtphr_post_duplicator_metaboxer_ajax_file_display',
53
- id: attachment.id,
54
- type: attachment.type,
55
- url: attachment.url,
56
- title: attachment.title,
57
- caption: attachment.caption,
58
- description: attachment.description,
59
- security: mtphr_post_duplicator_metaboxer_vars.security
60
- };
61
-
62
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
63
- jQuery.post( ajaxurl, data, function( response ) {
64
-
65
- // Append the new data
66
- $container.append( response );
67
-
68
- // Hide the upload button
69
- $container.find('.mtphr-post-duplicator-metaboxer-file-upload').hide();
70
- });
71
-
72
- wp.media.editor.send.attachment = send_attachment_bkp;
73
- }
74
-
75
- wp.media.editor.open();
76
-
77
- return false;
78
- });
79
-
80
- $('.mtphr-post-duplicator-metaboxer-file-delete').live('click',function() {
81
-
82
- // Save the container
83
- var $container = $(this).parents('.mtphr-post-duplicator-metaboxer-field-content');
84
-
85
- // Remove the field value
86
- $container.find('.mtphr-post-duplicator-metaboxer-file-value').val('');
87
-
88
- // Remove the current display
89
- $container.find('.mtphr-post-duplicator-metaboxer-file-table').remove();
90
-
91
- // Disply the upload button
92
- $container.find('.mtphr-post-duplicator-metaboxer-file-upload').css('display','inline-block');
93
- });
94
- }
95
-
96
-
97
-
98
-
99
- /**
100
- * Add list functionality.
101
- *
102
- * @since 1.0.0
103
- */
104
- if( $('.mtphr-post-duplicator-metaboxer-list').length > 0 ) {
105
- mtphr_post_duplicator_metaboxer_lists();
106
- }
107
- function mtphr_post_duplicator_metaboxer_lists() {
108
-
109
- // Loop through all lists to initialize
110
- $('.mtphr-post-duplicator-metaboxer-list').each( function(index) {
111
-
112
- // Set the field order
113
- mtphr_post_duplicator_metaboxer_lists_set_order( $(this) );
114
-
115
- // Add sorting to the items
116
- $(this).sortable( {
117
- handle: '.mtphr-post-duplicator-metaboxer-list-item-handle',
118
- items: '.mtphr-post-duplicator-metaboxer-list-item',
119
- axis: 'y',
120
- helper: function(e, tr) {
121
- var $originals = tr.children();
122
- var $helper = tr.clone();
123
- $helper.children().each(function(index) {
124
- // Set helper cell sizes to match the original sizes
125
- $(this).width($originals.eq(index).width())
126
- });
127
- return $helper;
128
- },
129
- update: function( event, ui ) {
130
-
131
- // Set the field order
132
- mtphr_post_duplicator_metaboxer_lists_set_order( $(this) );
133
- }
134
- });
135
- });
136
-
137
- // Set the list item order
138
- function mtphr_post_duplicator_metaboxer_lists_set_order( $list ) {
139
-
140
- // Set the order of the items
141
- $list.find('.mtphr-post-duplicator-metaboxer-list-item').each( function(i) {
142
-
143
- $(this).find('.mtphr-post-duplicator-metaboxer-list-structure-item').each( function(e) {
144
-
145
- var base = $(this).attr('base');
146
- var field = $(this).attr('field');
147
- $(this).find('input,textarea,select').attr('name', base+'['+i+']['+field+']');
148
- });
149
- });
150
-
151
- // Hide the delete if only one element
152
- if( $list.find('.mtphr-post-duplicator-metaboxer-list-item').length == 1 ) {
153
-
154
- $list.find('.mtphr-post-duplicator-metaboxer-list-item-handle,.mtphr-post-duplicator-metaboxer-list-item-delete').hide();
155
- }
156
- }
157
-
158
- // Add item click
159
- $('.mtphr-post-duplicator-metaboxer-list-item-add').children('a').click( function(e) {
160
- e.preventDefault();
161
-
162
- // Create a new item with blank content
163
- var $parent = $(this).parents('.mtphr-post-duplicator-metaboxer-list-item');
164
- var $new = $parent.clone(true).hide();
165
- $new.find('input,textarea,select').removeAttr('value').removeAttr('checked').removeAttr('selected');
166
- $parent.after($new);
167
- $new.fadeIn();
168
-
169
- // Set the field order
170
- mtphr_post_duplicator_metaboxer_lists_set_order( $(this).parents('.mtphr-post-duplicator-metaboxer-list') );
171
-
172
- // Show the handles
173
- $(this).parents('.mtphr-post-duplicator-metaboxer-list').find('.mtphr-post-duplicator-metaboxer-list-item-handle,.mtphr-post-duplicator-metaboxer-list-item-delete').show();
174
-
175
- // Set the focus to the new input
176
- var inputs = $new.find('input,textarea,select');
177
- $(inputs[0]).focus();
178
- });
179
-
180
- // Delete item click
181
- $('.mtphr-post-duplicator-metaboxer-list-item-delete').children('a').click( function(e) {
182
- e.preventDefault();
183
-
184
- // Fade out the item
185
- $(this).parents('.mtphr-post-duplicator-metaboxer-list-item').fadeOut( function() {
186
-
187
- // Get the list
188
- var $list = $(this).parents('.mtphr-post-duplicator-metaboxer-list');
189
-
190
- // Remove the item
191
- $(this).remove();
192
-
193
- // Set the field order
194
- mtphr_post_duplicator_metaboxer_lists_set_order( $list );
195
- });
196
- });
197
- }
198
-
199
-
200
-
201
-
202
- /**
203
- * Add list functionality.
204
- *
205
- * @since 1.0.0
206
- */
207
- if( $('.mtphr-post-duplicator-metaboxer-sort').length > 0 ) {
208
- mtphr_post_duplicator_metaboxer_sorts();
209
- }
210
- function mtphr_post_duplicator_metaboxer_sorts() {
211
-
212
- // Loop through all sorts to initialize
213
- $('.mtphr-post-duplicator-metaboxer-sort').each( function(index) {
214
-
215
- // Set the field order
216
- //mtphr_post_duplicator_metaboxer_sorts_set_order( $(this) );
217
-
218
- // Add sorting to the items
219
- $(this).sortable( {
220
- handle: '.mtphr-post-duplicator-metaboxer-sort-item-handle',
221
- items: '.mtphr-post-duplicator-metaboxer-sort-item',
222
- axis: 'y',
223
- helper: function(e, tr) {
224
- var $originals = tr.children();
225
- var $helper = tr.clone();
226
- $helper.children().each(function(index) {
227
- // Set helper cell sizes to match the original sizes
228
- $(this).width($originals.eq(index).width())
229
- });
230
- return $helper;
231
- },
232
- update: function( event, ui ) {
233
-
234
- // Set the field order
235
- //mtphr_post_duplicator_metaboxer_sorts_set_order( $(this) );
236
- }
237
- });
238
- });
239
-
240
- // Set the list item order
241
- /*
242
- function mtphr_post_duplicator_metaboxer_sorts_set_order( $sort ) {
243
-
244
- // Set the order of the items
245
- $list.find('.mtphr-post-duplicator-metaboxer-list-item').each( function(i) {
246
-
247
- $(this).find('.mtphr-post-duplicator-metaboxer-list-structure-item').each( function(e) {
248
-
249
- var base = $(this).attr('base');
250
- var field = $(this).attr('field');
251
- $(this).find('input,textarea,select').attr('name', base+'['+i+']['+field+']');
252
- });
253
- });
254
-
255
- // Hide the delete if only one element
256
- if( $list.find('.mtphr-post-duplicator-metaboxer-list-item').length == 1 ) {
257
-
258
- $list.find('.mtphr-post-duplicator-metaboxer-list-item-handle,.mtphr-post-duplicator-metaboxer-list-item-delete').hide();
259
- }
260
- }
261
- */
262
- }
263
-
264
-
265
-
266
-
267
- /**
268
- * Add code functionality.
269
- *
270
- * @since 1.0.0
271
- */
272
- if( $('.mtphr-post-duplicator-metaboxer-code').length > 0 ) {
273
- mtphr_post_duplicator_metaboxer_codes();
274
- }
275
- function mtphr_post_duplicator_metaboxer_codes() {
276
-
277
- // Select the code on button click
278
- $('.mtphr-post-duplicator-metaboxer-code-select').click( function(e) {
279
- e.preventDefault();
280
-
281
- var $pre = $(this).parents('.mtphr-post-duplicator-metaboxer-code').find('pre');
282
- var refNode = $pre[0];
283
- if ( jQuery.browser.msie ) {
284
- var range = document.body.createTextRange();
285
- range.moveToElementText( refNode );
286
- range.select();
287
- } else if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
288
- var selection = window.getSelection();
289
- var range = document.createRange();
290
- range.selectNodeContents( refNode );
291
- selection.removeAllRanges();
292
- selection.addRange( range );
293
- } else if ( jQuery.browser.safari || jQuery.browser.chrome ) {
294
- var selection = window.getSelection();
295
- selection.setBaseAndExtent( refNode, 0, refNode, 1 );
296
- }
297
- });
298
- }
299
-
300
-
301
-
302
-
303
- /**
304
- * Add metabox toggle functionality.
305
- *
306
- * @since 1.0.0
307
- */
308
- if( $('.mtphr-post-duplicator-metaboxer-field-metabox_toggle').length > 0 ) {
309
- mtphr_post_duplicator_metaboxer_metabox_toggles();
310
- }
311
- function mtphr_post_duplicator_metaboxer_metabox_toggles() {
312
-
313
- $('.mtphr-post-duplicator-metaboxer-field-metabox_toggle').each( function(index) {
314
-
315
- // Create an array to store all the toggled metaboxes
316
- var metaboxes = Array();
317
- $(this).find('.mtphr-post-duplicator-metaboxer-metabox-toggle').each( function(index) {
318
-
319
- // Get the metaboxes and merge into the main array
320
- var m = $(this).attr('metaboxes').split(',');
321
- $.merge( metaboxes, m );
322
- });
323
- var total_metaboxes = metaboxes.length;
324
-
325
- // Hide the toggled metaboxes
326
- mtphr_post_duplicator_metaboxer_metabox_hide();
327
-
328
- // Display the current metaboxes
329
- if( $(this).find('.mtphr-post-duplicator-metaboxer-metabox-toggle.button-primary').length > 0 ) {
330
- $init_button = $(this).find('.mtphr-post-duplicator-metaboxer-metabox-toggle.button-primary');
331
- } else {
332
- $init_button = $(this).find('.mtphr-post-duplicator-metaboxer-metabox-toggle:first');
333
- $init_button.addClass('button-primary');
334
- }
335
- mtphr_post_duplicator_metaboxer_metabox_show( $init_button );
336
-
337
- // Hide the toggled metaboxes
338
- function mtphr_post_duplicator_metaboxer_metabox_hide() {
339
- for( var i=0; i<total_metaboxes; i++ ) {
340
- $('#'+metaboxes[i]).hide();
341
- $('input[name="'+metaboxes[i]+'-hide"]').removeAttr('checked');
342
- }
343
- }
344
-
345
- // Show the selected metaboxes
346
- function mtphr_post_duplicator_metaboxer_metabox_show( $button ) {
347
-
348
- // Get and display the selected metaboxes
349
- var m = $button.attr('metaboxes').split(',');
350
- var t = m.length;
351
-
352
- // Show all the toggled metaboxes
353
- for( var i=0; i<t; i++ ) {
354
- $('#'+m[i]).show();
355
- $('input[name="'+m[i]+'-hide"]').attr('checked', 'checked');
356
- }
357
-
358
- // Store the new value
359
- $button.siblings('input').val($button.attr('href'));
360
- }
361
-
362
- // Select the code on button click
363
- $(this).find('.mtphr-post-duplicator-metaboxer-metabox-toggle').click( function(e) {
364
- e.preventDefault();
365
-
366
- // Hide all the toggled metaboxes
367
- mtphr_post_duplicator_metaboxer_metabox_hide();
368
-
369
- // Show the selected metaboxes
370
- mtphr_post_duplicator_metaboxer_metabox_show( $(this) );
371
-
372
- // Set the button classes
373
- $(this).siblings('.mtphr-post-duplicator-metaboxer-metabox-toggle').removeClass('button-primary');
374
- $(this).addClass('button-primary');
375
- });
376
- });
377
- }
378
-
379
-
380
-
381
-
382
-
383
  });
 
 
 
 
 
 
 
 
 
 
 
 
1
  jQuery(document).ready( function($) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  });
metaboxer/metaboxer.php CHANGED
@@ -2,11 +2,9 @@
2
  /**
3
  * Put all the Metaboxer admin function here fields here
4
  *
5
- * @package Ditty News Ticker
6
  * @author Metaphor Creations
7
  * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
8
- * @link http://www.metaphorcreations.com/plugins/metatools
9
- * @version 1.0.0
10
  */
11
 
12
 
@@ -70,113 +68,6 @@ function mtphr_post_duplicator_metaboxer_container( $field, $context ) {
70
 
71
 
72
 
73
- /**
74
- * Add custom image sizes.
75
- *
76
- * @since 1.0.0
77
- */
78
- if ( function_exists( 'add_image_size' ) ) {
79
-
80
- // Create custom image sizes
81
- add_image_size( 'metaboxer-gallery-thumb', 120, 120, true );
82
- }
83
-
84
-
85
-
86
-
87
- add_action( 'wp_ajax_mtphr_post_duplicator_metaboxer_insert_attachment', 'mtphr_post_duplicator_metaboxer_insert_attachment' );
88
- /**
89
- * Ajax function used to insert a single attachment
90
- *
91
- * @since 1.0.0
92
- */
93
- function mtphr_post_duplicator_metaboxer_insert_attachment() {
94
-
95
- // Get access to the database
96
- global $wpdb;
97
-
98
- // Check the nonce
99
- check_ajax_referer( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce', 'security' );
100
-
101
- // Get variables
102
- $file_id = $_POST['file_ids'];
103
- $file_type = isset( $_POST['file_type'] ) ? $_POST['file_type'] : '';
104
- $file_size = isset( $_POST['file_size'] ) ? $_POST['file_size'] : '';
105
-
106
- $output = '<li class="mtphr-post-duplicator-metaboxer-single-attachment" id="'.$file_id.'">'.wp_get_attachment_image( $file_id, ( $file_size != '' ) ? $file_size : 'thumbnail' );;
107
- $output .= '<div class="mtphr-post-duplicator-metaboxer-attachment-links">';
108
- //$output .= '<a href="'.$file_id.'" class="mtphr-post-duplicator-metaboxer-attachment-preview"></a>';
109
- $output .= '<a href="'.$file_id.'" class="mtphr-post-duplicator-metaboxer-attachment-settings"></a>';
110
- $output .= '<a href="'.$file_id.'" class="mtphr-post-duplicator-metaboxer-attachment-delete"></a>';
111
- $output .= '</div><li>';
112
-
113
- echo $output;
114
-
115
- die(); // this is required to return a proper result
116
- }
117
-
118
-
119
-
120
-
121
- add_action( 'wp_ajax_mtphr_post_duplicator_metaboxer_insert_attachments', 'mtphr_post_duplicator_metaboxer_insert_attachments' );
122
- /**
123
- * Ajax function used to insert multiple attachments
124
- *
125
- * @since 1.0.0
126
- */
127
- function mtphr_post_duplicator_metaboxer_insert_attachments() {
128
-
129
- // Get access to the database
130
- global $wpdb;
131
-
132
- // Check the nonce
133
- check_ajax_referer( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce', 'security' );
134
-
135
- // Get variables
136
- $file_ids = $_POST['file_ids'];
137
-
138
- // Create an array of ids
139
- $files = explode( ',', $file_ids );
140
-
141
- // Create the new files
142
- foreach ( $files as $id ) {
143
- echo mtphr_post_duplicator_metaboxer_thumb( $id, false );
144
- }
145
-
146
- die(); // this is required to return a proper result
147
- }
148
-
149
-
150
-
151
-
152
- add_action( 'wp_ajax_mtphr_post_duplicator_metaboxer_delete_attachments', 'mtphr_post_duplicator_metaboxer_delete_attachments' );
153
- /**
154
- * Ajax function used to delete attachments
155
- *
156
- * @since 1.0.0
157
- */
158
- function mtphr_post_duplicator_metaboxer_delete_attachments() {
159
-
160
- // Get access to the database
161
- global $wpdb;
162
-
163
- // Check the nonce
164
- check_ajax_referer( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce', 'security' );
165
-
166
- // Get variables
167
- $file_ids = $_POST['file_ids'];
168
-
169
- // Create an array of ids
170
- $files = explode( ',', $file_ids );
171
-
172
- // Delete the attachments
173
- foreach ( $files as $id ) {
174
- wp_delete_attachment( $id );
175
- }
176
-
177
- die(); // this is required to return a proper result
178
- }
179
-
180
 
181
  /**
182
  * Append fields
@@ -231,208 +122,6 @@ function mtphr_post_duplicator_metaboxer_append_field( $field ) {
231
  }
232
 
233
 
234
-
235
- /* Table of Contents
236
-
237
- * text
238
- * number
239
- * textarea
240
- * wysiwyg
241
- * checkbox
242
- * radio
243
- * farbtastic
244
- * image
245
- * select
246
- * image_select
247
- * list
248
- * sort
249
- * html
250
- * metabox toggle
251
- * file
252
- * gallery
253
- * code
254
-
255
- */
256
-
257
- /**
258
- * Renders an text field.
259
- *
260
- * @since 1.0.0
261
- */
262
- function mtphr_post_duplicator_metaboxer_text( $field, $value='' ) {
263
- $size = ( isset($field['size']) ) ? $field['size'] : 40;
264
- $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
265
- $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
266
- $text_align = ( isset($field['text_align']) ) ? ' style="text-align:'.$field['text_align'].'"' : '' ;
267
- $output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="text" value="'.$value.'" size="'.$size.'"'.$text_align.'>'.$after;
268
- echo $output;
269
-
270
- // Add appended fields
271
- mtphr_post_duplicator_metaboxer_append_field($field);
272
- }
273
-
274
- /**
275
- * Renders an number field.
276
- *
277
- * @since 1.0.0
278
- */
279
- function mtphr_post_duplicator_metaboxer_number( $field, $value='' ) {
280
- $style = ( isset($field['style']) ) ? ' style="'.$field['style'].'"' : '';
281
- $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
282
- $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
283
- $output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="number" value="'.$value.'" class="small-text"'.$style.'>'.$after;
284
- echo $output;
285
-
286
- // Add appended fields
287
- mtphr_post_duplicator_metaboxer_append_field($field);
288
- }
289
-
290
- /**
291
- * Renders a textarea custom field.
292
- *
293
- * @since 1.0.0
294
- */
295
- function mtphr_post_duplicator_metaboxer_textarea( $field, $value='' ) {
296
- $rows = ( isset($field['rows']) ) ? $field['rows'] : 5;
297
- $cols = ( isset($field['cols']) ) ? $field['cols'] : 40;
298
- $output = '<textarea name="'.$field['id'].'" id="'.$field['id'].'" rows="'.$rows.'" cols="'.$cols.'">'.$value.'</textarea>';
299
- echo $output;
300
-
301
- // Add appended fields
302
- mtphr_post_duplicator_metaboxer_append_field($field);
303
- }
304
-
305
- /**
306
- * Renders a wysiwyg field.
307
- *
308
- * @since 1.0.0
309
- */
310
- function mtphr_post_duplicator_metaboxer_wysiwyg( $field, $value='' ) {
311
- $settings = array();
312
- $settings['media_buttons'] = true;
313
- $settings['textarea_rows'] = ( isset($field['rows']) ) ? $field['rows'] : 12;
314
- wp_editor( $value, $field['id'], $settings );
315
-
316
- // Add appended fields
317
- mtphr_post_duplicator_metaboxer_append_field($field);
318
- }
319
-
320
- /**
321
- * Renders a checkbox custom field.
322
- *
323
- * @since 1.0.0
324
- */
325
- function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
326
-
327
- $output = '';
328
- $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
329
- $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
330
-
331
- if( isset($field['options']) ) {
332
-
333
- $break = '<br/>';
334
- if ( isset($field['display']) ) {
335
- if( $field['display'] == 'inline' ) {
336
- $break = '&nbsp;&nbsp;&nbsp;&nbsp;';
337
- }
338
- }
339
- foreach( $field['options'] as $i => $option ) {
340
- $checked = ( isset($value[$i]) ) ? 'checked="checked"' : '';
341
- $output .= '<label><input name="'.$field['id'].'['.$i.']" id="'.$field['id'].'['.$i.']" type="checkbox" value="1" '.$checked.' /> '.$option.'</label>'.$break;
342
- }
343
-
344
- } else {
345
-
346
- $checked = ( $value == 1 ) ? 'checked="checked"' : '';
347
- $output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="checkbox" value="1" '.$checked.' />';
348
- if( isset($field['label']) ) {
349
- $output .= ' '.$field['label'];
350
- }
351
- $output .= '</label>';
352
- }
353
-
354
- echo $before.$output.$after;
355
-
356
- // Add appended fields
357
- mtphr_post_duplicator_metaboxer_append_field($field);
358
- }
359
-
360
- /**
361
- * Renders a radio custom field.
362
- *
363
- * @since 1.0.0
364
- */
365
- function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
366
-
367
- if( isset($field['options']) ) {
368
-
369
- $output = '';
370
- $break = '<br/>';
371
- if ( isset($field['display']) ) {
372
- if( $field['display'] == 'inline' ) {
373
- $break = '&nbsp;&nbsp;&nbsp;&nbsp;';
374
- }
375
- }
376
- foreach( $field['options'] as $i => $option ) {
377
- $checked = ( $value == $i ) ? 'checked="checked"' : '';
378
- $output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="radio" value="'.$i.'" '.$checked.' /> '.$option.'</label>'.$break;
379
- }
380
- }
381
-
382
- echo $output;
383
-
384
- // Add appended fields
385
- mtphr_post_duplicator_metaboxer_append_field($field);
386
- }
387
-
388
- /**
389
- * Renders a farbtastic custom field.
390
- *
391
- * @since 1.0.0
392
- */
393
- function mtphr_post_duplicator_metaboxer_farbtastic( $field, $value='' ) {
394
- $output = '<div class="farbtastic_cp" id="'.$field['id'].'_cp"></div>';
395
- $output .= '<input name="'.$field['id'].'" id="'.$field['id'].'" type="text" value="'.$value.'" />';
396
- $output .= '<a href="#" class="farbtastic-pick button">Pick Color</a>';
397
- echo $output;
398
-
399
- // Add appended fields
400
- mtphr_post_duplicator_metaboxer_append_field($field);
401
- }
402
-
403
- /**
404
- * Renders an image field.
405
- *
406
- * @since 1.0.0
407
- */
408
- function mtphr_post_duplicator_metaboxer_image( $field, $value=false ) {
409
- $button = isset( $field['button'] ) ? $field['button'] : 'Upload Image';
410
- $size = isset( $field['size'] ) ? $field['size'] : 'thumbnail';
411
-
412
- $value = ( $value ) ? $value : false;
413
-
414
- $output = '<div class="mtphr-post-duplicator-metaboxer-attachment-buttons"><a href="#" class="button mtphr-post-duplicator-metaboxer-upload-button">'.$button.'</a></div>';
415
- $output .= '<input class="mtphr-post-duplicator-metaboxer-attachment-limit" type="hidden" value="1" />';
416
- $output .= '<input class="mtphr-post-duplicator-metaboxer-attachment-size" type="hidden" value="'.$size.'" />';
417
- $output .= '<div class="mtphr-post-duplicator-metaboxer-input-container" id="'.$field['id'].'"></div>';
418
- $output .= '<ul id="'.wp_create_nonce( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce' ).'" class="mtphr-post-duplicator-metaboxer-attachment-container clearfix">';
419
- if( $value ) {
420
- if( get_post($value[0]) ) {
421
- $output .= '<li id="'.$value[0].'" class="mtphr-post-duplicator-metaboxer-single-attachment">'.wp_get_attachment_image( $value[0], isset( $field['size'] ) ? $field['size'] : 'thumbnail' );
422
- $output .= '<div class="mtphr-post-duplicator-metaboxer-attachment-links">';
423
- //$output .= '<a href="'.$value[0].'" class="mtphr-post-duplicator-metaboxer-attachment-preview"></a>';
424
- $output .= '<a href="'.$value[0].'" class="mtphr-post-duplicator-metaboxer-attachment-settings"></a>';
425
- $output .= '<a href="'.$value[0].'" class="mtphr-post-duplicator-metaboxer-attachment-delete"></a>';
426
- $output .= '</div>';
427
- $output .= '</li>';
428
- }
429
- }
430
- $output .= '</ul>';
431
- echo $output;
432
-
433
- // Add appended fields
434
- mtphr_post_duplicator_metaboxer_append_field($field);
435
- }
436
 
437
  /**
438
  * Renders a select field.
@@ -470,208 +159,92 @@ function mtphr_post_duplicator_metaboxer_select( $field, $value='' ) {
470
  mtphr_post_duplicator_metaboxer_append_field($field);
471
  }
472
 
473
- /**
474
- * Renders an image select
475
- *
476
- * @since 1.0.0
477
- */
478
- function mtphr_post_duplicator_metaboxer_image_select( $field, $value='' ) {
479
- $output = '<input type="hidden" id="'.$field['id'].'" name="'.$field['id'].'" value="'.$value.'" />';
480
- foreach ( $field['options'] as $option ) {
481
- $selected = ( $value == $option['value'] ) ? 'selected' : '';
482
- $output .= '<a class="mtphr-post-duplicator-metaboxer-image-select-link '.$selected.'" href="'.$option['value'].'"><img src="'.$option['path'].'" /><small>'.$option['label'].'</small></a>';
483
- }
484
- echo $output;
485
-
486
- // Add appended fields
487
- mtphr_post_duplicator_metaboxer_append_field($field);
488
- }
489
 
490
  /**
491
- * Renders a list.
492
  *
493
  * @since 1.0.0
494
  */
495
- function mtphr_post_duplicator_metaboxer_list( $field, $value='' ) {
496
-
497
- $output = '<table>';
498
-
499
- $headers = false;
500
- $header_str = '';
501
- foreach( $field['structure'] as $id => $str ) {
502
-
503
- $header_str .= '<th>';
504
- if( isset($str['header']) ) {
505
- $headers = true;
506
- $header_str .= $str['header'];
507
- }
508
- $header_str .= '</th>';
509
- }
510
- if( $headers ) {
511
- $output .= '<tr><td class="mtphr-post-duplicator-metaboxer-list-item-handle"></td>'.$header_str.'</tr>';
512
- }
513
 
514
- $buttons = '<td class="mtphr-post-duplicator-metaboxer-list-item-delete"><a href="#">Delete</a></td><td class="mtphr-post-duplicator-metaboxer-list-item-add"><a href="#">Add</a></td>';
515
- if( is_array($value) ) {
516
- foreach( $value as $i=>$v ) {
517
- $structure = mtphr_post_duplicator_metaboxer_list_structure( $i, $field, $v );
518
- $output .= '<tr class="mtphr-post-duplicator-metaboxer-list-item"><td class="mtphr-post-duplicator-metaboxer-list-item-handle"><span></span></td>'.$structure.$buttons.'</tr>';
 
 
 
519
  }
 
 
 
 
520
  }
521
 
522
- // If nothing is being output make sure one field is showing
523
- if( $value == '' ) {
524
- $structure = mtphr_post_duplicator_metaboxer_list_structure( 0, $field );
525
- $output .= '<tr class="mtphr-post-duplicator-metaboxer-list-item"><td class="mtphr-post-duplicator-metaboxer-list-item-handle"><span></span></td>'.$structure.$buttons.'</tr>';
526
- }
527
-
528
- $output .= '</table>';
529
-
530
  echo $output;
531
 
532
  // Add appended fields
533
  mtphr_post_duplicator_metaboxer_append_field($field);
534
  }
535
 
536
- /**
537
- * Add the list structure
538
- *
539
- * @since 1.0.0
540
- */
541
- function mtphr_post_duplicator_metaboxer_list_structure( $pos, $fields, $m_value='' ) {
542
 
543
- $main_id = $fields['id'];
544
-
545
- // Add appended fields
546
- if( isset($fields['structure']) ) {
547
-
548
- $fields = $fields['structure'];
549
- $settings = ( isset($fields['option'] ) ) ? $fields['option'] : false;
550
-
551
- if( is_array($fields) ) {
552
-
553
- ob_start();
554
-
555
- foreach( $fields as $id => $field ) {
556
-
557
- // Get the value
558
- $value = isset($m_value[$id]) ? $m_value[$id] : '';
559
-
560
- // Get the width
561
- $width = isset($field['width']) ? ' style="width:'.$field['width'].'"' : '';
562
-
563
- if( isset($field['type']) ) {
564
-
565
- $field['id'] = $main_id.'['.$pos.']['.$id.']';
566
-
567
- // Call the function to display the field
568
- if ( function_exists('mtphr_post_duplicator_metaboxer_'.$field['type']) ) {
569
-
570
- echo '<td'.$width.' class="mtphr-post-duplicator-metaboxer-list-structure-item mtphr-post-duplicator-metaboxer'.$main_id.'-'.$id.'" base="'.$main_id.'" field="'.$id.'">';
571
- call_user_func( 'mtphr_post_duplicator_metaboxer_'.$field['type'], $field, $value );
572
- echo '</td>';
573
- }
574
- }
575
- }
576
-
577
- return ob_get_clean();
578
- }
579
- }
580
- }
581
 
582
  /**
583
- * Renders a sort.
584
  *
585
  * @since 1.0.0
586
  */
587
- function mtphr_post_duplicator_metaboxer_sort( $field, $value='' ) {
588
 
589
- global $post;
590
-
591
- $rows = array();
592
- if( is_array($value) ) {
593
- foreach( $value as $id ) {
594
- $rows[$id] = $field['rows'][$id];
595
- }
596
- } else {
597
- $rows = $field['rows'];
598
- }
599
-
600
- $output = '<table>';
601
 
602
- foreach( $rows as $id => $data ) {
603
 
604
- $output .= '<tr class="mtphr-post-duplicator-metaboxer-sort-item"><td class="mtphr-post-duplicator-metaboxer-sort-item-handle"><span></span></td>';
605
- if( isset($data['name']) ) {
606
- $output .= '<td class="mtphr-post-duplicator-metaboxer-sort-name">'.$data['name'].'</td>';
607
- }
608
- $output .= '<td><input name="'.$field['id'].'[]" id="'.$field['id'].'[]" type="hidden" value="'.$id.'">';
609
-
610
- // Find the value
611
- $data_value = get_post_meta( $post->ID, $data['id'], true );
612
- if( $data_value == '' && isset($data['default']) ) {
613
- $data_value = $data['default'];
614
  }
615
-
616
- ob_start();
617
- // Call the function to display the field
618
- if ( function_exists('mtphr_post_duplicator_metaboxer_'.$data['type']) ) {
619
- call_user_func( 'mtphr_post_duplicator_metaboxer_'.$data['type'], $data, $data_value );
620
  }
621
- $output .= ob_get_clean();
622
 
623
- $output .= '</td>';
624
 
625
- $output .= '</tr>';
 
 
 
 
 
626
  }
627
 
628
- $output .= '</table>';
629
-
630
- echo $output;
631
 
632
  // Add appended fields
633
  mtphr_post_duplicator_metaboxer_append_field($field);
634
  }
635
 
636
- /**
637
- * Renders an html field.
638
- *
639
- * @since 1.0.0
640
- */
641
- function mtphr_post_duplicator_metaboxer_html( $field, $value='' ) {
642
-
643
- // Echo the html
644
- echo $value;
645
-
646
- // Add appended fields
647
- mtphr_post_duplicator_metaboxer_append_field($field);
648
- }
649
 
650
  /**
651
- * Renders a metabox toggle.
652
  *
653
- * @since 1.0.0
654
  */
655
- function mtphr_post_duplicator_metaboxer_metabox_toggle( $field, $value='' ) {
656
-
657
- if( isset($field['options']) ) {
658
-
659
- $output = '';
660
- $output .= '<input type="hidden" id="'.$field['id'].'" name="'.$field['id'].'" value="'.$value.'" />';
661
-
662
- foreach( $field['options'] as $i => $option ) {
663
-
664
- $button = $option['button'];
665
- $metaboxes = $option['metaboxes'];
666
- $metabox_list = join( ',', $metaboxes );
667
-
668
- // Create a button
669
- $selected = ( $value == $i ) ? ' button-primary' : '';
670
- $output .= '<a href="'.$i.'" metaboxes="'.$metabox_list.'" class="mtphr-post-duplicator-metaboxer-metabox-toggle button'.$selected.'">'.$button.'</a>&nbsp;';
671
- }
672
-
673
- echo $output;
674
- }
675
 
676
  // Add appended fields
677
  mtphr_post_duplicator_metaboxer_append_field($field);
@@ -679,268 +252,38 @@ function mtphr_post_duplicator_metaboxer_metabox_toggle( $field, $value='' ) {
679
 
680
 
681
 
682
-
683
  /**
684
- * Redners a file attachment
685
  *
686
  * @since 1.0.0
687
  */
688
- function mtphr_post_duplicator_metaboxer_file( $field, $value='' ) {
689
-
690
- // Check if there's actually a file
691
- $file = false;
692
- if( $value != '' ) {
693
- $file = get_post( $value );
694
- }
695
-
696
- // If there isn't a file reset the value
697
- if( !$file ) {
698
- $value = '';
699
- }
700
- ?>
701
-
702
- <input class="mtphr-post-duplicator-metaboxer-file-value" type="hidden" id="<?php echo $field['id']; ?>" name="<?php echo $field['id']; ?>" value="<?php echo $value; ?>" />
703
-
704
- <?php
705
- echo isset( $field['button'] ) ? '<a href="#" class="button mtphr-post-duplicator-metaboxer-file-upload">'.$field['button'].'</a>' : '<a href="#" class="button custom-media-upload">Insert File</a>';
706
-
707
- if( $file ) {
708
 
709
- $type = explode( '/', $file->post_mime_type );
710
-
711
- // Display the file
712
- echo mtphr_post_duplicator_metaboxer_file_display( $file->ID, $type[0], $file->guid, $file->post_title, $file -> post_excerpt, $file->post_content );
713
- }
714
-
715
  // Add appended fields
716
  mtphr_post_duplicator_metaboxer_append_field($field);
717
  }
718
 
719
- add_action( 'wp_ajax_mtphr_post_duplicator_metaboxer_ajax_file_display', 'mtphr_post_duplicator_metaboxer_ajax_file_display' );
720
- /**
721
- * Ajax function used to delete attachments
722
- *
723
- * @since 1.0.0
724
- */
725
- function mtphr_post_duplicator_metaboxer_ajax_file_display() {
726
-
727
- // Get access to the database
728
- global $wpdb;
729
-
730
- // Check the nonce
731
- check_ajax_referer( 'mtphr_dnt', 'security' );
732
-
733
- // Get variables
734
- $id = $_POST['id'];
735
- $type = $_POST['type'];
736
- $url = $_POST['url'];
737
- $title = $_POST['title'];
738
- $caption = $_POST['caption'];
739
- $description = $_POST['description'];
740
-
741
- // Display the file
742
- mtphr_post_duplicator_metaboxer_file_display( $id, $type, $url, $title, $caption, $description );
743
-
744
- die(); // this is required to return a proper result
745
- }
746
-
747
- // Display the file
748
- function mtphr_post_duplicator_metaboxer_file_display( $id, $type, $url, $title, $caption, $description ) {
749
-
750
- $src = '';
751
- switch( $type ) {
752
-
753
- case 'image':
754
- $att = wp_get_attachment_image_src( $id, 'thumbnail' );
755
- $src = $att[0];
756
- break;
757
-
758
- case 'application':
759
- $att = wp_get_attachment_image_src( $id, 'thumbnail', true );
760
- $src = $att[0];
761
- break;
762
- }
763
- ?>
764
- <table class="mtphr-post-duplicator-metaboxer-file-table">
765
- <tr>
766
- <td class="mtphr-post-duplicator-metaboxer-file-display">
767
- <a href="<?php echo $url; ?>" target="_blank" class="clearfix">
768
- <img class="custom_media_image" src="<?php echo $src; ?>" />
769
- <span class="mtphr-post-duplicator-metaboxer-file-title"><strong>Title:</strong> <?php echo $title; ?></span><br/>
770
- <?php if( $caption != '' ) { ?>
771
- <span class="mtphr-post-duplicator-metaboxer-file-caption"><strong>Caption:</strong> <?php echo $caption; ?></span><br/>
772
- <?php }
773
- if( $description != '' ) { ?>
774
- <span class="mtphr-post-duplicator-metaboxer-file-description"><strong>Description:</strong> <?php echo $description; ?></span>
775
- <?php } ?>
776
- </a>
777
- </td>
778
- <td class="mtphr-post-duplicator-metaboxer-file-delete">
779
- <a href="#"></a>
780
- </td>
781
- </tr>
782
- </table>
783
- <?php
784
- }
785
-
786
-
787
 
788
 
789
  /**
790
- * Render a gallery attachment
791
  *
792
  * @since 1.0.0
793
  */
794
- function mtphr_post_duplicator_metaboxer_gallery( $field, $value='' ) {
795
-
796
- /* Create the buttons */
797
- $button = isset( $field['button'] ) ? $field['button'] : 'Insert Media';
798
-
799
- $output = '<div class="mtphr-post-duplicator-metaboxer-attachment-buttons"><a href="#" class="button mtphr-post-duplicator-metaboxer-upload-button">'.$button.'</a></div>';
800
-
801
- /* If there is a file limit */
802
- if ( isset( $field['limit'] ) ) {
803
- $output .= '<input class="mtphr-post-duplicator-metaboxer-attachment-limit" type="hidden" value="'.$field['limit'].'" />';
804
- }
805
- $output .= '<div class="mtphr-post-duplicator-metaboxer-input-container" id="'.$field['id'].'"></div>';
806
- $output .= '<ul id="'.wp_create_nonce( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce' ).'" class="mtphr-post-duplicator-metaboxer-gallery-attachment-container mtphr-post-duplicator-metaboxer-attachment-container clearfix">';
807
-
808
- /* Loop through the existing attachments */
809
- if( $value != '' ){
810
- foreach( $value as $id ) {
811
- $output .= mtphr_post_duplicator_metaboxer_thumb( $id );
812
- }
813
- }
814
- $output .= '</ul>';
815
  echo $output;
816
 
817
  // Add appended fields
818
  mtphr_post_duplicator_metaboxer_append_field($field);
819
  }
820
 
821
- /**
822
- * Create the gallery thumbnail containers.
823
- *
824
- * @since 1.0.0
825
- */
826
- function mtphr_post_duplicator_metaboxer_thumb( $id, $preview=true ) {
827
-
828
- $html = '';
829
- $attachment = get_post( $id );
830
- $nonce = wp_create_nonce( 'mtphr_post_duplicator_metaboxer_ajax_file_nonce' );
831
-
832
- if ( $attachment ) {
833
-
834
- $mime = $attachment->post_mime_type;
835
-
836
- $html = '<li id="'.$id.'" class="mtphr-post-duplicator-metaboxer-gallery-attachment mtphr-post-duplicator-metaboxer-sort-container clearfix">';
837
-
838
- switch ( $mime ) {
839
-
840
- case 'image/jpeg':
841
- $thumb = wp_get_attachment_image_src( $id, 'metaboxer-gallery-thumb' );
842
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-image" style="background-image:url('.$thumb[0].');"></div>';
843
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-image"></div>';
844
- break;
845
-
846
- case 'image/png':
847
- $thumb = wp_get_attachment_image_src( $id, 'metaboxer-gallery-thumb' );
848
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-image" style="background-image:url('.$thumb[0].');"></div>';
849
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-image"></div>';
850
- break;
851
-
852
- case 'application/pdf':
853
- $thumb = wp_get_attachment_image_src( $id, false, true );
854
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-pdf" style="background-image:url('.$thumb[0].');"></div>';
855
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-pdf"></div>';
856
- break;
857
-
858
- case 'application/zip':
859
- $thumb = wp_get_attachment_image_src( $id, false, true );
860
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-zip" style="background-image:url('.$thumb[0].');"></div>';
861
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-zip"></div>';
862
- break;
863
-
864
- case 'audio/mpeg':
865
- $image_id = get_post_meta( $id, '_attachment_poster_image', true );
866
- $default = ( !$image_id || $image_id=='none' ) ? true : false;
867
- $thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
868
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-audio" style="background-image:url('.$thumb[0].');"></div>';
869
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-audio"></div>';
870
- break;
871
-
872
- case 'video/mp4':
873
- $image_id = get_post_meta( $id, '_attachment_poster_image', true );
874
- $default = ( !$image_id || $image_id=='none' ) ? true : false;
875
- $thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
876
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-video" style="background-image:url('.$thumb[0].');"></div>';
877
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-video"></div>';
878
- break;
879
-
880
- case 'video/m4v':
881
- $image_id = get_post_meta( $id, '_attachment_poster_image', true );
882
- $default = ( !$image_id || $image_id=='none' ) ? true : false;
883
- $thumb = ( $default ) ? wp_get_attachment_image_src( $id, false, true ) : wp_get_attachment_image_src( $image_id, 'metaboxer-gallery-thumb' );
884
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-video" style="background-image:url('.$thumb[0].');"></div>';
885
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-video"></div>';
886
- break;
887
-
888
- case 'vimeo':
889
- $thumb = get_post_meta( $id, '_video_thumb_large', true );
890
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-vimeo" style="background-image:url('.$thumb.');"></div>';
891
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-vimeo"></div>';
892
- break;
893
-
894
- case 'youtube':
895
- $thumb = get_post_meta( $id, '_video_thumb_large', true );
896
- $html .= '<div class="mtphr-post-duplicator-metaboxer-gallery-attachment-bg mtphr-post-duplicator-metaboxer-gallery-attachment-bg-youtube" style="background-image:url('.$thumb.');"></div>';
897
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-mime-type mtphr-post-duplicator-metaboxer-attachment-mime-type-youtube"></div>';
898
- break;
899
-
900
- default:
901
- // Call the function to display the custom field
902
- call_user_func( 'mtphr_post_duplicator_metaboxer_'.str_replace('%/%','_',$mime).'_thumb', $id, $nonce );
903
- $html .= $mime;
904
- break;
905
- }
906
-
907
- $html .= '<div class="mtphr-post-duplicator-metaboxer-attachment-links">';
908
- //$html .= '<a href="'.$id.'" rel="attachment_preview" class="mtphr-post-duplicator-metaboxer-attachment-preview"></a>';
909
- $html .= '<a href="'.$id.'" class="mtphr-post-duplicator-metaboxer-attachment-settings"></a>';
910
- $html .= '<a href="'.$id.'" class="mtphr-post-duplicator-metaboxer-attachment-delete"></a>';
911
- $html .= '</div>';
912
-
913
- $html .= '</li>';
914
- }
915
-
916
- return $html;
917
- }
918
-
919
-
920
-
921
 
922
- /**
923
- * Renders the code fields.
924
- *
925
- * @since 1.0.0
926
- */
927
- function mtphr_post_duplicator_metaboxer_code( $field, $value='' ) {
928
-
929
- global $post;
930
-
931
- // Display the shortcode code
932
- if( $field['id'] == '_mtphr_post_duplicator_shortcode' ) {
933
-
934
- echo '<pre><p>[ditty_news_ticker id="'.$post->ID.'"]</p></pre>';
935
-
936
- // Display the function code
937
- } elseif( $field['id'] == '_mtphr_post_duplicator_function' ) {
938
-
939
- echo '<pre><p>ditty_news_ticker('.$post->ID.');</p></pre>';
940
- }
941
-
942
- // Display a "Select All" button
943
- $button = isset($field['button']) ? $field['button'] : __('Select Code', 'post-duplicator');
944
- echo '<a href="#" class="button mtphr-post-duplicator-metaboxer-code-select">'.$button.'</a>';
945
- }
946
 
2
  /**
3
  * Put all the Metaboxer admin function here fields here
4
  *
5
+ * @package Post Duplicator
6
  * @author Metaphor Creations
7
  * @license http://www.opensource.org/licenses/gpl-license.php GPL v2.0 (or later)
 
 
8
  */
9
 
10
 
68
 
69
 
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  /**
73
  * Append fields
122
  }
123
 
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
  /**
127
  * Renders a select field.
159
  mtphr_post_duplicator_metaboxer_append_field($field);
160
  }
161
 
162
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
 
164
  /**
165
+ * Renders a radio custom field.
166
  *
167
  * @since 1.0.0
168
  */
169
+ function mtphr_post_duplicator_metaboxer_radio( $field, $value='' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
+ if( isset($field['options']) ) {
172
+
173
+ $output = '';
174
+ $break = '<br/>';
175
+ if ( isset($field['display']) ) {
176
+ if( $field['display'] == 'inline' ) {
177
+ $break = '&nbsp;&nbsp;&nbsp;&nbsp;';
178
+ }
179
  }
180
+ foreach( $field['options'] as $i => $option ) {
181
+ $checked = ( $value == $i ) ? 'checked="checked"' : '';
182
+ $output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="radio" value="'.$i.'" '.$checked.' /> '.$option.'</label>'.$break;
183
+ }
184
  }
185
 
 
 
 
 
 
 
 
 
186
  echo $output;
187
 
188
  // Add appended fields
189
  mtphr_post_duplicator_metaboxer_append_field($field);
190
  }
191
 
 
 
 
 
 
 
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
 
194
  /**
195
+ * Renders a checkbox.
196
  *
197
  * @since 1.0.0
198
  */
199
+ function mtphr_post_duplicator_metaboxer_checkbox( $field, $value='' ) {
200
 
201
+ $output = '';
202
+ $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
203
+ $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
 
 
 
 
 
 
 
 
 
204
 
205
+ if( isset($field['options']) ) {
206
 
207
+ $break = '<br/>';
208
+ if ( isset($field['display']) ) {
209
+ if( $field['display'] == 'inline' ) {
210
+ $break = '&nbsp;&nbsp;&nbsp;&nbsp;';
211
+ }
 
 
 
 
 
212
  }
213
+ foreach( $field['options'] as $i => $option ) {
214
+ $checked = ( isset($value[$i]) ) ? 'checked="checked"' : '';
215
+ $output .= '<label><input name="'.$field['id'].'['.$i.']" id="'.$field['id'].'['.$i.']" type="checkbox" value="1" '.$checked.' /> '.$option.'</label>'.$break;
 
 
216
  }
 
217
 
218
+ } else {
219
 
220
+ $checked = ( $value == 1 ) ? 'checked="checked"' : '';
221
+ $output .= '<label><input name="'.$field['id'].'" id="'.$field['id'].'" type="checkbox" value="1" '.$checked.' />';
222
+ if( isset($field['label']) ) {
223
+ $output .= ' '.$field['label'];
224
+ }
225
+ $output .= '</label>';
226
  }
227
 
228
+ echo $before.$output.$after;
 
 
229
 
230
  // Add appended fields
231
  mtphr_post_duplicator_metaboxer_append_field($field);
232
  }
233
 
234
+
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  /**
237
+ * Renders an text field.
238
  *
239
+ * @since 1.0.1
240
  */
241
+ function mtphr_post_duplicator_metaboxer_text( $field, $value='' ) {
242
+ $size = ( isset($field['size']) ) ? $field['size'] : 40;
243
+ $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
244
+ $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
245
+ $text_align = ( isset($field['text_align']) ) ? ' style="text-align:'.$field['text_align'].'"' : '' ;
246
+ $output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="text" value="'.$value.'" size="'.$size.'"'.$text_align.'>'.$after;
247
+ echo $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
  // Add appended fields
250
  mtphr_post_duplicator_metaboxer_append_field($field);
252
 
253
 
254
 
 
255
  /**
256
+ * Renders a textarea.
257
  *
258
  * @since 1.0.0
259
  */
260
+ function mtphr_post_duplicator_metaboxer_textarea( $field, $value='' ) {
261
+ $rows = ( isset($field['rows']) ) ? $field['rows'] : 5;
262
+ $cols = ( isset($field['cols']) ) ? $field['cols'] : 40;
263
+ $output = '<textarea name="'.$field['id'].'" id="'.$field['id'].'" rows="'.$rows.'" cols="'.$cols.'">'.$value.'</textarea>';
264
+ echo $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
 
 
 
 
 
 
266
  // Add appended fields
267
  mtphr_post_duplicator_metaboxer_append_field($field);
268
  }
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
 
271
 
272
  /**
273
+ * Renders an number field.
274
  *
275
  * @since 1.0.0
276
  */
277
+ function mtphr_post_duplicator_metaboxer_number( $field, $value='' ) {
278
+ $style = ( isset($field['style']) ) ? ' style="'.$field['style'].'"' : '';
279
+ $before = ( isset($field['before']) ) ? '<span>'.$field['before'].' </span>' : '';
280
+ $after = ( isset($field['after']) ) ? '<span> '.$field['after'].'</span>' : '';
281
+ $output = $before.'<input name="'.$field['id'].'" id="'.$field['id'].'" type="number" value="'.$value.'" class="small-text"'.$style.'>'.$after;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  echo $output;
283
 
284
  // Add appended fields
285
  mtphr_post_duplicator_metaboxer_append_field($field);
286
  }
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
289