-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·697 lines (554 loc) · 22.3 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
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
<?php
/***************************************************************
* INDEX
* 1.0 SETUP (concerns ADMIN + THEME)
* 1.1 Enqueue Scripts
* 1.2 General theme options
* 1.3 Register Menus
* 2.0 ADMIN
* 2.1 Remove default screen metaboxes
* 2.2 Cleanup Dashboard
* 2.3 Customize Admin
* 2.4 Hide Login Errors
* 3.0 THEME
* 3.1 Clean <head>
* 3.2 Add Section Class
* 3.3 has_attachments()
* 3.4 Remove More Jump
* 3.5 Get first Category of post
* 3.6 Display Bootstrap Pagination
* 3.7 Has more
* 3.8 Insert Images with Figure/figcaption
* 3.9 Customize Theme
* 3.10 Make twitter embedd responsive
* 3.11 Overwrite Notes Plugin
* 3.12 Embedd Gist links
* 3.13 Allow fullscreen video embeds
* 3.14 Disable Jetpack Opengraph
* 3.15 List Tags shortcode
* 3.16 Get Sites patch
*
***************************************************************/
require_once( 'libs/wp-less/wp-less.php' );
require_once( 'libs/ChromePhp.php' );
function debug( $msg ) {
return WP_DEBUG ? ChromePhp::log($msg) : false;
}
/***************************************************************
* 1.1 ENQUEUE SCRIPTS
***************************************************************/
function theme_ressources() {
// wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
wp_deregister_script('l10n');
wp_deregister_script('jquery');
/*wp_enqueue_script('jquery');
wp_enqueue_script('init', get_template_directory_uri() . '/js/init.js', array('jquery'), '1.0', true ); */
// wp_enqueue_style( $handle, $src, $deps, $ver, $media );
if ( !is_admin() )
wp_enqueue_style( 'style', get_template_directory_uri() . '/less/jbm.less' );
}
add_action('wp_enqueue_scripts', 'theme_ressources');
/***************************************************************
* 1.2 General theme options
***************************************************************/
add_theme_support( 'post-thumbnails' );
add_editor_style( 'less/editor.less' );
load_theme_textdomain( 'jbm', get_template_directory() .'/language' );
/***************************************************************
* 1.3 Register Menus
***************************************************************/
register_nav_menus(array(
'navigation' => __('Navigation', 'jbm'),
'footer-links' => __('Footer Links', 'jbm'),
));
/***************************************************************
* 1.4 Echoes bloginfo as shortcode
***************************************************************/
function bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
'key' => '',
), $atts));
return get_bloginfo($key);
}
add_shortcode('bloginfo', 'bloginfo_shortcode');
/***************************************************************
* 2.1 Remove default screen metaboxes
***************************************************************/
function remove_default_screen_metaboxes() {
// remove_default_post_screen_metaboxes
remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Metabox
remove_meta_box( 'trackbacksdiv','post','normal' ); // Talkback Metabox
remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
// remove_default_page_screen_metaboxes
remove_meta_box( 'postcustom','post','normal' ); // Custom Fields Metabox
remove_meta_box( 'commentstatusdiv','post','normal' ); // Comments Metabox
remove_meta_box( 'trackbacksdiv','post','normal' ); // Talkback Metabox
remove_meta_box( 'authordiv','post','normal' ); // Author Metabox
}
add_action( 'admin_menu', 'remove_default_screen_metaboxes' );
/***************************************************************
* 2.2 Cleanup Dashboard
***************************************************************/
function clean_dashboard_widgets() {
global $wp_meta_boxes;
//Right Now - Comments, Posts, Pages at a glance
//unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
//Recent Comments
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
//Incoming Links
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
//Plugins - Popular, New and Recently updated Wordpress Plugins
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
//Wordpress Development Blog Feed
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
//Other Wordpress News Feed
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
//Quick Press Form
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
//Recent Drafts List
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);
}
add_action('wp_dashboard_setup', 'clean_dashboard_widgets');
/***************************************************************
* 2.3 Customize Admin: Change admin interface and login page
* Source: http://snipplr.com/view.php?codeview&id=63771
***************************************************************/
// add own css to admin
function add_admin_css() {
wp_enqueue_style('admin', get_template_directory_uri().'/css/admin.css');
}
add_action('admin_print_styles', 'add_admin_css');
// add own js to admin
function add_admin_js() {
wp_enqueue_script('admin', get_template_directory_uri().'/js/admin.js');
}
add_action('admin_print_scripts', 'add_admin_js');
function remove_items_from_adminbar(){
global $wp_admin_bar;
$wp_admin_bar->remove_menu( 'comments' );
$wp_admin_bar->remove_menu( 'backwpup' );
$wp_admin_bar->remove_menu( 'wp-logo' );
$wp_admin_bar->remove_menu( 'appearance' );
$wp_admin_bar->remove_menu( 'my-account-with-avatar' );
}
add_action( 'wp_before_admin_bar_render', 'remove_items_from_adminbar' );
/***************************************************************
* 3.1 Clean <head>: Use Template instead.
***************************************************************/
function remheadlink() {
// Remove links to the extra feeds (e.g. category feeds)
// remove_action( 'wp_head', 'feed_links_extra', 3 );
// Remove links to the general feeds (e.g. posts and comments)
// remove_action( 'wp_head', 'feed_links', 2 );
// Remove link to the RSD service endpoint, EditURI link
// remove_action( 'wp_head', 'rsd_link' );
// Remove link to the Windows Live Writer manifest file
// remove_action( 'wp_head', 'wlwmanifest_link' );
// Remove index link
// remove_action( 'wp_head', 'index_rel_link' );
// Remove prev link
// remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
// Remove start link
// remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
// Display relational links for adjacent posts
// remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
// Remove XHTML generator showing WP version
remove_action( 'wp_head', 'wp_generator' );
}
add_action('init', 'remheadlink');
/***************************************************************
* 3.2 Add Section Class: Add the top level page to the body class for coloured sections
***************************************************************/
function body_class_section( $classes ) {
global $wpdb, $post;
if (is_page()) {
if ($post->post_parent) {
$parent = end(get_post_ancestors($current_page_id));
} else {
$parent = $post->ID;
}
$post_data = get_post($parent, ARRAY_A);
$classes[] = 'section-' . $post_data['post_name'];
}
return $classes;
}
add_filter( 'body_class', 'body_class_section' );
/***************************************************************
* 3.3 has_attachments(): returns true if post has attachments
* Description:
***************************************************************/
function has_attachments( $post_id = null ) {
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
$args = array(
'post_type' => 'attachment',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $post_id
);
$attachments = get_posts($args);
if ($attachments)
return true;
else
return false;
}
/***************************************************************
* 3.4 Add post thumbnail to content
***************************************************************/
function add_post_thumbnail_to_content( $content ) {
global $post;
// Do nothing if post has no thumbnail set
if ( ! has_post_thumbnail( $post->ID ))
return $content;
$id = get_post_thumbnail_id( $post->ID );
// attach thumbnail even if post has no more tag set
if ( ! $pos = strpos( $post->post_content, '<!--more-->' ))
return $content . "[image id='$id']";
// on single post insert thumbnail into article flow
return str_replace( '<p><span id="more-', '[image id="'. $id .'"][toc levels=2 title="Table of Contents"]<p><span id="more-', $content );
}
add_filter( 'the_content', 'add_post_thumbnail_to_content' );
function replace_more_link_with_post_thumbnail( $more_link, $more_link_text ) {
global $post;
if ( ! has_post_thumbnail($post->ID) )
return '';
$id = get_post_thumbnail_id($post->ID);
return str_replace( $more_link_text, "[image id='$id']", $more_link );
}
add_filter( 'the_content_more_link', 'replace_more_link_with_post_thumbnail', 10, 2 );
/***************************************************************
* 3.5 Get first Category of post
***************************************************************/
function get_first_category() {
$category = get_the_category();
return $category[0]->cat_name;
}
/***************************************************************
* 3.6 Display Pagination
***************************************************************/
function pagination() {
global $wp_query;
$big = 999999999; // need an unlikely integer
if ( $wp_query->max_num_pages < 2 )
return;
$output = '<nav role="navigation">';
$output .= paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'show_all' => false,
'end_size' => 1,
'mid_size' => 2,
'prev_next' => true,
'prev_text' => '«',
'next_text' => '»',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type' => 'list'
) );
$output .= '</nav>';
return $output;
}
/***************************************************************
* 3.7 Has more
* http://wordpress.org/support/topic/conditional-tag-to-check-for-lt-more-gt
***************************************************************/
function has_more( ) {
global $post;
return ( strstr( $post->post_content,'<!--more-->' ) ? true : false );
}
/***************************************************************
* 3.8 Use shortcode for images
***************************************************************/
function insert_image_shortcode($html, $id, $caption, $title, $align, $url) {
return "[image id='$id']";
}
add_filter( 'image_send_to_editor', 'insert_image_shortcode', 10, 9 );
if ( ! isset( $content_width ) ) $content_width = 960;
function image_shortcode( $atts ) {
global $post, $content_width;
extract(shortcode_atts(array(
'id' => '',
'class' => ''
), $atts));
if (empty($id))
return '';
$save_id = get_current_blog_id();
$blog_list = wp_get_sites( 0, 'all' );
// Search for the site the image comes from
foreach ( $blog_list AS $blog ) {
switch_to_blog( $blog['blog_id'] );
if ( wp_get_attachment_image_src( $id, 'full') ) break;
}
$caption = get_post_field( 'post_excerpt', $id );
$title = get_post_field( 'post_title', $id );
$image_src = wp_get_attachment_image_src( $id, 'full' );
$image = wp_get_attachment_image($id, 'large', false, array(
'src' => $image_src[0] . '?filter=grayscale'
));
$output = '<figure class="media-'. $id .' '. $class .'">';
if ($image_src[1] > $content_width) {
if (is_single() || is_page())
$link = $image_src[0];
else
$link = get_permalink($post->ID);
$output .= '<a href="'. $link .'">'. $image .'</a>';
} else {
$output .= wp_get_attachment_image($id, 'full');
}
if ($caption)
$output .= "<figcaption><strong>$title:</strong> $caption</figcaption>";
$output .= '</figure>';
// switch back to original site
switch_to_blog( $save_id );
return $output;
}
add_shortcode('image', 'image_shortcode');
/***************************************************************
* 3.9 Customize Theme
***************************************************************/
function theme_customize_register( $wp_customize ) {
// COLORS
$wp_customize->add_section( 'theme_colors' , array(
'title' => __('Custom Colors', 'jbm'),
'priority' => 30,
) );
$wp_customize->add_setting( 'highlight_color' , array(
'default' => '#08c',
'type' => 'theme_mod',
'transport' => 'postMessage'
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'highlight_color', array(
'label' => __( 'Highlight Color', 'jbm' ),
'section' => 'theme_colors',
'settings' => 'highlight_color',
) ) );
// LOGO
$wp_customize->add_section( 'theme_text' , array(
'title' => __('Logo', 'jbm'),
'priority' => 30,
) );
$wp_customize->add_setting( 'logo_text' , array(
'default' => get_bloginfo('name'),
'type' => 'theme_mod'
) );
$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'logo_text', array(
'label' => __( 'Logo Text', 'jbm' ),
'section' => 'theme_text',
'settings' => 'logo_text',
) ) );
// FAVICONS
$wp_customize->add_section( 'favicons' , array(
'title' => __('Favicons', 'jbm'),
'priority' => 30,
) );
$wp_customize->add_setting( 'favicon_ico' , array(
'type' => 'theme_mod'
) );
$wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'favicon_ico', array(
'label' => __( 'Favicon (.ico)', 'jbm' ),
'section' => 'favicons',
'settings' => 'favicon_ico',
) ) );
$wp_customize->add_setting( 'favicon_png' , array(
'type' => 'theme_mod'
) );
$wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'favicon_png', array(
'label' => __( 'Favicon (.png)', 'jbm' ),
'section' => 'favicons',
'settings' => 'favicon_png',
) ) );
$wp_customize->add_setting( 'favicon_apple' , array(
'type' => 'theme_mod'
) );
$wp_customize->add_control( new WP_Customize_Upload_Control( $wp_customize, 'favicon_apple', array(
'label' => __( 'Apple Touch Icon (.png)', 'jbm' ),
'section' => 'favicons',
'settings' => 'favicon_apple',
) ) );
}
add_action( 'customize_register', 'theme_customize_register' );
function addUploadMimes($mimes) {
$mimes = array_merge($mimes, array(
'ico' => 'image/x-icon'
));
return $mimes;
}
add_filter('upload_mimes', 'addUploadMimes');
function custom_less_vars( $vars, $handle ) {
$vars[ 'highlight' ] = get_theme_mod('highlight_color');
return $vars;
}
add_filter( 'less_vars', 'custom_less_vars', 10, 2 );
/***************************************************************
* 3.10 Make twitter embedd responsive
***************************************************************/
add_filter( 'embed_oembed_html', 'twitter_no_width', 10, 3 );
function twitter_no_width($html, $url, $args) {
if (false !== strpos($url, 'twitter.com')) {
$html = str_replace('width="500"','',$html);
$html = str_replace('width="550"','',$html);
}
return $html;
}
/***************************************************************
* 3.11 Overwrite Notes Plugin
***************************************************************/
add_filter( 'jbm_notes_title', 'translate_notes_title' );
function translate_notes_title() {
return __( 'Notes', 'jbm' );
}
/***************************************************************
* 3.12 Embedd Gist links
***************************************************************/
wp_embed_register_handler( 'gists', '/\s*gist.github.com?.+\/(\d+)/', 'wp_embed_handler_gists' );
function wp_embed_handler_gists( $matches, $attr, $url, $rawattr ) {
if (false !== strpos($url, 'github.com'))
return '[gist id='. $matches[1] .']';
else
return $url;
}
/***************************************************************
* 3.13 Allow fullscreen video embeds
***************************************************************/
add_filter( 'embed_oembed_html', 'video_in_figure', 10, 3 );
function video_in_figure($html, $url, $args) {
// follow aspect ratio
$atts = array();
preg_match_all('/(width|height|src)=("[^"]*")/i', $html, $atts);
$height = trim( $atts[2][2], '"' );
$width = trim( $atts[2][1], '"' );
$padding = ( $height != 0 && $height != 0 ? $height / $width * 100 : 56.25);
if (false !== strpos($url, 'vimeo.com') && ! empty($atts)) {
$html = str_replace("<iframe", "<figure class='embed-vimeo' style='padding-bottom: $padding%'><iframe", $html);
$html = str_replace("</iframe>", "</iframe></figure>", $html);
}
// not working:
if (false !== strpos($url, 'youtube') && ! empty($atts)) {
$html = str_replace('<span class="embed-youtube" style="text-align:center; display: block;">', "<figure class='embed-youtube' style='padding-bottom: $padding%'>", $html);
$html = str_replace("</span>", "</figure>", $html);
}
return $html;
}
/***************************************************************
* 3.14 Disable Jetpack Opengraph
***************************************************************/
remove_action('wp_head','jetpack_og_tags');
/***************************************************************
* 3.15 List Tags shortcode
***************************************************************/
function get_tag_list( $atts ){
$output = '';
$posttags = get_tags('orderby=count');
$sep = '';
if ($posttags) {
$output .= '<p>';
foreach($posttags as $tag) {
$output .= $sep .'<a href="'. get_tag_link($tag->term_id) .'">'. $tag->name .'</a>';
$sep = ', ';
}
}
return $output;
}
add_shortcode( 'tags', 'get_tag_list' );
/***************************************************************
* 3.16 Get Sites patch
* http://core.trac.wordpress.org/ticket/14511
***************************************************************/
if( !function_exists('wp_get_sites') ) {
/**
* Return a list of sites for the current network
*
* @since 3.5.0
*
* @param array|string $args Optional. Override default arguments.
* @return array site list and values
*/
function wp_get_sites( $args = array() ) {
// replacement for wp-includes/ms-deprecated.php#get_blog_list
// see wp-admin/ms-sites.php#352
// also wp-includes/ms-functions.php#get_blogs_of_user
// also wp-includes/post-template.php#wp_list_pages
global $wpdb;
$defaults = array(
'include_public' => '1', // Include blogs marked as public
'include_archived' => '0', // Include archived sites
'include_mature' => '0', // Included blogs marked as mature
'include_spam' => '0', // Include sites marked as "spam"
'include_deleted' => '0', // Include deleted sites
'domain' => '', // domain is this value
'path' => '', // path is like this value
'reg_date_since' => '', // sites registered since (accepts pretty much any valid date like tomorrow, today, 5/12/2009, etc.)
'reg_date_before' => '', // sites registered before
'sort_column' => 'registered',// or last_updated, blogname, site_id.
'order' => 'desc', // or asc
'limit_results' => '', // return this many results
'start' => '', // return results starting with this item
'postcount' => false // add postcount info - default to false
);
$r = wp_parse_args( $args, $defaults );
extract( $r, EXTR_SKIP );
$query = "SELECT * FROM $wpdb->blogs WHERE site_id = %d ";
$query_args = Array( $wpdb->siteid );
foreach( Array( 'public', 'archived', 'mature', 'spam', 'deleted' ) as $param ) {
$var = "include_{$param}";
$var = $$var;
if ( $var == 1 )
$query .= " AND $param = '1' ";
elseif ( ( $var === 0 ) || ( $var === '0' ) )
$query .= " AND $param = '0' ";
}
if ( !empty( $domain ) ) {
$query .= " AND ( domain = '%s' ) ";
$query_args[] = $domain;
}
if ( !empty( $path ) ) {
$query .= " AND ( path LIKE '%%%s%%' ) ";
$query_args[] = $path;
}
if( !empty( $reg_date_since ) ) {
$query .= " AND unix_timestamp( b.date_registered ) > '%s' ";
$query_args[] = strtotime( $reg_date_since );
}
if( !empty( $reg_date_before ) ) {
$query .= " AND unix_timestamp( b.date_registered ) < '%s' ";
$query_args[] = strtotime( $reg_date_before );
}
$sort_column = strtolower( $sort_column );
if ( !in_array( $sort_column, Array( 'registered', 'last_updated', 'blog_id', 'domain' ) ) )
$sort_column = 'registered';
$query .= " ORDER BY {$sort_column} ";
$order = strtoupper( $order );
if ( $order !== 'ASC' ) $order = 'DESC';
$query .= $order;
if ( !empty( $start ) || !empty( $limit_results ) ) {
if ( empty( $start ) )
$start = 0;
else
$start = absint( $start );
if ( empty( $limit_results ) )
$limit_results = '18446744073709551615'; // 2^64 - 1 -- see docs for LIMIT in http://dev.mysql.com/doc/refman/5.0/en/select.html
else
$limit_results = absint( $limit_results );
if ( empty( $start ) ) {
if ( !empty( $limit_results ) ) $query .= " LIMIT $limit_results";
} else {
$query .= " LIMIT $start, $limit_results";
}
}
$blogs = $wpdb->get_results( $wpdb->prepare( $query, $query_args ), ARRAY_A );
$blog_list = Array();
foreach ( (array) $blogs as $details ) {
$blog_list[ $details['blog_id'] ] = $details;
if ( $postcount )
$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->get_blog_prefix( $details['blog_id'] ). "posts WHERE post_status='publish' AND post_type='post'" );
}
unset( $blogs );
$blogs = $blog_list;
if ( false == is_array( $blogs ) )
return array();
return $blogs;
}
}
/***************************************************************
* X.X Code Template
***************************************************************/