-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
406 lines (352 loc) · 13.6 KB
/
Copy pathfunctions.php
File metadata and controls
406 lines (352 loc) · 13.6 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
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
<?php
function fabric_scripts() {
wp_enqueue_style( 'fabric', get_template_directory_uri() . '/css/fabric.min.css', array(), '1.4.0' );
wp_enqueue_style( 'fabric-components', get_template_directory_uri() . '/css/fabric.components.min.css', array(), '1.4.0' );
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_script( 'fabric-js', get_template_directory_uri() . '/js/fabric.min.js', array( ), '1.4.0', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'fabric_scripts' );
add_theme_support( 'title-tag' );
add_theme_support( 'post-thumbnails' );
add_theme_support( 'automatic-feed-links' );
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 500, 300, true );
if ( ! isset ( $content_width) ) { $content_width = 800; }
add_theme_support( 'post-formats', array ( 'aside', 'status', 'quote' ) );
function themename_custom_post_formats_setup() {
add_post_type_support( 'page', 'post-formats' );
}
add_action( 'init', 'themename_custom_post_formats_setup' );
function register_my_menus() {
register_nav_menus(
array(
'nav-menu' => __( 'Navigation Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
add_theme_support( 'customize-selective-refresh-widgets' );
add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
function gitbit_widgets_init() {
register_sidebar( array(
'name' => 'Right sidebar',
'id' => 'right_sidebar',
'before_widget' => '<section class="ms-Grid-col ms-u-sm12 ms-u-md6 ms-u-lg4 ms-u-xl12"><div class="widget">',
'after_widget' => '</div></section>',
'before_title' => '<h2 class="ms-font-xl">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => 'Footer sidebar',
'id' => 'footer_sidebar',
'before_widget' => '<section class="ms-Grid-col ms-u-sm12 ms-u-md6 ms-u-lg3"><div class="footer-widget ms-font-l">',
'after_widget' => '</div></section>',
'before_title' => '<h3 class="footer-widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'gitbit_widgets_init' );
function customize_post() {
add_meta_box(
'fabric_meta_box', // $id
'GitBit', // $title
'show_fabric_meta_box', // $callback
'post', // $screen
'normal', // $context
'high' // $priority
);
}
add_action( 'add_meta_boxes', 'customize_post' );
function customize_page() {
add_meta_box(
'fabric_meta_box', // $id
'GitBit', // $title
'show_fabric_meta_box', // $callback
'page', // $screen
'normal', // $context
'high' // $priority
);
}
add_action( 'add_meta_boxes', 'customize_page' );
function show_fabric_meta_box() {
global $post;
$meta = get_post_meta( $post->ID, 'gitbit', true );
$backgroundcolor = "";
if (!empty( $meta )) {
$backgroundcolor = esc_attr($meta['backgroundcolor']);
} ?>
<input type="hidden" name="fabric_nonce" value="<?php echo wp_create_nonce( basename(__FILE__) ); ?>">
<p>
<label for="gitbit[backgroundcolor]">background color</label>
<br>
<input type="text" name="gitbit[backgroundcolor]" id="gitbit[backgroundcolor]" class="regular-text" value="<?php echo $backgroundcolor ?>">
</p>
<?php }
function save_your_fields_meta( $post_id ) {
if ( !isset( $_POST['fabric_nonce'] ) || !wp_verify_nonce( $_POST['fabric_nonce'], basename( __FILE__ ) ) )
return $post_id;
// check autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
// check permissions
if ( 'page' === $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) ) {
return $post_id;
} elseif ( !current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
$old = get_post_meta( $post_id, 'gitbit', true );
$new = $_POST['gitbit'];
if ( $new && $new !== $old ) {
update_post_meta( $post_id, 'gitbit', $new );
} elseif ( '' === $new && $old ) {
delete_post_meta( $post_id, 'gitbit', $old );
}
}
add_action( 'save_post', 'save_your_fields_meta' );
// *** category customization ***
//add extra fields to category edit form callback function
function extra_category_fields( $tag ) { //check for existing featured ID
$t_id = $tag->term_id;
$cat_meta = get_option( "category_$t_id");
?>
<tr class="form-field">
<th scope="row" valign="top"><label for="subheading"><?php _e('Category subheading'); ?></label></th>
<td>
<input type="text" name="Cat_meta[subheading]" id="Cat_meta[subheading]" size="25" style="width:60%;" value="<?php echo $cat_meta['subheading'] ? $cat_meta['subheading'] : ''; ?>"><br />
<span class="description"><?php _e('Subheading of category'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="cat_Image_url"><?php _e('Category Image Url'); ?></label></th>
<td>
<input type="text" name="Cat_meta[img]" id="Cat_meta[img]" size="3" style="width:60%;" value="<?php echo $cat_meta['img'] ? $cat_meta['img'] : ''; ?>"><br />
<span class="description"><?php _e('Image for category: use full url with '); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony_title"><?php _e('Testimonies title'); ?></label></th>
<td>
<input type="text" name="Cat_meta[testimony_title]" id="Cat_meta[testimony_title]" size="25" style="width:60%;" value="<?php echo $cat_meta['testimony_title'] ? $cat_meta['testimony_title'] : ''; ?>"><br />
<span class="description"><?php _e('Title shown above the testimonies'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony1_url"><?php _e('Testimony 1 url'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony1_url]" id="Cat_meta[testimony1_url]" style="width:60%;"><?php echo $cat_meta['testimony1_url'] ? $cat_meta['testimony1_url'] : ''; ?></textarea><br />
<span class="description"><?php _e('url for testimony 1 link'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony1_image"><?php _e('Testimony 1 image'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony1_image]" id="Cat_meta[testimony1_image]" style="width:60%;"><?php echo $cat_meta['testimony1_image'] ? $cat_meta['testimony1_image'] : ''; ?></textarea><br />
<span class="description"><?php _e('url pointing to testimony 1 image'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony2_url"><?php _e('Testimony 2 url'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony2_url]" id="Cat_meta[testimony2_url]" style="width:60%;"><?php echo $cat_meta['testimony2_url'] ? $cat_meta['testimony2_url'] : ''; ?></textarea><br />
<span class="description"><?php _e('url for testimony 1 link'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony2_image"><?php _e('Testimony 2 image'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony2_image]" id="Cat_meta[testimony2_image]" style="width:60%;"><?php echo $cat_meta['testimony2_image'] ? $cat_meta['testimony2_image'] : ''; ?></textarea><br />
<span class="description"><?php _e('url pointing to testimony 2 image'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony3_url"><?php _e('Testimony 3 url'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony3_url]" id="Cat_meta[testimony3_url]" style="width:60%;"><?php echo $cat_meta['testimony3_url'] ? $cat_meta['testimony3_url'] : ''; ?></textarea><br />
<span class="description"><?php _e('url for testimony 3 link'); ?></span>
</td>
</tr>
<tr class="form-field">
<th scope="row" valign="top"><label for="testimony3_image"><?php _e('Testimony 3 image'); ?></label></th>
<td>
<textarea name="Cat_meta[testimony3_image]" id="Cat_meta[testimony3_image]" style="width:60%;"><?php echo $cat_meta['testimony3_image'] ? $cat_meta['testimony3_image'] : ''; ?></textarea><br />
<span class="description"><?php _e('url pointing to testimony 3 image'); ?></span>
</td>
</tr>
<?php
}
//add extra fields to category edit form hook
add_action ( 'edit_category_form_fields', 'extra_category_fields');
// save extra category extra fields callback function
function save_extra_category_fileds( $term_id ) {
if ( isset( $_POST['Cat_meta'] ) ) {
$t_id = $term_id;
$cat_meta = get_option( "category_$t_id");
$cat_keys = array_keys($_POST['Cat_meta']);
foreach ($cat_keys as $key){
if (isset($_POST['Cat_meta'][$key])){
$cat_meta[$key] = $_POST['Cat_meta'][$key];
}
}
//save the option array
update_option( "category_$t_id", $cat_meta );
}
}
// save extra category extra fields hook
add_action ( 'edited_category', 'save_extra_category_fileds');
// *** END OF CATEGORY SECTION ***
function analytics_footer() {
get_template_part( 'template-parts/meta/google-analytics' );
}
add_action( 'wp_footer', 'analytics_footer' );
function create_post_type() {
register_post_type( 'gitbit_product',
array(
'labels' => array(
'name' => __( 'Products' ),
'singular_name' => __( 'Product' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'legal-products'),
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'page-attributes')
)
);
register_taxonomy('gitbit_product_topic', 'gitbit_product', array(
'labels' => array(
'name' => 'Topic',
'add_new_item' => 'Add New Topic',
'new_item_name' => "New Topic Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'public' => false
));
register_taxonomy('gitbit_product_feature', 'gitbit_product', array(
'labels' => array(
'name' => 'Features',
'add_new_item' => 'Add New Feature',
'new_item_name' => "New Feature Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
));
register_taxonomy('gitbit_product_integration', 'gitbit_product', array(
'labels' => array(
'name' => 'Integrations',
'add_new_item' => 'Add New Integration',
'new_item_name' => "New Integration Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'products/integrations' )
));
register_taxonomy('gitbit_product_devices', 'gitbit_product', array(
'labels' => array(
'name' => 'Device support',
'add_new_item' => 'Add New Device',
'new_item_name' => "New Device Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => 'products/devices' )
));
register_taxonomy('gitbit_product_services', 'gitbit_product', array(
'labels' => array(
'name' => 'Services',
'add_new_item' => 'Add New Service',
'new_item_name' => "New Service Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
));
register_taxonomy('gitbit_product_practices', 'gitbit_product', array(
'labels' => array(
'name' => 'Practice Area',
'add_new_item' => 'Add New Practice Area',
'new_item_name' => "New Practice Area Type"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
));
}
add_action( 'init', 'create_post_type' );
function customize_gitbit_product() {
add_meta_box(
'gitbit_product_meta_box', // $id
'GitBit Product Details', // $title
'show_gitbit_product_meta_box', // $callback
'gitbit_product', // $screen
'normal', // $context
'high' // $priority
);
}
add_action( 'add_meta_boxes', 'customize_gitbit_product' );
function show_gitbit_product_meta_box() {
global $post;
$meta = get_post_meta( $post->ID, 'gitbit_product', true );
$slideshare = "";
$video = "";
$quote1 = "";
$quote2 = "";
if (!empty( $meta )) {
$slideshare = esc_attr($meta['slideshare']);
$video = esc_attr($meta['video']);
$quote1 = esc_attr($meta['quote1']);
$quote2 = esc_attr($meta['quote2']);
}
?>
<input type="hidden" name="gitbit_product_nonce" value="<?php echo wp_create_nonce( basename(__FILE__) ); ?>">
<p>
<label for="gitbit_product[slideshare]">SlideShare URL</label><br>
<input type="text" name="gitbit_product[slideshare]" id="gitbit_product[slideshare]" class="regular-text" value="<?php echo $slideshare ?>">
</p>
<p>
<label for="gitbit_product[video]">Video URL</label><br>
<input type="text" name="gitbit_product[video]" id="gitbit_product[video]" class="regular-text" value="<?php echo $video ?>">
</p>
<p>
<label for="gitbit_product[quote1]">Quote 1</label><br>
<input type="text" name="gitbit_product[quote1]" id="gitbit_product[quote1]" class="regular-text" value="<?php echo $quote1 ?>">
</p>
<p>
<label for="gitbit_product[quote2]">Quote 2</label><br>
<input type="text" name="gitbit_product[quote2]" id="gitbit_product[quote2]" class="regular-text" value="<?php echo $quote2 ?>">
</p>
<?php }
function save_gitbit_product_fields_meta( $post_id ) {
if ( !isset( $_POST['gitbit_product_nonce'] ) || !wp_verify_nonce( $_POST['gitbit_product_nonce'], basename( __FILE__ ) ) )
return $post_id;
// check autosave
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
// check permissions
if ( 'gitbit_product' === $_POST['post_type'] ) {
if ( !current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
}
$old = get_post_meta( $post_id, 'gitbit_product', true );
$new = $_POST['gitbit_product'];
if ( $new && $new !== $old ) {
update_post_meta( $post_id, 'gitbit_product', $new );
} elseif ( '' === $new && $old ) {
delete_post_meta( $post_id, 'gitbit_product', $old );
}
}
add_action( 'save_post', 'save_gitbit_product_fields_meta' );
?>