-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpage-collect.php
executable file
·784 lines (515 loc) · 28.9 KB
/
page-collect.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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
<?php
/*
Template Name: Add to Collection
*/
// set blanks
$wTitle = $wSource = $wTags = $wNotes = $wEmail = $wAlt = $w_thumb_status = $wAccess = '';
$wFeatureImageID = $wCommentNotify = $post_id = 0;
$is_re_edit = $linkEmailed = $wAccessCodeOk = $is_published = false;
$errors = array();
// default welcome message
$feedback_msg = trucollector_form_default_prompt();
$wAuthor = 'Anonymous';
// initial button states
$previewBtnState = ' disabled';
$submitBtnState = ' disabled';
$box_style = '<div class="notify"><span class="symbol icon-info"></span> ';
$wCats = array( trucollector_option('def_cat') ); // preload default category
$wText = trucollector_option('def_text'); // default text for editing field
$wAltRequired = trucollector_option('img_alt');
$wLicense = '--'; // default license
$all_licenses = trucollector_get_licences();
// see if we have an incoming clear the code form variable only on collection form
// ignored if options are not to use it or we are in the customizer
// Thanks @troywelcg for catching a parenthetical error
$wAccessCodeOk = ((isset( $_POST['wAccessCodeOk'] )) ? true : (is_customize_preview())) ? true : false;
// check that an access code is in play and it's not been yet passed
if ( !empty( trucollector_option('accesscode') ) AND !$wAccessCodeOk ) {
// now see if we are to check the access code
if ( isset( $_POST['trucollector_form_access_submitted'] )
AND wp_verify_nonce( $_POST['trucollector_form_access_submitted'], 'trucollector_form_access' ) ) {
// grab the entered code from form
$wAccess = stripslashes( $_POST['wAccess'] );
// Validation of the code
if ( $wAccess != trucollector_option('accesscode') ) {
$box_style = '<div class="notify notify-red"><span class="symbol icon-error"></span> ';
$feedback_msg = '<strong>Incorrect Access Code</strong> - try again? Hint: ' . trucollector_option('accesshint') . '.';
} else {
$wAccessCodeOk = true;
}
} else {
$box_style = '<div class="notify"><span class="symbol icon-info"></span> ';
$feedback_msg = 'An access code is required to use the collection form on "' . get_bloginfo('name') . '".';
} // form check access code
} else {
// set flag true just to clear all the other gates
$wAccessCodeOk = true;
} // access code in play check
// ------------------- form processing ------------------------
// verify that a form was submitted and it passes the nonce check
if ( isset( $_POST['trucollector_form_make_submitted'] ) && wp_verify_nonce( $_POST['trucollector_form_make_submitted'], 'trucollector_form_make' ) ) {
// grab the variables from the form
$wTitle = ( isset ($_POST['wTitle'] ) ) ? sanitize_text_field( stripslashes( $_POST['wTitle'] ) ) : '';
$wAuthor = ( isset ($_POST['wAuthor'] ) ) ? sanitize_text_field( stripslashes($_POST['wAuthor']) ) : 'Anonymous';
$wTags = ( isset ($_POST['wTags'] ) ) ? sanitize_text_field( $_POST['wTags'] ) : '';
$wEmail = ( isset ($_POST['wEmail'] ) ) ? sanitize_text_field( $_POST['wEmail'] ) : '';
$wText = ( isset ($_POST['wText'] ) ) ? wp_kses_post( $_POST['wText'] ) : '';
$wSource = ( isset ($_POST['wSource'] ) ) ? sanitize_text_field( stripslashes( $_POST['wSource'] ) ) : '';
$wNotes = ( isset ($_POST['wNotes'] ) ) ? sanitize_text_field( stripslashes( $_POST['wNotes'] ) ) : '';
$wFeatureImageID = ( isset ( $_POST['wFeatureImage'] ) ) ? $_POST['wFeatureImage'] : 0;
$wAlt = ( isset ($_POST['wAlt'] ) ) ? sanitize_text_field($_POST['wAlt']) : '';
$wCats = ( isset ($_POST['wCats'] ) ) ? $_POST['wCats'] : array( trucollector_option('def_cat') );
$wLicense = ( isset ( $_POST['wLicense'] ) ) ? $_POST['wLicense'] : '';
$wCommentNotify = ( isset ( $_POST['wCommentNotify'] ) ) ? 1 : 0;
if ( isset ($_POST['post_id'] ) ) $post_id = $_POST['post_id'];
// upload header image if we got one
if ($_FILES) {
foreach ( $_FILES as $file => $array ) {
$newupload = trucollector_insert_attachment( $file, $post_id );
if ( $newupload ) {
$wFeatureImageID = $newupload;
$w_thumb_status = 'Image uploaded. Choose another to replace it.';
}
}
}
if ( $wTitle == '' ) $errors[] = '<strong>Title Missing</strong> - enter a descriptive title for this ' . get_trucollector_collection_single_item() . '.';
// do we have image?
if ( $wFeatureImageID == 0) {
$errors[] = '<strong>Image File Missing</strong> - upload the image you wish to add to represent this ' . get_trucollector_collection_single_item() . '.';
}
if ( trucollector_option('img_alt') == '1' AND $wAlt == '' ) $errors[] = '<strong>Image Alternative Text Missing</strong> - please enter text description to make your image accessible for visually impaired visitors.';
if ( trucollector_option('use_caption') == '2' AND $wText == '' ) $errors[] = '<strong>Description Missing</strong> - please enter a detailed description for this ' . get_trucollector_collection_single_item() . '.';
if ( trucollector_option('use_source') == '2' AND $wSource == '' ) $errors[] = '<strong>Source Missing</strong> - please the name or organization to credit as the source of this image.';
if ( trucollector_option('use_license') == '2' AND $wLicense == '--' ) $errors[] = '<strong>No License Selected</strong> - select an appropriate license for this ' . get_trucollector_collection_single_item() . '.';
// test for email only if enabled in options
if ( trucollector_option('show_email') == '1' ) {
// check first for valid email address, blank is ok
if ( is_email( $wEmail ) OR empty($wEmail) ) {
// if email is good then check if we are limiting to domains
if ( !empty(trucollector_option('email_domains')) AND !trucollector_allowed_email_domain( $wEmail ) ) {
$errors[] = '<strong>Email Address Not Allowed</strong> - The email address you entered <code>' . $wEmail . '</code> is not from a domain accepted for this site. This site requests that addresses are ones from domain[s] <code>' . trucollector_option('email_domains') . '</code>. ';
}
} else {
// bad email, sam.
$errors[] = '<strong>Invalid Email Address</strong> - the email address entered <code>' . $wEmail . '</code> is not valid. Pleae check and try again. To skip entering an email address, make sure the field is empty. ';
}
} elseif ( trucollector_option('show_email') == '2' ) {
// now test for case where email is required
if (empty( $wEmail ) ) {
// ding ding, no email
$errors[] = '<strong>Email Address Missing</strong> - an email address is required for this site. Please enter one.';
} elseif ( is_email( $wEmail ) ) {
// if email is good then check if we are limiting to domains
if ( !empty(trucollector_option('email_domains')) AND !trucollector_allowed_email_domain( $wEmail ) ) {
$errors[] = '<strong>Email Address Not Allowed</strong> - The email address you entered <code>' . $wEmail . '</code> is not from an domain accepted in this site. This site requests that addresses are ones with domains <code>' . trucollector_option('email_domains') . '</code>. ';
}
} else {
// bad email, sam.
$errors[] = '<strong>Invalid Email Address</strong> - the email address entered <code>' . $wEmail . '</code> is not valid. Pleae check and try again.';
}
}
if ( count($errors) > 0 ) {
// form errors, build feedback string to display the errors
$feedback_msg = 'Sorry, but there are a few errors in your submission. Please correct and try again. We really want to add your ' . get_trucollector_collection_single_item() . '.<ul>';
// Hah, each one is an oops, get it?
foreach ($errors as $oops) {
$feedback_msg .= '<li>' . $oops . '</li>';
}
$feedback_msg .= '</ul>';
// reset button states
$previewBtnState = ' disabled';
$submitBtnState = ' disabled';
$box_style = '<div class="notify notify-red"><span class="symbol icon-error"></span> ';
} else { // good enough, let's set up a post!
$post_status = trucollector_option('new_item_status');
if ($post_status == 'draft') $post_status = 'pending'; // fix wrong status from older versions
if ( isset( $_POST['makeit'] ) ) {
// set status (will be either 'publish' or 'pending') for post based on theme settings
$post_status = trucollector_option('new_item_status');
$is_published = true;
$box_style = '<div class="notify"><span class="symbol icon-info"></span> ';
// set up notifications, email messages for later use
if ( $post_status == 'publish' ) {
// feed back for published item
// feed back for published item
$feedback_msg = 'Your ' . get_trucollector_collection_single_item() . ' "' . $wTitle . '" has been published! ';
// if user provided email address (only possible if the feature enabled), send instructions to use link to edit
if ( $wEmail != '' ) {
$feedback_msg .= 'Since you provided an email address, a message has been sent to <strong>' . $wEmail . '</strong> with a special link that can be used at any time later to edit this ' . get_trucollector_collection_single_item() . '. ';
} else {
$feedback_msg .= ' You might want to save this link <code>' . trucollector_get_edit_link( $post_id ) . '</code> in a safe place as it allows you to edit your ' . get_trucollector_collection_single_item() . ' at a later time. ';
} // wEmail != ''
$feedback_msg .= 'You can <a href="'. get_permalink( $post_id ) . '">view it now</a> or <a href="' . site_url() . '">return to ' . get_bloginfo() . '</a>.';
// for email
$message = 'A new ' . get_trucollector_collection_single_item() . ' <strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been published to ' . get_bloginfo() . '. You can <a href="'. site_url() . '/?p=' . $post_id . '">view it now</a>';
} else {
$feedback_msg = 'Your ' . get_trucollector_collection_single_item() . ' "' . $wTitle . '" is now in the queue for publishing. ';
if ( $wEmail != '' ) {
$feedback_msg .= 'Since you provided an email address, a message has been sent to <strong>' . $wEmail . '</strong> with a special link that can be used at any time later to edit this ' . get_trucollector_collection_single_item() . '. ';
} else {
$feedback_msg .= ' You might want to save this link <code>' . trucollector_get_edit_link( $post_id ) . '</code> in a safe place as it allows you to edit your ' . get_trucollector_collection_single_item() . ' at a later time. ';
} // wEmail != ''
$feedback_msg .= 'You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true&ispre=1' . '" target="_blank">preview it now</a> (link opens in a new window). It will appear on <strong>' . get_bloginfo() . '</strong> as soon as it has been reviewed. Now you can <a href="' . site_url() . '">return to ' . get_bloginfo() . '</a>.';
$message = 'A new ' . get_trucollector_collection_single_item() . ' <strong>"' . $wTitle . '"</strong> written by <strong>' . $wAuthor . '</strong> has been submitted to ' . get_bloginfo() . '. You can <a href="'. site_url() . '/?p=' . $post_id . 'preview=true' . '">preview it now</a>.<br /><br /> To publish it, simply <a href="' . admin_url( 'edit.php?post_status=pending&post_type=post') . '">find it in the pending items</a> and change its status from <strong>Pending</strong> to <strong>Publish</strong>';
} // post_status == 'publish / pending'
} else {
// updated button clicked
$post_status = 'draft';
$box_style = '<div class="notify notify-green"><span class="symbol icon-tick"></span> ';
$feedback_msg = 'Your draft has been updated and can again be <a href="'. site_url() . '/?p=' . $post_id . '&preview=true&ispre=1' . '" target="_blank">previewed</a> to review changes. When ready to publish <a href="#theButtons">just scroll down</a> and click "Share Now" to add it to' . get_bloginfo( 'name' ) . '.';
// enable preview and submit buttons
$previewBtnState = '';
$submitBtnState = '';
} // isset( $_POST['makeit'] )
$w_information = array(
'post_title' => $wTitle,
'post_content' => $wText,
'post_category' => $wCats,
'post_status' => $post_status
);
// Is this a first draft?
if ( $post_id == 0 ) {
// insert as a new post
$post_id = wp_insert_post( $w_information );
// store the author as post meta data
add_post_meta($post_id, 'shared_by', $wAuthor);
// store the email as post meta data
add_post_meta($post_id, 'wEmail', $wEmail);
// store the source of the image (text or URL)
if ( trucollector_option('use_source') > 0 ) {
add_post_meta($post_id, 'source', $wSource);
}
// store the license code
if ( trucollector_option('use_license') > 0 ) {
add_post_meta($post_id, 'license', $wLicense);
}
// store notes for editor
if ( $wNotes ) add_post_meta($post_id, 'editor_notes', $wNotes);
// track the comment notification preference
if ( trucollector_option( 'allow_comments' ) ) add_post_meta($post_id, 'wCommentNotify', $wCommentNotify);
// add the tags
wp_set_post_tags( $post_id, $wTags);
// set featured image
set_post_thumbnail( $post_id, $wFeatureImageID);
// update featured image alt
update_post_meta($wFeatureImageID, '_wp_attachment_image_alt', $wAlt);
// create an edit key
trucollector_make_edit_link( $post_id );
if ( $wEmail != '' ) {
trucollector_mail_edit_link( $post_id, 'draft' );
$linkEmailed = true;
}
// feedback for first check of item
$feedback_msg = 'A draft of your ' . get_trucollector_collection_single_item() . ' has been saved. You can <a href="'. site_url() . '/?p=' . $post_id . '&preview=true&ispre=1' . '" target="_blank">preview it now</a>. This will open in a new tab/window. Or make any changes below, check your information again and/or <a href="#theButtons">scroll down</a> to submit it to ' . get_bloginfo() . '.';
} else {
// the post exists, let's update and process the post
// check if we have a publish button click
if ( isset ( $_POST['makeit'] ) ) { // final processing
if ( trucollector_option( 'notify' ) != '') {
// Let's do some EMAIL!
// who gets mail? They do.
$to_recipients = explode( "," , trucollector_option( 'notify' ) );
$subject = 'New ' . get_trucollector_collection_single_item() . ' submitted to ' . get_bloginfo();
if ( $wNotes ) $message .= '<br /><br />There are some extra notes from the author:<blockquote>' . $wNotes . '</blockquote>';
// turn on HTML mail
add_filter( 'wp_mail_content_type', 'set_html_content_type' );
// mail it!
wp_mail( $to_recipients, $subject, $message);
// Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
} else {
// updated but still in draft mode
// if user provided email address, send instructions to use link to edit if not done before
if ( isset( $wEmail ) and !$linkEmailed ) trucollector_mail_edit_link( $post_id, 'draft' );
} // isset( $_POST['makeit']
// add the id to our array of post information so we can issue an update
$w_information['ID'] = $post_id;
// update the post
wp_update_post( $w_information );
// store the author as post meta data
update_post_meta($post_id, 'shared_by', $wAuthor);
// store the email as post meta data
update_post_meta($post_id, 'wEmail', $wEmail);
// store the source of the image (text or URL)
if ( trucollector_option('use_source') > 0 ) {
update_post_meta($post_id, 'source', $wSource);
}
// store the license code
if ( trucollector_option('use_license') > 0 ) {
update_post_meta($post_id, 'license', $wLicense);
}
// store notes for editor
if ( $wNotes ) update_post_meta($post_id, 'editor_notes', $wNotes);
// track the comment notification preference
if ( trucollector_option( 'allow_comments' ) ) update_post_meta($post_id, 'wCommentNotify', $wCommentNotify);
// update the tags
wp_set_post_tags( $post_id, $wTags);
// set featured image
set_post_thumbnail( $post_id, $wFeatureImageID);
// update featured image alt
update_post_meta($wFeatureImageID, '_wp_attachment_image_alt', $wAlt);
} // isset( $_POST['makeit']
} // post_id = 0
} // count errors
} elseif ( $wAccessCodeOk ) {
// first time entry
// default welcome message
$box_style = '<div class="notify"><span class="symbol icon-info"></span> ';
// ------------------------ re-edit check ------------------------
// check for query vars that indicate this is a edit request
$tk = get_query_var( 'tk', 0 ); // magic token to check
// is re-edit attempt
if ( ( $tk ) ) {
$is_re_edit = true;
$wid = trucollector_get_id_from_tk( $tk );
if ( $wid ) {
// found a post with the matching code, so set up for re-edit
// default welcome message for a re-edit
$feedback_msg = trucollector_form_re_edit_prompt();
// get the post and then content for this item
$item = get_post( $wid );
$wText = $item->post_content;
$wTitle = get_the_title( $wid );
$wAuthor = get_post_meta( $wid, 'shared_by', 1 );
$wEmail = get_post_meta( $wid, 'wEmail', 1 );
$box_style = '<div class="notify notify-green"><span class="symbol icon-tick"></span> ';
// get categories
$categories = get_the_category( $wid);
foreach ( $categories as $category ) {
$wCats[] = $category->term_id;
}
// festured image
$wFeatureImageID = get_post_thumbnail_id( $wid );
// get image alt tag
$wAlt = get_post_meta($wFeatureImageID, '_wp_attachment_image_alt', true);
// source
$wSource = get_post_meta( $wid, 'source', 1 );
// notes
$wNotes = get_post_meta( $wid, 'editor_notes', 1 );
// license
$wLicense = get_post_meta( $wid, 'license', 1 );
// comment notification preference
$wCommentNotify = get_post_meta( $wid, 'wCommentNotify', 1 );
// load the tags
$wTags = implode(', ', wp_get_post_tags( $wid, array( 'fields' => 'names' ) ) );
// post id
$post_id = $wid;
} else {
// no posts found with matching key
$is_re_edit = false;
// updates for display
$errors[] = '<strong>Token Mismatch</strong> - please check the url provided.';
// default welcome message
$feedback_msg = 'This URL does not match the edit key. Please check the link from your email again, or return to your published ' . get_trucollector_collection_single_item() . ' and click the button at the bottom to send an edit link.';
$is_published = true; // not really but it serves to hide the form.
$box_style = '<div class="notify notify-red"><span class="symbol icon-error"></span> ';
} // end is wid
} // end is tk
} // end form submmitted check
?>
<?php get_header(); ?>
<div class="content thin">
<?php
if ( have_posts() ) :
while ( have_posts() ) : the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class( 'post single' ); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail_size' ); $thumb_url = $thumb['0']; ?>
<?php elseif ( has_post_thumbnail() ) : ?>
<div class="featured-media">
<?php the_post_thumbnail( 'post-image' ); ?>
</div><!-- .featured-media -->
<?php endif; ?>
<div class="post-inner">
<div class="post-header">
<h2 class="post-title"><?php the_title(); ?></h2>
</div> <!-- /post-header section -->
<div class="post-content">
<?php the_content(); ?>
<?php echo $box_style . $feedback_msg . '</div>';?>
<?php if (!$wAccessCodeOk) : // show the access code form ?>
<form id="splotboxform" method="post" action="">
<fieldset>
<label for="wAccess">Access Code</label><br />
<p>Enter the special code to access the sharing form</p>
<input type="text" name="wAccess" id="wAccess" class="required" value="<?php echo $wAccess?>" />
</fieldset>
<fieldset>
<?php wp_nonce_field( 'trucollector_form_access', 'trucollector_form_access_submitted' )?>
<input type="submit" class="pretty-button pretty-button-final" value="Check Code" id="checkit" name="checkit">
</fieldset>
</form>
<?php elseif ( !$is_published ) : // show form it has not been published ?>
<form id="collectorform" class="collectorform" method="post" action="" enctype="multipart/form-data">
<fieldset id="theTitle">
<label for="wTitle"><?php trucollector_form_item_title() ?> (required)</label><br />
<p><?php trucollector_form_item_title_prompt() ?> </p>
<input type="text" name="wTitle" id="wTitle" class="required" value="<?php echo $wTitle; ?>" tabindex="1" />
</fieldset>
<fieldset id="theHeaderImage">
<label for="headerImage"><?php trucollector_form_item_upload() ?> (required)</label>
<div class="uploader">
<input id="wFeatureImage" name="wFeatureImage" type="hidden" value="<?php echo $wFeatureImageID?>" />
<?php
if ($wFeatureImageID) {
// header image identified
$defthumb = wp_get_attachment_image_src( $wFeatureImageID, 'thumbnail' );
} else {
// header image optional, use placeholder
$defthumb = [];
$defthumb[] = 'https://place-hold.it/150x150?text=Upload+Image';
}
echo '<img src="' . $defthumb[0] . '" alt="Upload Image" id="headerthumb" />';
?>
<input id="wDefThumbURL" name="wDefThumbURL" type="hidden" value="<?php echo $defthumb[0]?>" />
</div>
<p><?php trucollector_form_item_upload_prompt() ?> <span id="uploadresponse"><?php echo $w_thumb_status?></span><br clear="left"></p>
<div id="splotdropzone">
<input type="file" accept="image/*" name="wUploadImage" id="wUploadImage">
<p id="dropmessage">Drag file or click to select file to upload</p>
</div>
</fieldset>
<fieldset id="theAlt">
<?php
$required = (trucollector_option('img_alt') == 1) ? '(required)' : '(highly reccomennded)';
?>
<label for="wAlt"><?php trucollector_form_item_img_alt()?> <?php echo $required?></label><br />
<p><?php trucollector_form_item_img_alt_prompt()?></p>
<input type="text" name="wAlt" id="wAlt" value="<?php echo $wAlt; ?>" tabindex="3" />
</fieldset>
<fieldset id="theAuthor">
<label for="wAuthor"><?php trucollector_form_item_author()?></label><br />
<p><?php trucollector_form_item_author_prompt()?></p>
<input type="text" name="wAuthor" id="wAuthor" class="required" value="<?php echo $wAuthor; ?>" tabindex="4" />
</fieldset>
<?php if ( trucollector_option('use_caption') > '0'):
$required = (trucollector_option('use_caption') == 2) ? '(required)' : '';
?>
<fieldset id="theText">
<label for="wText"><?php trucollector_form_item_description() ?> <?php echo $required?> </label>
<p><?php trucollector_form_item_description_prompt()?> </p>
<?php if ( trucollector_option('caption_field') == 's'):?>
<input id="wRichText" type="hidden" value="0">
<textarea name="wText" id="wText" rows="4" tabindex="5"><?php echo stripslashes( $wText );?></textarea><p style="font-size:0.8rem">To create hyperlinks use this shortcode<br /><code>[link url="http://www.themostamazingwebsiteontheinternet.com/" text="the coolest site on the internet"]</code><br />If you omit <code>text=</code> the URL will be the link text.</p>
<?php else:?>
<input id="wRichText" type="hidden" value="1">
<?php
// set up for inserting the WP post editor
$settings = array( 'textarea_name' => 'wText', 'editor_height' => '300', 'tabindex' => "6", 'media_buttons' => true, 'drag_drop_upload' => true);
wp_editor( stripslashes( $wText ), 'wTextHTML', $settings );
?>
<?php endif?>
</fieldset>
<?php endif?>
<?php if ( trucollector_option('use_source') > '0'):
$required = (trucollector_option('use_source') == 2) ? '(required)' : '';
?>
<fieldset id="theSource">
<label for="wSource"><?php trucollector_form_item_image_source() ?> <?php echo $required?></label>
<p><?php trucollector_form_item_image_source_prompt() ?></p>
<input type="text" name="wSource" id="wSource" class="required" value="<?php echo $wSource; ?>" tabindex="7" />
</fieldset>
<?php endif?>
<?php if ( trucollector_option('use_license') > '0'):
$required = (trucollector_option('use_license') == 2) ? '(required)' : '';
?>
<fieldset id="theLicense">
<label for="wLicense"><?php trucollector_form_item_license() ?> <?php echo $required?></label>
<p><?php trucollector_form_item_license_prompt() ?></p>
<select name="wLicense" id="wLicense" tabindex="8" />
<option value="--">Select a License</option>
<?php
foreach ($all_licenses as $key => $value) {
$selected = ( $key == $wLicense ) ? ' selected' : '';
echo '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
?>
</select>
</fieldset>
<?php endif?>
<?php if ( trucollector_option( 'show_attribution' ) == 1 ): ?>
<input id="wAttributionPreview" type="hidden" value="1">
<?php endif?>
<?php if (trucollector_option('show_cats') == '1' ):?>
<fieldset id="theCats">
<label for="wCats"><?php trucollector_form_item_categories() ?></label>
<p><?php trucollector_form_item_categories_prompt() ?></p>
<?php
// arguments for request of categories
$args = array(
'hide_empty' => 0,
);
$article_cats = get_categories( $args );
foreach ( $article_cats as $acat ) {
$checked = ( in_array( $acat->term_id, $wCats) ) ? ' checked="checked"' : '';
echo '<label><input type="checkbox" name="wCats[]" tabindex="9" value="' . $acat->term_id . '"' . $checked . '> ' . $acat->name . '</label><br />';
}
?>
</fieldset>
<?php endif?>
<?php if (trucollector_option('show_tags') == '1' ):?>
<fieldset id="theTags">
<label for="wTags"><?php trucollector_form_item_tags() ?></label>
<p><?php trucollector_form_item_tags_prompt() ?></p>
<input type="text" name="wTags" id="wTags" value="<?php echo $wTags; ?>" tabindex="10" />
</fieldset>
<?php endif?>
<?php if (trucollector_option('show_email') ):?>
<fieldset id="theEmail">
<label for="wEmail"><?php trucollector_form_item_email() ?> (<?php echo ( trucollector_option('show_email') == '2' ) ? 'required' : 'optional'?>)</label><br />
<p><?php trucollector_form_item_email_prompt() ?>
<?php
if ( !empty( trucollector_option('email_domains') ) ) {
echo ' Allowable email addresses must be ones from domains <code>' . trucollector_option('email_domains') . '</code>.';
}
?>
</p>
<input type="text" name="wEmail" id="wEmail" name="wEmail" value="<?php echo $wEmail; ?>" />
<?php if (trucollector_option('allow_comments') ):?>
<label for="wCommentNotify" style="display:none;">Comment Notification</label>
<?php $checked = ( $wCommentNotify ) ? ' checked="checked"' : '';?>
<input type="checkbox" name="wCommentNotify" value="1"<?php echo $checked?>> Send notifications of comments to this address
<?php endif?>
</fieldset>
<?php endif?>
<?php if (trucollector_option('show_notes') ):?>
<fieldset id="theNotes">
<label for="wNotes"><?php trucollector_form_item_editor_notes() ?></label>
<p><?php trucollector_form_item_editor_notes_prompt() ?></p>
<textarea name="wNotes" id="wNotes" rows="10" tabindex="11"><?php echo stripslashes( $wNotes );?></textarea>
</fieldset>
<?php endif?>
<fieldset id="theButtons">
<label for="theButtons"><?php trucollector_form_item_submit_buttons() ?></label>
<?php wp_nonce_field( 'trucollector_form_make', 'trucollector_form_make_submitted' ); ?>
<p><?php trucollector_form_item_submit_buttons_prompt() ?></p>
<?php if ( $post_id ) : //draft saved at least once?>
<?php
// set up button names
if ( $is_re_edit ) {
$save_btn_txt = "Publish Changes";
} else {
$save_btn_txt = ( trucollector_option('new_item_status') == 'publish') ? "Share Now" : "Submit for Review";
}
?>
<input type="submit" value="Check Info" id="checkit" name="checkit">
<a href="<?php echo site_url() . '/?p=' . $post_id . '&preview=true&ispre=1'?>" title="Preview of your item." id="wPreview" class="fbutton<?php echo $previewBtnState?>" target="_blank">Preview</a>
<input type="submit" value="<?php echo $save_btn_txt?>" id="makeit" name="makeit" <?php echo $submitBtnState?>>
<?php else:?>
<input type="submit" value="Check and Review" id="checkit" name="checkit">
<?php endif?>
<input name="post_id" type="hidden" value="<?php echo $post_id?>" />
<input name="wAccessCodeOk" type="hidden" value="true" />
</fieldset>
</form>
<?php endif?>
</div>
</div> <!-- /post-inner -->
</div><!-- .post -->
<?php
endwhile;
endif;
?>
</div><!-- .content -->
<?php get_footer(); ?>