-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbread-example-extensions.php
More file actions
44 lines (42 loc) · 2.21 KB
/
bread-example-extensions.php
File metadata and controls
44 lines (42 loc) · 2.21 KB
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
<?php
/**
Plugin Name: bread-ext
Plugin URI: none
Description: Show how to add functionality to Bread
Author: Ron B
Version: 0.0.1
*/
add_filter( 'Bread_Meeting_Fields', 'addMeetingFields' ); // Control the fields that are returned when retrieving meetings
// All field names are available for use in templates
add_filter( 'Bread_Enrich_Meeting_Data', 'enrichMeetingData', 10, 2 ); // Add computed fields to the shortcodes in templates
add_filter( 'Bread_Section_Shortcodes', 'sectionShortcodes', 10, 3 ); // Add shortcodes to front-page, last-page and custom-page
function addMeetingFields( $fields ) {
array_push($fields,'public_transport'); // These are two fields defined in my bmlt meeting data.
array_push($fields,'format_comments');
return $fields;
};
function enrichMeetingData($value, $formats_by_key) { // make the string of language formats available for use in template
$enFormats = explode ( ",", $value['formats'] );
$langs = array();
foreach($enFormats as $format_key) {
$format_key = trim($format_key);
if (! isset($formats_by_key[$format_key])) {
continue;
}
if ($formats_by_key[$format_key]['format_type_enum']=='LANG') {
$langs[] = $formats_by_key[$format_key]['name_string'];
}
}
$value['lang_format_names'] = implode('/',$langs);
return $value;
}
function sectionShortcodes($section_shortcodes, $areas, $formats_used) { // In this case, the meetings are printed
// on a 4-column portrait-mode page,
// but we want to fold the meeting list 3 ways, and
// that is how our front page should be printed.
// So we create short codes with the MPDF directives.
$section_shortcodes['[Page-Break-L]'] = '<pagebreak orientation=\"L\"/>';
$section_shortcodes['[Columns-3]'] = '<columns column-count="3" vAlign="justify" column-gap=\"8\"/>';
return $section_shortcodes;
}
?>