-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
237 lines (128 loc) · 4.59 KB
/
functions.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
<?php
define('GAPROPERTYID', 'UA-46685643-1');
add_action( 'after_setup_theme', 'my_ag_child_theme_setup' );
// new feature box
function my_ag_child_theme_setup() {
remove_shortcode( 'feature-box' );
add_shortcode( 'feature-box', 'child_theme_shortcode_feature_box' );
}
function child_theme_shortcode_feature_box($atts, $content = false) {
$output = "";
// get some sort of image from img id
if ( $content ) { $p_class = "feature has-content"; } else { $p_class = "feature has-content"; }
if ($atts["colour"]) {
$p_class .= " " . $atts["colour"];
}
if ( $atts["link"] ) {
$p_class .= " has-link";
}
if ( $atts["link"] ) { $output .= '<a href="' . $atts["link"] . '" title="' . $atts["linktitle"] . '">'; }
$output .= '<div class="' . $p_class . '">';
if ($atts["imgid"] != "" && $atts["imgid"] != 'undefined') {
$img = wp_get_attachment_image_src($atts["imgid"], responsive_conditional_size('medium'));
$output .= '<header>';
$output .= '<img src="' . $img[0] . '" />';
$output .= '</header>';
}
$output .= '<div class="content">';
$output .= '<h2>';
if ($atts["icon"]) { $output .= '<i class="fa fa-' . $atts["icon"] . '"></i>'; }
$output .= $atts["title"];
$output .= '</h2>';
if ( $content ) {
//if ( $atts["link"] ) { $output .= '<a href="' . $atts["link"] . '" title="' . $atts["linktitle"] . '">'; }
$output .= '<div class="copy">' . wpautop($content) . '</div>';
//if ( $atts["link"]) { $output .= '</a>'; }
}
$output .= '</div>';
$output .= '</div>';
if ( $atts["link"]) { $output .= '</a>'; }
return $output;
}
remove_filter("the_content", "WrapStuff");
add_filter("the_content", "BBG_WrapStuff", 0);
function BBG_WrapStuff( $post ) {
$array = array (
"{gallery" => "[gallery",
"{feature-box" => "[feature-box"
);
$post = strtr($post, $array);
$post = strtr($post, $array);
$pattern = "/{{section:(\#?.+)}}/";
$chars = preg_split($pattern, $post, null, PREG_SPLIT_DELIM_CAPTURE);
$original = $post;
$newpost = "";
if (count($chars) == 0) return $post;
$even = true;
foreach ($chars as $key => $match) {
if ($even) {
// content
$newpost .= $match;
if ($key > 0) {
$newpost .= "</div>"; // close div
}
} else {
// flag
if (substr($match, 0, 1) == '#' || substr(strtolower($match), 0, 3) == 'rgb') {
$newpost .= "<div class='section full-width-background' style='background:" . $match . ";'>";
} else {
$newpost .= "<div class='section full-width-background " . $match . "'>";
}
}
$even = ($even) ? false : true;
}
return $newpost;
// /*
// $match == {{section:colour}}
// $matches[1][$key] == colour
// */
// echo $x . "<textarea>" . print_r($match, true) . "</textarea>";
// $chunk = strstr($post, $match, TRUE ); // everything before this instance of the section
// echo "<textarea>" . $chunk . "</textarea>";
// echo "<textarea>" . $post . "</textarea>";
// echo "<textarea>" . strstr($post, $match) . "</textarea>";
// $newpost .= $chunk;
// if ($key > 0) {
// $newpost .= "</div>";
// }
// // open the section
// $newpost .= "<div class='section " . $matches[1][$key] . "'>";
// echo "<hr>";
// $post = str_replace( $match, "", strstr($post, $match) );
// $x++;
// }
// $newpost .= $post . "</div>"; // we never close this in the loop above
// return $newpost;
}
// add_action( 'init', 'create_posttype' );
// function create_posttype() {
// $args = array(
// 'labels' => array(
// 'name' => __( 'Products' ),
// 'singular_name' => __( 'Product' )
// ),
// 'public' => true,
// 'has_archive' => true,
// 'rewrite' => array('slug' => 'products'),
// 'supports' => array( 'thumbnail' )
// );
// register_post_type( 'products', $args);
// }
function codex_custom_init() {
$args = array(
'public' => true,
'label' => 'Menu',
'supports' => array( 'thumbnail', 'editor', 'title' )
);
register_post_type( 'menu', $args );
}
add_action( 'init', 'codex_custom_init' );
function get_events() {
$args = array(
'public' => true,
'label' => 'Events',
'supports' => array( 'thumbnail', 'editor', 'title', 'excerpt' )
);
register_post_type( 'event', $args );
}
add_action( 'init', 'get_events' );