-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-agls.php
1246 lines (961 loc) · 35.1 KB
/
simple-agls.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
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Plugin Name: Simple AGLS
* Plugin URI: http://plugins.findingsimple.com
* Description: Simple plugin that helps integrate AGLS meta data into your WordPress powered site.
* Version: 1.0
* Author: Finding Simple
* Author URI: http://findingsimple.com
* License: GPL2
*
*
* Copyright 2014 Finding Simple (email : [email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*
* @package Simple AGLS
* @since 1.0
* @author Jason Conroy <[email protected]>
* @copyright Copyright (c) 2008 - 2014 Finding Simple
* @link http://findingsimple.com/
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Admin settings
*/
require_once dirname( __FILE__ ) . '/simple-agls-admin.php';
if ( ! class_exists( 'SIMPLE_AGLS' ) ) {
/**
* So that themes and other plugins can customise the text domain, the FS_AGLS should
* not be initialized until after the plugins_loaded and after_setup_theme hooks.
* However, it also needs to run early on the init hook.
*
* @since 1.0
*/
function initialize_simple_agls() {
SIMPLE_AGLS::init();
}
add_action( 'init', 'initialize_simple_agls', -1 );
class SIMPLE_AGLS {
static $text_domain, $defaults;
/**
* Hook into WordPress where appropriate.
*
* @since 1.0
*/
public static function init() {
self::$text_domain = apply_filters( 'simple_agls_text_domain', 'SIMPLE_AGLS' );
self::$defaults = array(
'element' => 'meta',
'echo' => true,
'show_default' => false,
'before' => '',
'after' => "\n"
);
/* Specify the schema/s used */
add_action( 'wp_head', __CLASS__ .'::agls_namespace', 1 );
/* Add mandatory agls <meta> elements to the <head> area. */
add_action( 'wp_head', __CLASS__ .'::agls_creator', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_date', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_description', 1 ); /* Recommended */
add_action( 'wp_head', __CLASS__ .'::agls_title', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_identifier', 1 ); /* Mandatory for online resources */
add_action( 'wp_head', __CLASS__ .'::agls_publisher', 1 ); /* Mandatory for information resources */
add_action( 'wp_head', __CLASS__ .'::agls_function', 1 ); /* Recommended if subject is not used */
add_action( 'wp_head', __CLASS__ .'::agls_subject', 1 ); /* Recommended if function is not used. */
/* Add conditional agls <meta> elements to the <head> area. */
add_action( 'wp_head', __CLASS__ .'::agls_availability', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_language', 1 );
/* Add optional agls <meta> elements to the <head> area. */
add_action( 'wp_head', __CLASS__ .'::agls_type', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_audience', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_contributor', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_coverage', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_format', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_mandate', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_relation', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_rights', 1 );
add_action( 'wp_head', __CLASS__ .'::agls_source', 1 );
}
/**
* Specify namespace/s used
*
* @since 1.0
*/
public static function agls_namespace( $args = array() ) {
$args['element'] = 'link';
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_namespace_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array(
'rel' => 'schema.DCTERMS',
'href' => 'http://purl.org/dc/terms/'
);
if ( !empty($attributes) && (get_option('simple_agls-toggle-dublin-core-namespace') == 1) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
$attributes = array(
'rel' => 'schema.AGLSTERMS',
'href' => 'http://www.agls.gov.au/agls/terms/'
);
if ( !empty($attributes) && (get_option('simple_agls-toggle-agls-namespace') == 1) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Creator term
*
* HTML/XHTML syntax - DCTERMS.creator
* Definition - An entity primarily responsible for making the resource
* Obligation - Mandatory
* Syntax encoding schemes - AglsAgent, GOLD, URI
*
* @since 1.0
*/
public static function agls_creator( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_creator_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$name = get_option( 'agls-creator-corporate-name' );
$address = get_option( 'agls-creator-address' );
$contact = get_option( 'agls-creator-contact' );
if ( ( !empty($name) ) && ( !empty($address) ) && ( !empty($contact) ) ) {
$attributes = array(
'name' => 'DCTERMS.creator',
'content' => 'CorporateName=' . $name . '; address=' . $address . '; contact=' . $contact . ';'
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'AGLSTERMS.AglsAgent';
}
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Date term
*
* Auto populates with date created
*
* HTML/XHTML syntax - DCTERMS.date
* Definition - A point or period of time associated with an event in the life of the resource.
* Obligation - Mandatory unless a related property is used.
* Syntax encoding schemes - ISO8601, XSD.date, XSD.dateTime
*
* @since 1.0
*/
public static function agls_date( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_date_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
if ( is_singular() ) {
$attributes = array(
'name' => 'DCTERMS.date',
'content' => get_the_date( 'c' )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.ISO8601';
}
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Date Modified term
*
* HTML/XHTML syntax - DCTERMS.modified
* Definition - Date on which the resource was changed.
* Obligation - Optional — may be used in place of date.
* Syntax encoding schemes - ISO8601, XSD.date, XSD.dateTime
*
* Auto populates with date modified
*
* @since 1.0
*/
public static function agls_date_modified( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_date_modified_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
if ( is_singular() && ( get_the_modified_time() != get_the_time() ) ) {
$attributes = array(
'name' => 'DCTERMS.modified',
'content' => get_the_modified_time( 'c' )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.ISO8601';
}
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Description term
*
* HTML/XHTML syntax - DCTERMS.description
* Definition - An account of the resource.
* Obligation - Recommended.
*
* @since 1.0
*/
public static function agls_description( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_description_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
/* If viewing the home/posts page, get the site's description. */
if ( is_home() )
$description = get_bloginfo( 'description' );
/* If viewing a singular post. */
elseif ( is_singular() || is_admin() ) {
/* By default use the post excerpt. */
$description = get_post_field( 'post_excerpt', $post->ID );
$individual = get_post_meta( $post->ID, 'DCTERMS.description', true );
/* If no description was found and viewing the site's front page, use the site's description. */
if ( empty( $description ) && is_front_page() )
$description = get_bloginfo( 'description' );
if ( !empty( $individual ) && !$show_default )
$description = $individual;
}
/* If viewing an archive page. */
elseif ( is_archive() ) {
/* If viewing a user/author archive. */
if ( is_author() ) {
/* Get the meta value for the 'Description' user meta key. */
$description = get_user_meta( get_query_var( 'author' ), 'Description', true );
/* If no description was found, get the user's description (biographical info). */
if ( empty( $description ) )
$description = get_the_author_meta( 'description', get_query_var( 'author' ) );
}
/* If viewing a taxonomy term archive, get the term's description. */
elseif ( is_category() || is_tag() || is_tax() )
$description = term_description( '', get_query_var( 'taxonomy' ) );
/* If viewing a custom post type archive. */
elseif ( is_post_type_archive() ) {
/* Get the post type object. */
$post_type = get_post_type_object( get_query_var( 'post_type' ) );
/* If a description was set for the post type, use it. */
if ( isset( $post_type->description ) )
$description = $post_type->description;
}
}
/* Format the description. */
if ( !empty( $description ) )
$attributes = array(
'name' => 'DCTERMS.description',
'content' => str_replace( array( "\r", "\n", "\t" ), '', esc_attr( strip_tags( $description ) ) )
);
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Title term
*
* HTML/XHTML syntax - DCTERMS.title
* Definition - A name given to the resource.
* Obligation - Mandatory.
*
* @since 1.0
*/
public static function agls_title( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_title_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$individual = get_post_meta( $post->ID, 'DCTERMS.title', true );
if (is_singular() || is_admin() ) {
$title = get_the_title();
} else if(is_search()) {
$title = __( 'Search', self::$text_domain );
} else if(is_category()) {
$title = single_cat_title("", false);
} else if(is_tag()) {
$title = single_tag_title("", false);
} else if(is_tax()) {
$title = single_term_title("", false);
} else if(is_author()) {
$id = get_query_var( 'author' );
$title = get_the_author_meta( 'display_name', $id );
} else if(is_date()) {
$title = __( 'Archives by date', self::$text_domain );
} else if(is_post_type_archive()) {
$post_type = get_post_type_object( get_query_var( 'post_type' ) );
$title = post_type_archive_title("", false);
} else if(is_archive()) {
$title = __( 'Archives', self::$text_domain );
} else if(is_404()) {
$title = __( 'Page Not Found', self::$text_domain );
} else if(is_home() && !is_front_page()) {
$title = get_the_title( get_option('page_for_posts', true) );
} else if(is_front_page() || (is_home() && is_front_page()) ) {
$title = get_bloginfo('name');
}
/* Apply the wp_title filters so we're compatible with plugins. */
$title = apply_filters( 'wp_title', $title, 10, 3 );
if ( !empty( $individual ) && !$show_default )
$title = $individual;
if ( !empty( $title ) )
$attributes = array(
'name' => 'DCTERMS.title',
'content' => esc_attr( $title )
);
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Identifier term
*
* Auto populate with the permalink (page url)
*
* HTML/XHTML syntax - DCTERMS.identifier
* Definition - An unambiguous reference to the resource within a given context.
* Obligation - Conditional - Mandatory for online resources.
* Syntax encoding schemes - DOI,ISBN,ISSN,URI
*
* @since 1.0
*/
public static function agls_identifier( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_identifier_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
if ((is_singular() && !is_front_page()) || is_admin()) {
$url = get_permalink();
} else if(is_search()) {
$search = get_query_var('s');
$url = get_search_link( $search );
} else if(is_category()) {
$url = get_category_link( get_queried_object() );
} else if(is_tag()) {
$url = get_tag_link( get_queried_object() );
} else if(is_tax()) {
$url = get_term_link( get_queried_object() );
} else if(is_author()) {
$id = get_query_var( 'author' );
$url = get_author_posts_url( $id );
} else if(is_year()) {
$url = get_year_link( get_query_var('year') );
} else if(is_month()) {
$url = get_month_link( get_query_var('year'), get_query_var('monthnum') );
} else if(is_day()) {
$url = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
} else if(is_post_type_archive()) {
$url = get_post_type_archive_link( get_query_var('post_type') );
} else if(is_home() && !is_front_page()) {
$url = get_permalink( get_option('page_for_posts', true) );
} else if(is_front_page() || (is_home() && is_front_page()) ) {
$url = get_bloginfo('url');
$url = preg_replace("~^https?://[^/]+$~", "$0/", $url); //trailing slash
} else {
$url = '';
}
if ( !empty( $url ) )
$attributes = array(
'name' => 'DCTERMS.identifier',
'content' => $url
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.URI';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Availability term
*
* HTML/XHTML syntax - AGLSTERMS.availability
* Definition - How the resource can be obtained or accessed, or contact information for obtaining the resource.
* Obligation - Conditional - Mandatory for descriptions of offline resources.
* Syntax encoding schemes - AglsAvail, URI
*
* @since 1.0
*/
public static function agls_availability( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_availability_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
if ((is_singular() && !is_front_page()) || is_admin()) {
$url = get_permalink();
} else if(is_search()) {
$search = get_query_var('s');
$url = get_search_link( $search );
} else if(is_category()) {
$url = get_category_link( get_queried_object() );
} else if(is_tag()) {
$url = get_tag_link( get_queried_object() );
} else if(is_tax()) {
$url = get_term_link( get_queried_object() );
} else if(is_author()) {
$id = get_query_var( 'author' );
$url = get_author_posts_url( $id );
} else if(is_year()) {
$url = get_year_link( get_query_var('year') );
} else if(is_month()) {
$url = get_month_link( get_query_var('year'), get_query_var('monthnum') );
} else if(is_day()) {
$url = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') );
} else if(is_post_type_archive()) {
$url = get_post_type_archive_link( get_query_var('post_type') );
} else if(is_home() && !is_front_page()) {
$url = get_permalink( get_option('page_for_posts', true) );
} else if(is_front_page() || (is_home() && is_front_page()) ) {
$url = get_bloginfo('url');
$url = preg_replace("~^https?://[^/]+$~", "$0/", $url); //trailing slash
} else {
$url = '';
}
if ( !empty( $url ) )
$attributes = array(
'name' => 'AGLSTERMS.availability',
'content' => $url
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.URI';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Publisher term
*
* HTML/XHTML syntax - DCTERMS.publisher
* Definition - An entity responsible for making the resource available.
* Obligation - Conditional—Mandatory for information resources (optional for descriptions of services).
* Syntax encoding schemes - AglsAgent, GOLD, URI
*
* @since 1.0
*/
public static function agls_publisher( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_publisher_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$publisher = '';
$name = get_option( 'agls-creator-corporate-name' );
$address = get_option( 'agls-creator-address' );
$contact = get_option( 'agls-creator-contact' );
if ( ( !empty($name) ) && ( !empty($address) ) && ( !empty($contact) ) ) {
$default = 'CorporateName=' . $name . '; address=' . $address . '; contact=' . $contact . ';';
} else {
$default = '';
}
$sitewide = get_option( 'agls-publisher' );
$individual = get_post_meta( $post->ID, 'DCTERMS.publisher', true );
/* Use default */
if (!empty($default))
$publisher = $default;
/* Override the default with the sitewide if set */
if (!empty($sitewide))
$publisher = $sitewide;
/* If an individual publisher has been set and is not being overridden by default use individual */
if (!empty($individual) && !$show_default)
$publisher = $individual;
if ( !empty($publisher ) )
$attributes = array(
'name' => 'DCTERMS.publisher',
'content' => $publisher
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'AGLSTERMS.AglsAgent';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Type term
*
* Auto populate with the default type "text" - all web pages are text http://dublincore.org/documents/2000/07/11/dcmi-type-vocabulary/#text
*
* HTML/XHTML syntax - DCTERMS.type
* Definition -The nature or genre of the resource.
* Obligation - Optional
* Vocabulary encoding schemes -DCMIType
*
* @since 1.0
*
* http://www.agls.gov.au/documents/agls-document/ contains a list of preferred types
*
*/
public static function agls_type( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_type_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$attributes = array(
'name' => 'DCTERMS.type',
'content' => 'text'
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.DCMIType';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Function term
*
* HTML/XHTML syntax - AGLSTERMS.function
* Definition - The business function to which the resource relates.
* Obligation - Recommended if subject is not used.
* Vocabulary encoding scheme - AGIFT
*
* @since 1.0
*
* Government agencies may use the Australian Governments’ Interactive Functions
* Thesaurus (AGIFT) as a source of function terms and a Vocabulary Encoding
* Scheme.
*
*/
public static function agls_function( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_function_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
/* This is the sitewide value */
$default = get_option( 'agls-function' );
$individual = get_post_meta( $post->ID, 'AGLSTERMS.function', true );
$function = '';
if (!empty($default))
$function = $default;
if (!empty($individual) && !$show_default)
$function = $individual;
if (!empty($function))
$attributes = array(
'name' => 'AGLSTERMS.function',
'content' => esc_attr( $function )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'AGLSTERMS.AGIFT';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Subject term
*
* HTML/XHTML syntax - DCTERMS.subject
* Definition - The topic of the resource.
* Obligation -Recommended if function is not used.
* Vocabulary encoding scheme - APAIS, APT, LCSH, MESH, TAGS
*
* @since 1.0
*/
public static function agls_subject( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_subject_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
/* Set an empty $subject variable. */
$subject = '';
/* If on a singular post and not a preview. */
if ( is_singular() || is_admin() ) {
/* Get the meta value for the 'DCTERMS.subject' meta key. */
$subject = get_post_meta( $post->ID, 'DCTERMS.subject', true );
/* If no subject were found. */
if ( empty( $subject ) || $show_default ) {
/* Set subject as array */
$subject = array();
/* Get all taxonomies for the current post type. */
$taxonomies = get_object_taxonomies( $post->post_type );
/* If taxonomies were found for the post type. */
if ( is_array( $taxonomies ) ) {
/* Loop through the taxonomies, getting the terms for the current post. */
foreach ( $taxonomies as $tax ) {
if ( $terms = get_the_term_list( $post->ID, $tax, '', ', ', '' ) )
$subject[] = $terms;
}
/* If keywords were found, join the array into a comma-separated string. */
if ( !empty( $subject) )
$subject = join( ', ', $subject );
}
}
}
/* If we have keywords, format for output. */
if ( !empty( $subject ) )
$attributes = array(
'name' => 'DCTERMS.subject',
'content' => esc_attr( strip_tags( $subject ) )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'AGLSTERMS.TAGS';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Audience term
*
* HTML/XHTML syntax - DCTERMS.audience
* Definition -A class of entity for whom the resource is intended or useful.
* Obligation - Optional
* Vocabulary encoding schemes -agls-audience, ANZSCO, ANZSIC, edna-audience
*
* If no audience set, auto populates with All
*
* @since 1.0
*/
public static function agls_audience( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_audience_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$default = get_option( 'agls-audience' );
$individual = get_post_meta( $post->ID, 'DCTERMS.audience', true );
$audience = 'All';
if (!empty($default))
$audience = $default;
if (!empty($individual) && !$show_default)
$audience = $individual;
if (!empty($audience))
$attributes = array(
'name' => 'DCTERMS.audience',
'content' => $audience
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'AGLSTERMS.agls-audience';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Coverage term
*
* HTML/XHTML syntax -DCTERMS.coverage
* Definition -The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant.
* Obligation - Optional
* Syntax encoding schemes -Box, Point
*
* @since 1.0
*/
public static function agls_coverage( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_coverage_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$default = get_option( 'agls-coverage' );
$individual = get_post_meta( $post->ID, 'DCTERMS.coverage', true );
$coverage = '';
if (!empty($default))
$coverage = $default;
if (!empty($individual) && !$show_default)
$coverage = $individual;
if (!empty($coverage))
$attributes = array(
'name' => 'DCTERMS.coverage',
'content' => esc_attr( $coverage )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = '';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Language term
*
* Defaults to "en-AU" if not set site-wide
*
* HTML/XHTML syntax - DCTERMS.language
* Definition - A language of the resource.
* Obligation - Recommended where the language of the resource is not English.
* Syntax encoding scheme - RFC4646
*
* @since 1.0
*/
public static function agls_language( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_language_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$sitewide = get_option( 'agls-language' );
//use WP language setting
$language = get_bloginfo('language');
if (!empty($sitewide) && !$show_default)
$language = $sitewide;
if (!empty($language))
$attributes = array(
'name' => 'DCTERMS.language',
'content' => esc_attr( $language )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = 'DCTERMS.RFC4646';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Contributor term
*
* HTML/XHTML syntax -DCTERMS.contributor
* Definition -An entity responsible for making contributions to the resource.
* Obligation - Optional
* Syntax encoding schemes -AglsAgent, GOLD, URI
*
* @since 1.0
*/
public static function agls_contributor( $args = array() ) {
global $post;
$args = wp_parse_args( $args, self::$defaults );
$args = apply_filters( 'agls_contributor_args', $args );
extract( $args, EXTR_SKIP );
$attributes = array();
$contributor = '';
/* If viewing a singular post, get the post author's display name. */
if ( is_singular() )
$contributor = get_the_author_meta( 'display_name', $post->post_author );
/* If viewing a user/author archive, get the user's display name. */
elseif ( is_author() )
$contributor = get_the_author_meta( 'display_name', $post->ID );
/* If an author was found, wrap it in the proper HTML and escape the author name. */
if ( !empty( $contributor ) )
$attributes = array(
'name' => 'DCTERMS.contributor',
'content' => esc_attr( $contributor )
);
if ( ( get_option('simple_agls-toggle-scheme-attribute') == 1 ) && !empty( $attributes ) ) {
$attributes['scheme'] = '';
}
if ( !$echo && !empty($attributes) )
return SIMPLE_AGLS::agls_output( $attributes , $args );
if ( !empty($attributes) )
echo SIMPLE_AGLS::agls_output( $attributes , $args );
}
/**
* Format term
*
* HTML/XHTML syntax -DCTERMS.format
* Definition - The file format, physical medium, or dimensions of the resource.
* Obligation - Optional
* Syntax encoding scheme - IMT
*
* Auto populate with the doc type
*
* @since 1.0
*/
public static function agls_format( $args = array() ) {
$args = wp_parse_args( $args, self::$defaults );