-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
options.php
957 lines (828 loc) · 27.4 KB
/
options.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
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
<?php
/**
* Plugin options page.
*
* @package Credit_Tracker
* @author Labs64 <[email protected]>
* @license GPL-2.0+
* @link https://www.labs64.com
* @copyright 2013 Labs64
*/
define('CREDITTRACKER_OPTIONS', 'CREDITTRACKER_OPTIONS');
define('CREDITTRACKER_API_KEY', '31c7bc4e-90ff-44fb-9f07-b88eb06ed9dc');
if (is_admin()) {
// Add the options page and menu item.
add_action('admin_menu', 'credittracker_add_plugin_page');
add_action('admin_init', 'credittracker_page_init');
// Add an action link pointing to the options page.
$plugin_basename = plugin_basename(plugin_dir_path(__FILE__) . 'credit-tracker.php');
add_filter('plugin_action_links_' . $plugin_basename, 'credittracker_add_action_links');
// Load admin style sheet and JavaScript.
add_action('admin_enqueue_scripts', 'credittracker_enqueue_admin_styles');
add_action('admin_enqueue_scripts', 'credittracker_enqueue_admin_scripts');
// Get media data callback registration
add_action('wp_ajax_validate', 'credittracker_validate_callback');
add_action('wp_ajax_get_media_data', 'credittracker_get_media_data_callback');
}
/**
* Add settings action link to the plugins page.
*/
function credittracker_add_action_links($links)
{
return array_merge(
array(
'settings' => '<a href="' . admin_url('options-general.php?page=credit-tracker') . '">' . __('Settings', CREDITTRACKER_SLUG) . '</a>'
),
$links
);
}
/**
* Add options page
*/
function credittracker_add_plugin_page()
{
global $plugin_screen_hook_suffix;
$plugin_screen_hook_suffix = add_options_page(
__('Credit Tracker', CREDITTRACKER_SLUG),
__('Credit Tracker', CREDITTRACKER_SLUG),
'manage_options',
CREDITTRACKER_SLUG,
'credittracker_create_admin_page'
);
}
/**
* Register and enqueue admin-specific style sheet.
*
* @return null Return early if no settings page is registered.
*/
function credittracker_enqueue_admin_styles()
{
global $plugin_screen_hook_suffix;
if (!isset($plugin_screen_hook_suffix)) {
return;
}
$screen = get_current_screen();
$ct_allowed_screens = array($plugin_screen_hook_suffix, "attachment", "upload");
if (isset($screen) && in_array($screen->id, $ct_allowed_screens)) {
wp_enqueue_style(CREDITTRACKER_SLUG . '-admin-styles', plugins_url('css/ct-admin.css', __FILE__), array(), CREDITTRACKER_VERSION);
}
}
/**
* Register and enqueue admin-specific JavaScript.
*
* @return null Return early if no settings page is registered.
*/
function credittracker_enqueue_admin_scripts()
{
global $plugin_screen_hook_suffix;
if (!isset($plugin_screen_hook_suffix)) {
return;
}
$screen = get_current_screen();
$ct_allowed_screens = array($plugin_screen_hook_suffix, "attachment", "upload");
if (isset($screen) && in_array($screen->id, $ct_allowed_screens)) {
wp_enqueue_script(CREDITTRACKER_SLUG . '-admin-script', plugins_url('js/ct-admin.js', __FILE__), array('jquery'), CREDITTRACKER_VERSION);
}
}
/**
* Options page callback
*/
function credittracker_create_admin_page()
{
?>
<div class="wrap credit-tracker" xmlns="https://www.w3.org/1999/html">
<a href="https://www.labs64.com" target="_blank" class="icon-labs64 icon32"></a>
<h2><?php _e('Credit Tracker by Labs64', CREDITTRACKER_SLUG); ?></h2>
<form method="post" action="options.php">
<?php
// This prints out all hidden setting fields
settings_fields('CREDITTRACKER_OPTIONS_GROUP');
credittracker_settings_fields_hidden();
do_settings_sections(CREDITTRACKER_SLUG);
submit_button();
?>
</form>
<hr/>
<?php
credittracker_print_reference_section();
?>
</div>
<div class="info_menu">
<?php
credittracker_print_features_section();
credittracker_print_divider();
credittracker_print_feedback_section();
?>
</div>
<?php
}
/**
* Print sections divider
*/
function credittracker_print_divider()
{
?>
<hr/>
<?php
}
/**
* Print the Section info text
*/
function credittracker_get_on_off($opt)
{
if ($opt == '1') {
return "<span class='label-on'>ON</span>";
} else {
return "<span class='label-off'>OFF</span>";
}
}
/**
* Print the Common-Section info text
*/
function credittracker_print_common_section_info()
{
}
/**
* Print the Retriever-Section info text
*/
function credittracker_print_retriever_section_info()
{
print __('Some Image Data Retriever needs additional configuration', CREDITTRACKER_SLUG);
}
/**
* Returns available plugin features
*/
function credittracker_get_features_array()
{
$features = array(
'ct_feature_retriever' => __('Image data retriever (Free)', CREDITTRACKER_SLUG)
);
return $features;
}
/**
* Get features list.
*/
function credittracker_print_features_list($features)
{
$ret = '<ul id="credittracker_features">';
foreach ($features as $key => $value) {
$ret .= '<li id="' . $key . '"> ' . $value . ' - ' . credittracker_get_on_off(credittracker_get_single_option($key)) . '</li>';
}
$ret .= '</ul>';
print $ret;
}
/**
* Print the features section
*/
function credittracker_print_features_section()
{
$ct_feature_retriever = credittracker_get_single_option('ct_feature_retriever');
?>
<h3><?php _e('Features', CREDITTRACKER_SLUG); ?></h3>
<p><?php _e('Available plugin features', CREDITTRACKER_SLUG); ?>:</p>
<?php credittracker_print_features_list(credittracker_get_features_array()); ?>
<button id="ct-validate" type="button""><?php _e('Validate'); ?></button>
<br/>
<div style="font-style: italic; color: rgb(102, 102, 102); font-size: smaller;"><p>Powered by <a
href="https://netlicensing.io/?utm_source=credit-tracker&utm_medium=wordpress_plugin&utm_campaign=credit-tracker&utm_content=wordpress_admin"
target="_blank">NetLicensing</a></p>
</div>
<?php
}
/**
* Print the feedback section
*/
function credittracker_print_feedback_section()
{
?>
<h3><?php _e('Feedback', CREDITTRACKER_SLUG); ?></h3>
<p><?php _e('Did you find a bug? Have an idea for a plugin? Please help us improve this plugin', CREDITTRACKER_SLUG); ?>:</p>
<ul>
<li>
<a href="https://github.com/Labs64/credit-tracker/issues"
target="_blank"><?php _e('Report a bug, or suggest an improvement', CREDITTRACKER_SLUG); ?></a>
</li>
<li><a href="https://www.facebook.com/labs64" target="_blank"><?php _e('Like us on Facebook'); ?></a>
</li>
<li><a href="https://www.labs64.com/blog" target="_blank"><?php _e('Read Labs64 Blog'); ?></a></li>
</ul>
<?php
}
/**
* Print the reference section
*/
function credittracker_print_reference_section()
{
?>
<h3><?php _e('Shortcodes Reference', CREDITTRACKER_SLUG); ?></h3>
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row">
[caption]
</th>
<td>
<p>Override WordPress [caption] shortcode.</p>
<p><strong>Attributes:</strong></p>
<p> <strong>id</strong> <i>(mandatory)</i> - Attachment ID.</p>
<p> <strong>width</strong> <i>(optional)</i> - Caption area width in pixels.</p>
<p> <strong>text</strong> <i>(optional)</i> - custom attribute to override standard media
caption. The
default behavior, if not specified standard media caption will be used.</p>
<br/>
<p><strong>Examples:</strong></p>
<p><code>[caption id="attachment_11" width="111"]...[/caption]</code></p>
<p>Override [caption] shortcode</p>
<br/>
<p><code>[caption id="11" text="image caption"]...[/caption]</code></p>
<p>Override [caption] shortcode and use <i>text</i> instead of the standard media property</p>
<br/>
<p><code>[caption id="11"]<a href="%link%"><img src="11.png" alt="%caption%" title="%copyright%"/></a>[/caption]</code></p>
<p>Substitute media attribution within [caption] shortcode</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
[gallery]
</th>
<td>
<p>Override WordPress [gallery] shortcode.</p>
<p><strong>Attributes:</strong></p>
<p> All standard [gallery] shortcode attributes can be used.</p>
<br/>
<p><strong>Examples:</strong></p>
<p><code>[gallery link="none" size="large" ids="8,7,5"]</code></p>
<p>Override [gallery] shortcode</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
[credit_tracker_table]
</th>
<td>
<p>Generate 'Image Credits' table.</p>
<p><strong>Attributes:</strong></p>
<p> <strong>id</strong> <i>(optional)</i> - Attachment ID (one or more). The
default behavior, if no ID is specified, is to display all images containing author info.</p>
<p> <strong>size</strong> <i>(optional)</i> - Image size to use for the thumbnail
display. Valid values include "hidden", "linkonly", "thumbnail", "medium", "large", "full" or numeric values (e.g. "50" or
"100x50").
The default value is "thumbnail".</p>
<p> <strong>style</strong> <i>(optional)</i> - Table CSS style. Valid values
include "default", "mercury", "mars". The default value is "default".</p>
<p>  <strong>include_columns</strong> <i>(optional)</i> - Table columns order and visibility.
Valid values include "ident_nr", "author", "publisher", "copyright", "license".
The default value is "" - show all columns in the default order.</p>
<p> <strong>only_current_post</strong> <i>(optional)</i> - If true, only render images attached to the currently visible post.
Valid values include "true" or "false".
The default value is "" - which defaults to "false".</p>
<p> <strong>orderby</strong> <i>(optional)</i> - Which value to sort the table on.
The only valid value for this field is "date".
The default order value will be used if this is not provided.</p>
<p> <strong>order</strong> <i>(optional)</i> - Sort results ascending or descending.
Valid values include "asc" or "desc".
The default value is "desc" - no effect by default, sorts reverse chronologically when sorting by date.</p>
<br/>
<p><strong>Examples:</strong></p>
<p><code>[credit_tracker_table]</code></p>
<p>Generate table for all images with non-empty attribute 'author' and small (thumbnail) preview
image</p>
<br/>
<p><code>[credit_tracker_table id="11,22,33" size="medium" style="mercury"]</code></p>
<p>Generate table for with image ids (11, 22 and 33) and medium preview image. Table will be styled with
"mercury" CSS style</p>
<br/>
<p><code>[credit_tracker_table include_columns="ident_nr,copyright,license,author,publisher"]</code></p>
<p>Generate table with the specified columns only and defined columns order</p>
<br />
<p><code>[credit_tracker_table orderby="date" order="desc"]</code></p>
<p>Generate table sorted by date the image was added to the Media Library, showing most recent at the top.</p>
</td>
</tr>
</tbody>
</table>
<?php
}
/**
* Register and add settings
*/
function credittracker_page_init()
{
register_setting(
'CREDITTRACKER_OPTIONS_GROUP', // Option group
CREDITTRACKER_OPTIONS, // Option name
'credittracker_sanitize' // Sanitize
);
add_settings_section(
'CREDITTRACKER_COMMON_SETTINGS', // ID
__('Credit Tracker Settings', CREDITTRACKER_SLUG), // Title
'credittracker_print_common_section_info', // Callback
CREDITTRACKER_SLUG // Page
);
add_settings_section(
'CREDITTRACKER_RETRIEVER_SETTINGS', // ID
__('Retriever Settings', CREDITTRACKER_SLUG), // Title
'credittracker_print_retriever_section_info', // Callback
CREDITTRACKER_SLUG // Page
);
add_settings_field(
'ct_copyright_format',
__('Copyright format', CREDITTRACKER_SLUG),
'credittracker_text_field_callback',
CREDITTRACKER_SLUG,
'CREDITTRACKER_COMMON_SETTINGS',
array(
'id' => 'ct_copyright_format',
'description' => __('Default copyright format (HTML allowed)<br/>Allowed placeholders: %ident_nr%, %source%, %author%, %publisher%, %license%, %link%<br/>...as well as standard attributes: %title%, %caption%', CREDITTRACKER_SLUG),
)
);
add_settings_field(
'ct_override_caption_shortcode',
__('Override shortcodes', CREDITTRACKER_SLUG),
'credittracker_checkbox_field_callback',
CREDITTRACKER_SLUG,
'CREDITTRACKER_COMMON_SETTINGS',
array(
'id' => 'ct_override_caption_shortcode',
'caption' => __('Override WordPress [caption]/[gallery] shortcode', CREDITTRACKER_SLUG),
'description' => __('Replaces output of standard WordPress [caption]/[gallery] shortcode with improved version (add Image Microdata and Image Credit)<br/>Following placeholders can be used to substitute media attribution within [caption] shortcode: standard placeholders and %copyright%', CREDITTRACKER_SLUG),
)
);
add_settings_field(
'ct_override_caption_thumbnail',
__('Thumbnail', CREDITTRACKER_SLUG),
'credittracker_checkbox_field_callback',
CREDITTRACKER_SLUG,
'CREDITTRACKER_COMMON_SETTINGS',
array(
'id' => 'ct_override_caption_thumbnail',
'caption' => __('Add credit to the post thumbnail (featured image)', CREDITTRACKER_SLUG),
'description' => __('', CREDITTRACKER_SLUG),
)
);
add_settings_field(
'ct_auth_flickr_apikey',
__('Flickr api_key', CREDITTRACKER_SLUG),
'credittracker_text_field_callback',
CREDITTRACKER_SLUG,
'CREDITTRACKER_RETRIEVER_SETTINGS',
array(
'id' => 'ct_auth_flickr_apikey',
'description' => __('To use the Flickr data retriever you need to have an Flickr API application key.' . ' <a href="https://www.flickr.com/services/api/misc.api_keys.html" target="_blank">See here</a>' . ' for more details.', CREDITTRACKER_SLUG),
)
);
}
/**
* Sanitize each setting field as needed
*
* @param array $input Contains all settings fields as array keys
*/
function credittracker_sanitize($input)
{
if (empty($input['ct_copyright_format'])) {
if (is_admin()) {
add_settings_error(CREDITTRACKER_OPTIONS, 'empty-copyright-format', 'Please specify copyright format.');
}
} else {
$input['ct_copyright_format'] = $input['ct_copyright_format'];
}
if (isset($input['ct_auth_flickr_apikey'])) {
$input['ct_auth_flickr_apikey'] = sanitize_text_field($input['ct_auth_flickr_apikey']);
}
return $input;
}
/**
*/
function credittracker_settings_fields_hidden()
{
credittracker_print_settings_field_hidden('ct_feature_retriever');
}
/**
*/
function credittracker_print_settings_field_hidden($id)
{
$value = credittracker_get_single_option($id);
echo "<input type='hidden' id='$id' name='CREDITTRACKER_OPTIONS[$id]' value='$value' />";
}
/**
*/
function credittracker_text_field_callback($args)
{
$id = $args['id'];
$description = $args['description'];
$value = credittracker_get_single_option($id);
echo "<input type='text' id='$id' name='CREDITTRACKER_OPTIONS[$id]' value='$value' class='regular-text' />";
echo "<p class='description'>$description</p>";
}
function credittracker_checkbox_field_callback($args)
{
$id = $args['id'];
$caption = $args['caption'];
$description = $args['description'];
$value = credittracker_get_single_option($id);
echo "<input type='checkbox' id='$id' name='CREDITTRACKER_OPTIONS[$id]' value='1' class='code' " . checked(1, $value, false) . " /> $caption";
echo "<p class='description'>$description</p>";
}
/**
* Returns default options.
* If you override the options here, be careful to use escape characters!
*/
function credittracker_get_default_options()
{
$default_options = array(
'ct_feature_retriever' => '0',
'ct_copyright_format' => '© %author%',
'ct_auth_flickr_apikey' => '',
'ct_override_caption_shortcode' => '0',
'ct_override_caption_thumbnail' => '0'
);
return $default_options;
}
/**
* Retrieves (and sanitises) options
*/
function credittracker_get_options()
{
$options = credittracker_get_default_options();
$stored_options = get_option(CREDITTRACKER_OPTIONS);
if (empty($stored_options)) {
// restore old options
$stored_options = get_option('CT_OPTIONS');
}
if (!empty($stored_options)) {
credittracker_sanitize($stored_options);
$options = wp_parse_args($stored_options, $options);
}
update_option(CREDITTRACKER_OPTIONS, $options);
return $options;
}
/**
* Retrieves single option
*/
function credittracker_get_single_option($name)
{
$options = credittracker_get_options();
return $options[$name];
}
/**
* Set single option value
*/
function credittracker_set_single_option($name, $value)
{
$options = credittracker_get_options();
$options[$name] = $value;
update_option(CREDITTRACKER_OPTIONS, $options);
}
/**
* Returns available sources meta
*/
function credittracker_get_sources_names_array()
{
$names = array();
foreach (credittracker_get_sources_array() as $k => $v) {
$names[$k] = $v['caption'];
}
return $names;
}
/**
* Returns source caption
*/
function credittracker_get_source_caption($source, $useSource = false)
{
$sources = credittracker_get_sources_array();
if (isset($sources[$source]) && !empty($sources[$source]['caption'])) {
return $sources[$source]['caption'];
} else {
if ($useSource) {
return $source;
} else {
return '';
}
}
}
/**
* Returns source copyright format
*/
function credittracker_get_source_copyright($source)
{
$sources = credittracker_get_sources_array();
if (isset($sources[$source]) && !empty($sources[$source]['copyright'])) {
return call_user_func($sources[$source]['copyright']);
}
}
/**
* Returns source metadata
*/
function credittracker_get_source_metadata($source, $number)
{
$sources = credittracker_get_sources_array();
if (isset($sources[$source]) && !empty($sources[$source]['retriever'])) {
return call_user_func($sources[$source]['retriever'], $number);
}
}
/**
* Validate allowed features against Labs64 Netlicensing
*/
function credittracker_validate_callback()
{
// validate features
$nlic = new NetLicensing(CREDITTRACKER_API_KEY);
$res = $nlic->validate('CT', credittracker_strip_url(get_site_url(), 1000), urlencode(get_site_url()));
// NOTE: no NetLicensing response processing at the moment necessary; only product usage tracking functionality
// update options
credittracker_set_single_option('ct_feature_retriever', '1');
// prepare return values
$licenses = array(
'netlicensing_response' => $res,
'ct_feature_retriever' => credittracker_get_single_option('ct_feature_retriever')
);
echo json_encode($licenses);
die(); // this is required to return a proper result
}
/**
* Media data callback
*/
function credittracker_get_media_data_callback()
{
$item = credittracker_get_source_metadata($_POST['source'], $_POST['ident_nr']);
$mediadata = array(
'source' => $_POST['source'],
'ident_nr' => $_POST['ident_nr'],
'author' => isset($item['author']) ? $item['author'] : '',
'publisher' => $item['publisher'],
'license' => $item['license'],
'link' => $item['link']
);
echo json_encode($mediadata);
die(); // this is required to return a proper result
}
/**
* Returns available sources meta
*/
function credittracker_get_sources_array()
{
$sources = array(
'custom' => array(
'caption' => '',
'copyright' => '',
'retriever' => ''
),
'Fotolia' => array(
'caption' => 'Fotolia',
'copyright' => 'credittracker_get_fotolia_copyright',
'retriever' => 'credittracker_get_fotolia_metadata'
),
'iStockphoto' => array(
'caption' => 'iStockphoto',
'copyright' => 'credittracker_get_istockphoto_copyright',
'retriever' => 'credittracker_get_istockphoto_metadata'
),
'Shutterstock' => array(
'caption' => 'Shutterstock',
'copyright' => 'credittracker_get_shutterstock_copyright',
'retriever' => 'credittracker_get_shutterstock_metadata'
),
'Corbis_Images' => array(
'caption' => 'Corbis Images',
'copyright' => 'credittracker_get_corbis_images_copyright',
'retriever' => 'credittracker_get_corbis_images_metadata'
),
'Getty_Images' => array(
'caption' => 'Getty Images',
'copyright' => 'credittracker_get_getty_images_copyright',
'retriever' => 'credittracker_get_getty_images_metadata'
),
'pixelio' => array(
'caption' => 'Pixelio',
'copyright' => 'credittracker_get_pixelio_copyright',
'retriever' => 'credittracker_get_pixelio_metadata'
),
'flickr' => array(
'caption' => 'Flickr',
'copyright' => 'credittracker_get_flickr_copyright',
'retriever' => 'credittracker_get_flickr_metadata'
),
'freeimages' => array(
'caption' => 'Freeimages',
'copyright' => 'credittracker_get_freeimages_copyright',
'retriever' => 'credittracker_get_freeimages_metadata'
),
'wikimedia' => array(
'caption' => 'Wikimedia',
'copyright' => 'credittracker_get_wikimedia_copyright',
'retriever' => 'credittracker_get_wikimedia_metadata'
),
'unsplash' => array(
'caption' => 'Unsplash',
'copyright' => 'credittracker_get_unsplash_copyright',
'retriever' => 'credittracker_get_unsplash_metadata'
),
'depositphotos' => array(
'caption' => 'Depositphotos',
'copyright' => 'credittracker_get_depositphotos_copyright',
'retriever' => 'credittracker_get_depositphotos_metadata'
),
'Adobe_Stock' => array(
'caption' => 'Adobe Stock',
'copyright' => 'credittracker_get_adobestock_copyright',
'retriever' => 'credittracker_get_adobestock_metadata'
)
);
return $sources;
}
/**
* Fotolia: copyright
*/
function credittracker_get_fotolia_copyright()
{
return CTFotolia::COPYRIGHT;
}
/**
* Fotolia: metadata
*/
function credittracker_get_fotolia_metadata($number)
{
$parser = new CTFotolia();
return $parser->execute($number);
}
/**
* iStockphoto: copyright
*/
function credittracker_get_istockphoto_copyright()
{
return CTIStockphoto::COPYRIGHT;
}
/**
* iStockphoto: metadata
*/
function credittracker_get_istockphoto_metadata($number)
{
$parser = new CTIStockphoto();
return $parser->execute($number);
}
/**
* Shutterstock: copyright
*/
function credittracker_get_shutterstock_copyright()
{
return CTShutterstock::COPYRIGHT;
}
/**
* Shutterstock: metadata
*/
function credittracker_get_shutterstock_metadata($number)
{
$parser = new CTShutterstock();
return $parser->execute($number);
}
/**
* Corbis Images: copyright
*/
function credittracker_get_corbis_images_copyright()
{
return '© %author%/Corbis';
}
/**
* Corbis Images: metadata
*/
function credittracker_get_corbis_images_metadata($number)
{
$item = array();
$item['source'] = 'Corbis Images';
$item['author'] = '';
$item['publisher'] = 'Corbis Images';
$item['license'] = 'Royalty-free';
$item['link'] = 'https://www.corbisimages.com';
return $item;
}
/**
* Getty Images: copyright
*/
function credittracker_get_getty_images_copyright()
{
return '© %author% / Getty Images';
}
/**
* Getty Images: metadata
*/
function credittracker_get_getty_images_metadata($number)
{
$item = array();
$item['source'] = 'Getty Images';
$item['author'] = '';
$item['publisher'] = 'Getty Images';
$item['license'] = 'Royalty-free';
$item['link'] = 'https://www.gettyimages.com';
return $item;
}
/**
* Pixelio: copyright
*/
function credittracker_get_pixelio_copyright()
{
return CTPixelio::COPYRIGHT;
}
/**
* Pixelio: metadata
*/
function credittracker_get_pixelio_metadata($number)
{
$parser = new CTPixelio();
return $parser->execute($number);
}
/**
* Flickr: copyright
*/
function credittracker_get_flickr_copyright()
{
return CTFlickr::COPYRIGHT;
}
/**
* Flickr: metadata
*/
function credittracker_get_flickr_metadata($number)
{
$parser = new CTFlickr(credittracker_get_single_option('ct_auth_flickr_apikey'));
return $parser->execute($number);
}
/**
* Freeimages: copyright
*/
function credittracker_get_freeimages_copyright()
{
return CTFreeimages::COPYRIGHT;
}
/**
* Freeimages: metadata
*/
function credittracker_get_freeimages_metadata($number)
{
$parser = new CTFreeimages();
return $parser->execute($number);
}
/**
* Wikimedia: copyright
*/
function credittracker_get_wikimedia_copyright()
{
return 'By %author% [Creative Commons], via Wikimedia Commons';
}
/**
* Wikimedia: metadata
*/
function credittracker_get_wikimedia_metadata($number)
{
$item = array();
$item['source'] = 'Wikimedia';
$item['author'] = '';
$item['publisher'] = 'Wikimedia';
$item['license'] = 'Creative Commons';
$item['link'] = 'https://commons.wikimedia.org';
return $item;
}
/**
* Unsplash: copyright
*/
function credittracker_get_unsplash_copyright()
{
return CTUnsplash::COPYRIGHT;
}
/**
* Unsplash: metadata
*/
function credittracker_get_unsplash_metadata($number)
{
$parser = new CTUnsplash();
return $parser->execute($number);
}
/**
* Depositphotos: copyright
*/
function credittracker_get_depositphotos_copyright()
{
return CTDepositphotos::COPYRIGHT;
}
/**
* Depositphotos: metadata
*/
function credittracker_get_depositphotos_metadata($number)
{
$parser = new CTDepositphotos();
return $parser->execute($number);
}
/**
* Adobe Stock: copyright
*/
function credittracker_get_adobestock_copyright()
{
return CTAdobeStock::COPYRIGHT;
}
/**
* Adobe Stock: metadata
*/
function credittracker_get_adobestock_metadata($number)
{
$parser = new CTAdobeStock();
return $parser->execute($number);
}
?>