-
Notifications
You must be signed in to change notification settings - Fork 0
/
ictuwp-plugin-inclusie.php
2651 lines (1996 loc) · 95.1 KB
/
ictuwp-plugin-inclusie.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
/**
* @link https://inclusie.gebruikercentraal.nl
* @package ictu-gc-posttypes-inclusie
*
* @wordpress-plugin
* Plugin Name: ICTU / Gebruiker Centraal / Inclusie post types and taxonomies
* Plugin URI: https://github.com/ICTU/Gebruiker-Centraal---Inclusie---custom-post-types-taxonomies
* Description: Plugin for inclusie.gebruikercentraal.nl to register custom post types and custom taxonomies
* Version: 1.1.13
* Version description: Refactor constants
* Author: Tamara de Haas & Paul van Buuren
* Author URI: https://wbvb.nl/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: ictu-gc-posttypes-inclusie
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
//========================================================================================================
add_action( 'plugins_loaded', [ 'GC_INCLUSIE_Register_taxonomies', 'init' ], 10 );
//========================================================================================================
if ( ! defined( 'GC_INCLUSIE_STAP_CPT' ) ) {
define( 'GC_INCLUSIE_STAP_CPT', 'stap' ); // 'stap', prev: ICTU_GC_CPT_STAP
}
if ( ! defined( 'GC_INCLUSIE_CITAAT_CPT' ) ) {
define( 'GC_INCLUSIE_CITAAT_CPT', 'citaat' ); // 'citaat', prev: ICTU_GC_CPT_CITAAT
}
if ( ! defined( 'GC_INCLUSIE_DOELGROEP_CPT' ) ) {
define( 'GC_INCLUSIE_DOELGROEP_CPT', 'doelgroep' ); // 'doelgroep', prev: ICTU_GC_CPT_DOELGROEP
}
if ( ! defined( 'GC_INCLUSIE_VAARDIGHEDEN_CPT' ) ) {
define( 'GC_INCLUSIE_VAARDIGHEDEN_CPT', 'vaardigheden' ); // 'vaardigheden', prev: ICTU_GC_CPT_VAARDIGHEDEN
}
if ( ! defined( 'GC_INCLUSIE_AANRADER_CPT' ) ) {
define( 'GC_INCLUSIE_AANRADER_CPT', 'aanrader' ); // 'nietzomaarzo', prev: ICTU_GC_CPT_AANRADER
}
if ( ! defined( 'GC_INCLUSIE_AFRADER_CPT' ) ) {
define( 'GC_INCLUSIE_AFRADER_CPT', 'afrader' ); // 'nietzomaarzo', prev: ICTU_GC_CPT_AFRADER
}
if ( ! defined( 'GC_INCLUSIE_METHODE_CPT' ) ) {
define( 'GC_INCLUSIE_METHODE_CPT', 'methode' ); // 'methode', prev: ICTU_GC_CPT_METHODE
}
if ( ! defined( 'GC_INCLUSIE_TIJD_TAX' ) ) {
define( 'GC_INCLUSIE_TIJD_TAX', 'tijd' ); // slug for custom taxonomy 'tijd', prev: ICTU_GC_CT_TIJD
}
if ( ! defined( 'GC_INCLUSIE_MANKRACHT_TAX' ) ) {
define( 'GC_INCLUSIE_MANKRACHT_TAX', 'mankracht' ); // slug for custom taxonomy 'mankracht', prev: ICTU_GC_CT_MANKRACHT
}
if ( ! defined( 'GC_INCLUSIE_KOSTEN_TAX' ) ) {
define( 'GC_INCLUSIE_KOSTEN_TAX', 'kosten' ); // slug for custom taxonomy 'kosten', prev: ICTU_GC_CT_KOSTEN
}
if ( ! defined( 'GC_INCLUSIE_EXPERTISE_TAX' ) ) {
define( 'GC_INCLUSIE_EXPERTISE_TAX', 'expertise' ); // slug for custom taxonomy 'expertise', prev: ICTU_GC_CT_EXPERTISE
}
if ( ! defined( 'GC_INCLUSIE_DEELNEMERS_TAX' ) ) {
define( 'GC_INCLUSIE_DEELNEMERS_TAX', 'deelnemers' ); // slug for custom taxonomy 'deelnemers', prev: ICTU_GC_CT_DEELNEMERS
}
if ( ! defined( 'GC_INCLUSIE_ONDERWERP_TAX' ) ) {
define( 'GC_INCLUSIE_ONDERWERP_TAX', 'onderwerpen' ); // slug for custom taxonomy 'onderwerpen', prev: ICTU_GC_CT_ONDERWERP_TIP
}
if ( ! defined( 'GC_INCLUSIE_PROCESTIP_CPT' ) ) {
define( 'GC_INCLUSIE_PROCESTIP_CPT', 'procestip' ); // tax for custom cpt tip, prev: ICTU_GC_CPT_PROCESTIP
}
define( 'GC_INCLUSIE_ARCHIVE_CSS', 'ictu-gc-header-css' );
define( 'GC_INCLUSIE_BASE_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
define( 'GC_INCLUSIE_ASSETS_URL', trailingslashit( GC_INCLUSIE_BASE_URL ) );
define( 'GC_INCLUSIE_INCL_VERSION', '1.1.13' );
//========================================================================================================
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 0.0.1
*/
if ( ! class_exists( 'GC_INCLUSIE_Register_taxonomies' ) ) :
class GC_INCLUSIE_Register_taxonomies {
/**
* @var Rijksvideo
*/
public $inclusieobject = null;
/** ----------------------------------------------------------------------------------------------------
* Init
*/
public static function init() {
$inclusieobject = new self();
}
/** ----------------------------------------------------------------------------------------------------
* Constructor
*/
public function __construct() {
$this->includes();
$this->setup_actions();
}
/** ----------------------------------------------------------------------------------------------------
* Hook this plugins functions into WordPress
*/
private function includes() {
require_once dirname( __FILE__ ) . '/includes/inclusie.acf-definitions.php';
}
/** ----------------------------------------------------------------------------------------------------
* Hook this plugins functions into WordPress
*/
private function setup_actions() {
add_action( 'init', [ $this, 'ictu_gc_register_post_type' ] );
add_action( 'init', 'ictu_gc_inclusie_initialize_acf_fields' ); // function from inclusie.acf-definitions.php
add_action( 'init', [
$this,
'ictu_gc_admin_inclusie_set_terms_order',
] );
add_action( 'get_the_terms', [
$this,
'ictu_gc_admin_inclusie_get_terms_in_order',
], 10, 4 );
add_action( 'init', [ $this, 'ictu_gc_add_rewrite_rules' ] );
add_action( 'genesis_single_crumb', [
$this,
'filter_breadcrumb',
], 10, 2 );
add_action( 'genesis_page_crumb', [
$this,
'filter_breadcrumb',
], 10, 2 );
add_action( 'genesis_archive_crumb', [
$this,
'filter_breadcrumb',
], 10, 2 );
/** Adding custom Favicon */
add_action( 'genesis_pre_load_favicon', [ $this, 'custom_favicon' ] );
add_action( 'genesis_entry_content', [ $this, 'append_content' ], 15 );
// add a page temlate name
$this->templates = [];
$this->template_home = 'home-inclusie.php';
// add the page template to the templates list
add_filter( 'theme_page_templates', [
$this,
'ictu_gc_add_page_templates',
] );
// activate the page filters
add_filter( 'template_redirect', [
$this,
'ictu_gc_frontend_use_page_template',
] );
// disable the author pages
if ( function_exists( 'ictu_gctheme_disable_author_pages' ) ) {
add_action( 'template_redirect', 'ictu_gctheme_disable_author_pages' );
}
// add styling and scripts
add_action( 'wp_enqueue_scripts', [
$this,
'ictu_gc_register_frontend_style_script',
] );
// add header css
add_action( 'wp_enqueue_scripts', [
$this,
'ictu_gc_append_header_css_local',
] );
if ( function_exists( 'ictu_gctheme_card_append_header_css' ) ) {
add_action( 'wp_enqueue_scripts', 'ictu_gctheme_card_append_header_css' );
}
}
//========================================================================================================
/**
* Hides the custom post template for pages on WordPress 4.6 and older
*
* @param array $post_templates Array of page templates. Keys are filenames, values are translated names.
*
* @return array Expanded array of page templates.
*/
function ictu_gc_add_page_templates( $post_templates ) {
$post_templates[ $this->template_home ] = _x( 'Inclusie - Home page', "naam template", "ictu-gc-posttypes-inclusie" );
return $post_templates;
}
//========================================================================================================
/**
* Admin: force tax to sort by assigned sort order
*
* @in: terms, term ID, taxonomy
* @return terms
*/
public function ictu_gc_admin_inclusie_get_terms_in_order( $terms, $id, $taxonomy ) {
$terms = wp_cache_get( $id, "{$taxonomy}_relationships_sorted" );
if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy, [ 'orderby' => 'term_order' ] );
wp_cache_add( $id, $terms, $taxonomy . '_relationships_sorted' );
}
return $terms;
}
//========================================================================================================
/**
* Admin: force tax to sort by assigned sort order
*
* @return void
*/
public function ictu_gc_admin_inclusie_set_terms_order() {
global $wp_taxonomies; //fixed missing semicolon
// the following relates to tags, but you can add more lines like this for any taxonomy
$wp_taxonomies['post_tag']->sort = true;
$wp_taxonomies['post_tag']->args = [ 'orderby' => 'term_order' ];
}
//========================================================================================================
/**
* Handles the front-end display.
*
* @return void
*/
public function ictu_gc_frontend_doelgroeppagina_content() {
global $post;
$all_or_some = get_field( 'doelgroeppagina_showall_or_select', $post->ID );
if ( 'showsome' === $all_or_some ) {
$doelgroepen = get_field( 'doelgroeppagina_kies_doelgroepen', $post->ID );
if ( $doelgroepen ) {
echo '<div class="grid grid--col-3">';
$postcounter = 0;
foreach ( $doelgroepen as $post ):
setup_postdata( $post );
$postcounter ++;
$citaat = get_field( 'facts_citaten', $post->ID );
echo ictu_gctheme_card_doelgroep( $post, $citaat );
endforeach;
echo '</div>';
wp_reset_query();
} else {
echo '<p>' . _x( 'Geen doelgroepen geselecteerd voor deze pagina.', "error", "ictu-gc-posttypes-inclusie" ) . '</p>';
}
} else {
$args = [
'post_type' => GC_INCLUSIE_DOELGROEP_CPT,
'posts_per_page' => - 1,
'order' => 'ASC',
'orderby' => 'post_title',
];
$alledoelgroepen = new WP_query( $args );
if ( $alledoelgroepen->have_posts() ) {
echo '<div class="grid grid--col-3">';
$postcounter = 0;
while ( $alledoelgroepen->have_posts() ) : $alledoelgroepen->the_post();
$postcounter ++;
$citaat = get_field( 'facts_citaten', $post->ID );
echo ictu_gctheme_card_doelgroep( $post, $citaat );
endwhile;
echo '</div>';
wp_reset_query();
}
}
}
//========================================================================================================
/**
* Handles the front-end display.
*
* @return void
*/
public function ictu_gc_frontend_doelgroep_avatar_en_citaat() {
global $post;
$stap_inleiding = get_field( 'stap_inleiding', $post->ID );
$stap_methodes = get_field( 'stap_methodes', $post->ID );
$stap_methode_inleiding = get_field( 'stap_methode_inleiding', $post->ID );
// Set doelgroeppoppetje
$doelgroeppoppetje = 'poppetje-1';
if ( get_field( 'doelgroep_avatar', $post->ID ) ) {
$doelgroeppoppetje = get_field( 'doelgroep_avatar', $post->ID );
}
echo '<div id="doelgroep-inleiding" class="doelgroep--' . $doelgroeppoppetje . '">';
echo '<header class="entry-header wrap"><h1 class="entry-title">' . get_the_title() . '</h1></header>';
if ( $stap_inleiding ) {
echo sanitize_text_field( $stap_inleiding );
} else {
if ( get_the_excerpt( $post->ID ) ) {
echo '<p class="doelgroep__posttext">' . get_the_excerpt( $post->ID ) . '</p>';
}
}
$section_title = _x( 'Citaten', 'titel op methode-pagina', 'ictu-gc-posttypes-inclusie' );
$title_id = sanitize_title( $section_title . '-' . $post->ID );
$facts_citaten = get_field( 'facts_citaten', $post->ID );
echo '<div class="" id="doelgroep-inleiding-citaten">';
// loop through the rows of data
foreach ( $facts_citaten as $post ):
setup_postdata( $post );
$theid = $post->ID;
$section_title = get_the_title( $theid );
$title_id = sanitize_title( $section_title );
$citaat_post = get_post( $theid );
$content = '”' . $citaat_post->post_content . '”';
$section_text = apply_filters( 'the_content', $content );
$citaat_auteur = sanitize_text_field( get_field( 'citaat_auteur', $theid ) );
echo '<div class="tegeltje">' . $section_text . '<p class="author"><b>' . $citaat_auteur . '</b></p></div>';
endforeach;
//echo '<div class="feat-image ' . $doelgroeppoppetje . '">;</div>';
echo '</div>';
echo '<div class="doelgroep__avatar"></div>'; // #doelgroep-inleiding
echo '</div>'; // #doelgroep-inleiding
wp_reset_postdata();
}
//========================================================================================================
/**
* Handles the front-end display.
*
* @return void
*/
public function ictu_gc_frontend_stap_before_content() {
global $post;
$homepageID = get_option( 'page_on_front' );
if ( ! $homepageID ) {
return;
}
if ( is_search() ) {
// geen stappen tonen als deze pagina getoond wordt in sitesearch zoekresultaten
// @since 1.1.8
return;
}
if ( function_exists( 'get_field' ) ) {
$home_stappen = get_field( 'home_template_stappen', $homepageID );
if ( $home_stappen ):
$section_title = _x( 'Stappen', 'titel op home-pagina', 'ictu-gc-posttypes-inclusie' );
$title_id = sanitize_title( $section_title . '-' . $post->ID );
$stepcounter = 0;
echo '<div aria-labelledby="' . $title_id . '" class="stepnav">';
echo '<h2 id="' . $title_id . '" class="visuallyhidden">' . $section_title . '</h2>';
echo '<ol class="stepnav__items l-item-count-' . count( $home_stappen ) . '">';
foreach ( $home_stappen as $stap ):
unset( $icon_classes );
$active = '';
$icon_classes[] = 'stepnav__icon';
$stepcounter ++;
$titel = get_the_title( $stap->ID );
if ( get_field( 'stap_verkorte_titel', $stap->ID ) ) {
$titel = get_field( 'stap_verkorte_titel', $stap->ID );
}
if ( get_field( 'stap_icon', $stap->ID ) ) {
$icon_classes[] = 'icon--' . get_field( 'stap_icon', $stap->ID );
}
if ( $stap->ID === $post->ID ) {
$active = 'active';
}
$title_id = sanitize_title( get_the_title( $stap->ID ) . '-' . $stepcounter );
$steptitle = sprintf( _x( '%s. %s', 'Label stappen', 'ictu-gc-posttypes-inclusie' ), $stepcounter, $titel );
$stepnav_item = '<li id="step_' . $stepcounter . '" class="stepnav__step">' .
'<a href="' . get_permalink( $stap->ID ) . '" class="stepnav__link ' . ( ( $active ) ? 'is-active' : '' ) . '" title="' . $titel . '" >' .
'<svg class="icon icon--stepnav" focusable="false">' .
'<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="' . get_stylesheet_directory_uri() . '/images/svg/stepchart/defs/svg/sprite.defs.svg#' . get_field( 'stap_icon', $stap->ID ) . '"></use> ' .
'</svg> ' .
'<span class="stepnav__linktext">' . $titel . '</span>' .
'</a></li>';
echo $stepnav_item;
endforeach;
echo '</ol>';
echo '</div>';
endif;
} // if (function_exists('get_field'))
}
//========================================================================================================
/**
* Display title and short description before body text of single step
*
* @return void
*/
public function ictu_gc_frontend_stap_inleiding() {
global $post;
if ( is_search() ) {
// geen inleiding tonen als deze pagina getoond wordt in sitesearch zoekresultaten
// @since 1.1.8
return;
}
if ( function_exists( 'get_field' ) ) {
$stap_inleiding = get_field( 'stap_inleiding', $post->ID );
$stap_methodes_titel = get_field( 'stap_methodes_titel', $post->ID );
if ( ! $stap_methodes_titel ) {
$stap_methodes_titel = _x( 'Methoden', 'titel op Stap-pagina', 'ictu-gc-posttypes-inclusie' );
}
// Make reusable Intro region as a data container
echo '<div class="region region--content-top">' .
'<div class="page-intro inleiding">' .
'<header class="entry-header"><h1 class="entry-title">' . get_the_title() . '</h1>' . '</header>';
if ( $stap_inleiding ) {
echo $stap_inleiding;
}
echo '</div>'; // class="page-intro inleiding"
echo '</div>'; // class="region region--content-top"
} // if (function_exists('get_field'))
}
//========================================================================================================
/**
* Lists the attached methodes to a single step
*
* @return void
*/
public function ictu_gc_frontend_stap_methodes( $args = [] ) {
global $post;
$defaults = [
'ID' => 0,
'titletag' => 'h2',
'echo' => true,
];
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
if ( function_exists( 'get_field' ) ) {
$stap_methodes = get_field( 'stap_methodes', $post->ID );
$stap_methode_inleiding = get_field( 'stap_methode_inleiding', $post->ID );
$stap_methodes_titel = get_field( 'stap_methodes_titel', $post->ID );
if ( $stap_methodes ):
$section_title = $stap_methodes_titel;
$title_id = sanitize_title( $section_title . '-' . $post->ID );
echo '<section aria-labelledby="' . $title_id . '" class="section section--related-methoden">';
echo '<div class="l-section-top">';
echo '<h2 id="' . $title_id . '" class="section__title">' . $section_title . '</h2>';
if ( $stap_methode_inleiding ) {
echo $stap_methode_inleiding;
} else {
echo sprintf( '<p>%s</p>', _x( 'Dit is een selectie van methoden, technieken en instrumenten die je in kunt zetten bij het uitvoeren van deze stap. Soms gaat het om standaardmethoden die worden ingezet voor het uitvoeren van een ontwerptraject waarbij de gebruiker centraal staat. Andere methoden richten zich specifiek op inclusie. ', 'Stap: intro bij methoden', 'ictu-gc-posttypes-inclusie' ) );
}
echo '</div>'; // .page-intro__intro-text
echo '<div class="grid grid--col-3">';
// loop through the rows of data
foreach ( $stap_methodes as $post ):
setup_postdata( $post );
$theid = $post->ID;
$section_title = get_the_title( $theid );
$section_text = get_the_excerpt( $theid );
$section_link = get_sub_field( 'home_template_teaser_link' );
$title_id = sanitize_title( $section_title );
echo '<div class="card">';
echo '<div class="card__content">';
echo '<h3 class="card__title" id="' . $title_id . '">' .
'<a class="arrow-link" href="' . get_permalink( $theid ) . '">' .
'<span class="arrow-link__text">' . $section_title . '</span>' .
'<span class="arrow-link__icon"></span>' .
'</a></h3>';
echo '<p>';
echo $section_text;
echo '</p>';
echo '</div>';
echo '</div>';
endforeach;
wp_reset_postdata();
echo '</div>'; // class="grid grid--col-3 text-block
echo '</section>';
endif;
} // if (function_exists('get_field'))
}
//========================================================================================================
/**
* Lists the attached (proces)tips to a single step
* returns either an array or a block of HTML
*
* @return $return (string) / $menuarray (array)
*/
public function ictu_gc_frontend_stap_procestips( $args ) {
global $post;
$defaults = [
'ID' => 0,
'titletag' => 'h2',
'getmenu' => false,
'echo' => true,
];
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
$menuarray = [];
$return = '';
if ( function_exists( 'get_field' ) ) {
$stap_procestips_titel = get_field( 'stap_procestips_sectiontitle', $post->ID );
$stap_procestips = get_field( 'stap_procestips', $post->ID );
// Procestips
if ( $stap_procestips ):
// er zijn procestips
$title_id = sanitize_title( $stap_procestips_titel . '-' . $post->ID );
$return .= '<section aria-labelledby="' . $title_id . '" class="section section--related section--related-tips">';
$return .= '<div class="l-section-top">';
$return .= '<' . $args['titletag'] . ' id="' . $title_id . '" class="section__title">' . $stap_procestips_titel . '</' . $args['titletag'] . '>';
$return .= '</div>';
$return .= '<div class="l-section-content">';
// loop through the rows of data
foreach ( $stap_procestips as $post ):
setup_postdata( $post );
$theid = $post->ID;
$section_title = get_the_title( $theid );
$section_text = get_the_excerpt( $theid );
$title_id = sanitize_title( $section_title );
if ( $args['getmenu'] ) {
$menuarray[ $title_id ] = $section_title;
} else {
$return .= '<div aria-labelledby="' . $title_id . '" class="doelgroep-tips">';
$return .= '<h3><a href="' . get_permalink( $theid ) . '" id="' . $title_id . '">' . $section_title . '</a></h3>';
$return .= $section_text;
$return .= '</div>'; // .doelgroep-tips;
}
endforeach;
wp_reset_query();
$return .= '</div>'; // .wrap
$return .= '</section>'; // class="section--related-tips
endif; // $stap_tips_od
} // if (function_exists('get_field'))
else {
$return = 'Activeer ACF plugin';
}
if ( $args['getmenu'] ) {
return $menuarray;
} elseif ( $args['echo'] ) {
echo $return;
} else {
return $return;
}
}
//========================================================================================================
/**
* Displays Optimaal Digitaal tips for a single step
*
* @in: $args (array)
* @return $return (string) / $menuarray (array)
*/
public function ictu_gc_frontend_stap_optimaaldigitaal( $args ) {
global $post;
$defaults = [
'ID' => 0,
'titletag' => 'h2',
'getmenu' => false,
'echo' => true,
];
// Parse incoming $args into an array and merge it with $defaults
$args = wp_parse_args( $args, $defaults );
$menuarray = [];
$return = '';
if ( function_exists( 'get_field' ) ) {
$stap_tips_od_titel = get_field( 'stap_tips_optimaal_digitaal_sectiontitle', $post->ID );
// Optimaal Digitaal tips
if ( have_rows( 'stap_tips_optimaal_digitaal', $post->ID ) ):
// er zijn Optimaal Digitaal-tips
$title_id = sanitize_title( $stap_tips_od_titel . '-' . $post->ID );
$return .= '<section aria-labelledby="' . $title_id . '" class="section section--related section--related-optimaaldigitaal-tips">';
$return .= '<div class="l-section-top">';
$return .= '<h2 id="' . $title_id . '" class="section__title">' . $stap_tips_od_titel . '</h2>';
$return .= '</div>';
$return .= '<div class="l-section-content">';
$row_count = count( get_field( 'stap_tips_optimaal_digitaal', $post->ID ) );
if ( ! ( $row_count === 3 ) ):
$return .= '<div class="cards grid grid--col-2">';
else :
$return .= '<div class="cards grid grid--col-3">';
endif;
while ( have_rows( 'stap_tips_optimaal_digitaal', $post->ID ) ) : the_row();
$section_title = get_sub_field( 'stap_tip_optimaal_digitaal_titel' );
$tipnummer = get_sub_field( 'stap_tip_optimaal_digitaal_tipnummer' );
$section_link = get_sub_field( 'stap_tip_optimaal_digitaal_url' );
$section_class = get_sub_field( 'stap_tip_optimaal_digitaal_tipthema' );
$title_id = sanitize_title( $section_title );
$section_title = od_wbvb_custom_post_title( $section_title );
if ( $args['getmenu'] ) {
$menuarray[ $title_id ] = $section_title;
} else {
$tipcard = '<div class="card card--tipkaart tipkaart ' . $section_class . '">';
$tipcard .= ( $section_link ? '<a href="' . $section_link . '" class="tipkaart__link">' : '' );
$tipcard .= '<span class="tipkaart__nummer">Tip ' . $tipnummer . '</span>';
$tipcard .= '<h3 class="tipkaart__title" id="' . $title_id . '">' . $section_title . '</h3>';
$tipcard .= '<span class="tipkaart__categorie">' . $section_class . '</span>';
$tipcard .= ( $section_link ? '</a>' : '' );
$tipcard .= '</div>';
$return .= $tipcard;
}
endwhile;
$return .= '</div>'; // .cards grid grid--col-2
$return .= '</div>'; // .l-section-content
$return .= '</section>';
else:
// nothing
endif; // $stap_tips_od
} // if (function_exists('get_field'))
else {
$return = 'Activeer ACF plugin';
}
if ( $args['getmenu'] ) {
return $menuarray;
} elseif ( $args['echo'] ) {
echo $return;
} else {
return $return;
}
}
//========================================================================================================
/**
* Handles the front-end display.
*
* @return void
*/
public function ictu_gc_frontend_home_template_stappen() {
global $post;
ictu_gctheme_home_template_stappen( $post, trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/images/stappenplan-bg-fullscreen.svg' );
}
//========================================================================================================
/**
* Register frontend styles
*/
public function ictu_gc_frontend_home_template_doelgroepen() {
global $post;
if ( have_rows( 'home_template_doelgroepen' ) ):
$section_title = _x( 'Doelgroepen', 'titel op Stap-pagina', 'ictu-gc-posttypes-inclusie' );
$title_id = sanitize_title( $section_title . '-' . $post->ID );
$posttype = '';
echo '<div class="region region--content-top">' .
'<div class="overview">' .
// Items
'<div class="overview__items grid grid--col-3">';
// loop through the rows of data
while ( have_rows( 'home_template_doelgroepen' ) ) : the_row();
$doelgroep = get_sub_field( 'home_template_doelgroepen_doelgroep' );
$citaat = get_sub_field( 'home_template_doelgroepen_citaat' );
echo ictu_gctheme_card_doelgroep( $doelgroep, $citaat );
endwhile;
echo '</div>'; // .overview__items grid grid--col-3
echo '</div>'; // .overview
$doelgroeplink = get_post_type_archive_link( GC_INCLUSIE_DOELGROEP_CPT );
$label = _x( 'Alle doelgroepen', 'Linktekst doelgroepoverzicht', 'ictu-gc-posttypes-inclusie' ); // $obj->name;
$doelgroeppaginaid = get_field( 'themesettings_inclusie_doelgroeppagina', 'option' );
if ( $doelgroeppaginaid ) {
$doelgroeplink = get_permalink( $doelgroeppaginaid );
$label = get_the_title( $doelgroeppaginaid );
}
echo '<a href="' . $doelgroeplink . '" class="btn btn--primary ' . $posttype . '">' . $label . '</a>';
endif;
}
//========================================================================================================
/**
* Register frontend styles
*/
public function ictu_gc_append_header_css_local() {
global $post;
if ( ! defined( 'ID_SKIPLINKS' ) ) {
define( 'ID_SKIPLINKS', 'skiplinks' );
}
$dependencies = array( ID_SKIPLINKS );
wp_enqueue_style(
GC_INCLUSIE_ARCHIVE_CSS,
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/frontend.css',
$dependencies,
GC_INCLUSIE_INCL_VERSION,
'all'
);
$header_css = '';
$acfid = get_the_id();
$page_template = get_post_meta( $acfid, '_wp_page_template', true );
if ( ! is_admin() && ( $this->template_home == $page_template ) ) {
if ( have_rows( 'home_template_doelgroepen' ) ):
// loop through the rows of data
while ( have_rows( 'home_template_doelgroepen' ) ) : the_row();
$doelgroep = get_sub_field( 'home_template_doelgroepen_doelgroep' );
$posttype = get_post_type( $doelgroep->ID );
$title_id = sanitize_title( $posttype . '-' . $doelgroep->ID );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $doelgroep->ID ), 'large' );
if ( $image[0] ) {
$header_css .= "#" . $title_id . " .featured-image { ";
$header_css .= "background-image: url('" . $image[0] . "'); ";
$header_css .= "} ";
} else {
// $header_css .= "background: yellow;";
}
endwhile;
endif;
}
$gerelateerdecontent = get_field( 'gerelateerde_content_toevoegen', $acfid );
if ( 'ja' === $gerelateerdecontent ) {
$related_items = get_field( 'content_block_items' );
// loop through the rows of data
foreach ( $related_items as $post ):
setup_postdata( $post );
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
if ( $image[0] ) {
$header_css .= "#related_" . $post->ID . " .card__image { ";
$header_css .= "background-image: url('" . $image[0] . "'); ";
$header_css .= "} ";
}
endforeach;
wp_reset_postdata();
}
if ( $header_css ) {
wp_add_inline_style( GC_INCLUSIE_ARCHIVE_CSS, $header_css );
}
}
//========================================================================================================
/**
* Register frontend styles
*/
public function ictu_gc_register_frontend_style_script() {
global $post;
$infooter = true;
// to do: geen externe scripts laden
$version = GC_INCLUSIE_INCL_VERSION;
$version_btn = GC_INCLUSIE_INCL_VERSION;
if ( WP_DEBUG ) {
// als WP_DEBUG actief, gebruik filedate als versienummer
$version = filemtime( dirname( __FILE__ ) . '/js/stepchart.js' );
$version_btn = filemtime( dirname( __FILE__ ) . '/js/btn.js' );
}
wp_enqueue_script( 'gen-jquery-ui', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', '', $version, $infooter );