-
Notifications
You must be signed in to change notification settings - Fork 0
/
badges.tpl.php
176 lines (159 loc) · 5.69 KB
/
badges.tpl.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
<?php global $camptix; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php esc_html_e( 'WordCamp Badges' ); ?></title>
<style id="badges-css"></style>
<style>
html, body {
margin: 0 !important;
padding: 0 !important;
}
#use-firefox,
#style-tweak {
padding: 1em 2em;
}
#style-tweak textarea,
#style-tweak .CodeMirror {
width: 100%;
max-width: 45em;
height: 500px;
display: block;
}
#style-tweak .CodeMirror {
border: 1px solid #ccc;
}
@media print {
#style-tweak {
display: none;
}
}
</style>
<?php if ( defined( 'JETPACK__PLUGIN_FILE' ) ) : ?>
<script src="<?php echo esc_url( plugins_url( 'modules/custom-css/custom-css/js/codemirror.min.js', JETPACK__PLUGIN_FILE ) ); ?>"></script>
<link rel="stylesheet" href="<?php echo esc_url( plugins_url( 'modules/custom-css/custom-css/css/codemirror.min.css', JETPACK__PLUGIN_FILE ) ); ?>">
<?php endif; ?>
</head>
<body>
<?php
$attendees = get_posts( array(
'post_type' => 'tix_attendee',
'posts_per_page' => -1,
'post_status' => array( 'publish', 'pending' ),
'orderby' => 'title',
'fields' => 'ids', // ! no post objects
'cache_results' => false,
) );
if ( ! is_array( $attendees ) || count( $attendees ) < 1 ) {
echo esc_html__( 'No attendees found to make badges for.' ) . "\r\n</body>\r\n</html>";
return;
}
?>
<p id="use-firefox"><?php esc_html_e( 'Make sure to use Firefox to print these badges. Some other browsers (like Chrome) don\'t respect some CSS properties that we use to specify where page breaks should be.' ); ?></p>
<form id="style-tweak">
<label for="styletweak-css"><?php esc_html_e( 'You can modify the CSS for the badges here -- if you make a mistake, you can reset it back to the original markup. Changes are not saved if you leave this page, so you may want to save them locally or on gist.github.com' ); ?></label>
<textarea id="style-tweak-css"></textarea>
<input id="style-tweak-update" type="submit" value="<?php esc_attr_e( 'Update' ); ?>" />
<input id="style-tweak-reset" type="reset" value="<?php esc_attr_e( 'Reset' ); ?>" />
</form>
<br /><br /><br />
<?php
// Disable object cache for prepared metadata.
$camptix->filter_post_meta = $camptix->prepare_metadata_for( $attendees );
foreach ( $attendees as $attendee_id ) :
$first = get_post_meta( $attendee_id, 'tix_first_name', true );
$last = get_post_meta( $attendee_id, 'tix_last_name', true );
$name = $camptix->format_name_string( '<span class="tix-first">%first%</span> <span class="tix-last">%last%</span>', esc_html( $first ), esc_html( $last ) );
$email = get_post_meta( $attendee_id, 'tix_email', true );
$avatar = get_avatar_url( $email, array( 'size' => 600 ) );
?>
<article class="attendee">
<section class="back">
<header>
<?php if ( has_custom_logo() ) : ?>
<?php the_custom_logo(); ?>
<?php else : ?>
<h1><?php bloginfo( 'name' ); ?></h1>
<?php endif; ?>
</header>
<figure>
<img src="<?php echo esc_url( $avatar ); ?>" />
<figcaption>
<h3 class="name"><?php echo $name; /* already escaped above */ ?></h3>
</figcaption>
</figure>
</section>
<section class="front">
<div class="holepunch">Ⓧ</div>
<header>
<?php if ( has_custom_logo() ) : ?>
<?php the_custom_logo(); ?>
<?php else : ?>
<h1><?php bloginfo( 'name' ); ?></h1>
<?php endif; ?>
</header>
<figure>
<img src="<?php echo esc_url( $avatar ); ?>" />
<figcaption>
<h3 class="name"><?php echo $name; /* already escaped above */ ?></h3>
</figcaption>
</figure>
</section>
</article>
<?php endforeach; ?>
<script id="badges-css-original" type="text/css">
<?php readfile( dirname( __FILE__ ) . '/badges.css' ); ?>
</script>
<script>
(function(d){
var styleElement = d.getElementById( 'badges-css' ),
stylesOriginal = d.getElementById( 'badges-css-original' ).innerText.trim(),
styleTweak = d.getElementById( 'style-tweak' ),
styleTweakCss = d.getElementById( 'style-tweak-css' ),
styleTweakUpdate = d.getElementById( 'style-tweak-update' ),
styleTweakReset = d.getElementById( 'style-tweak-reset' );
styleElement.textContent = stylesOriginal;
styleTweakCss.value = stylesOriginal;
<?php if ( defined( 'JETPACK__PLUGIN_FILE' ) ) : ?>
var cmEditor = CodeMirror.fromTextArea( styleTweakCss, {
lineNumbers : true,
tabSize : 2,
indentWithTabs : true,
lineWrapping : true
});
<?php else : ?>
styleTweakCss.addEventListener( 'keydown', function(e) {
if( e.keyCode === 9 ) { // tab was pressed
// get caret position/selection
var start = this.selectionStart,
end = this.selectionEnd,
target = e.target,
value = target.value;
// set textarea value to: text before caret + tab + text after caret
target.value = value.substring( 0, start )
+ '\t'
+ value.substring( end );
// put caret at right position again (add one for the tab)
this.selectionStart = this.selectionEnd = start + 1;
// prevent the focus lose
e.preventDefault();
}
} );
<?php endif; ?>
styleTweak.addEventListener( 'submit', function(e){
e.preventDefault();
styleElement.textContent = styleTweakCss.value;
});
styleTweak.addEventListener( 'reset', function(e){
e.preventDefault();
styleElement.textContent = stylesOriginal;
<?php if ( defined( 'JETPACK__PLUGIN_FILE' ) ) : ?>
cmEditor.setValue( stylesOriginal );
<?php else : ?>
styleTweakCss.value = stylesOriginal;
<?php endif; ?>
});
})(document);
</script>
</body>
</html>