-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
95 lines (83 loc) · 2.88 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
<?php
// Import global CSS files
function my_css() {
wp_enqueue_style(
'main', get_template_directory_uri() . '/static/css/main.css',
);
}
add_action( 'wp_enqueue_scripts', 'my_css' );
// Import global JS files
function my_js() {
wp_enqueue_script(
'main', get_template_directory_uri() . '/static/js/main.js'
);
}
add_action( 'wp_enqueue_scripts', 'my_js' );
// Add Favicon
function add_favicon() {
echo '<link rel="shortcut icon" type="image/png" href="'.get_template_directory_uri().'/static/images/icons/favicon.png" />';
}
add_action('wp_head', 'add_favicon');
// Enable highlighted image
add_theme_support('post-thumbnails');
// Enable dynamic menus
function register_my_menus(){
register_nav_menus(
array(
'menu-name' => __('Displayed menu name'),
)
);
}
add_action('init', 'register_my_menus');
// Max post excerpt size
function wpdocs_custom_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 12 );
// Pagination
function pagination_posts($post_type_query){
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', get_pagenum_link( 999999999 ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $post_type_query->max_num_pages,
'prev_next' => true,
'prev_text' => "Prev",
'next_text' => "Next",
'before_page_number' => '',
'after_page_number' => '',
'show_all' => false,
'mid_size' => 3,
'end_size' => 1
) );
}
// Returns custom post date
function get_custom_post_date(){
// If post was published today
if ( get_the_time( 'Yd' ) === current_time( 'Yd' ) ) {
return get_the_date('\T\o\d\a\y \a\t H:i', strtotime($recent['post_date']));
} else {
return get_the_date('d/m/Y \a\t H:i', strtotime($recent['post_date']));
}
}
// If updated, returns custom post update date
function get_custom_post_modified_time(){
if (get_custom_post_date() != get_the_time()){
if (get_custom_post_date('Yd') === current_time( 'Yd' )) {
if (get_the_time('Yd') === current_time( 'Yd' )) {
$data_atualizado = get_the_modified_date('\a\t H:i', strtotime($recent['post_date']));
} else {
$data_atualizado = get_the_modified_date('\t\o\d\a\y \a\t H:i', strtotime($recent['post_date']));
}
} else {
$data_atualizado = get_the_modified_date('d/m/Y \a\t H:i', strtotime($recent['post_date']));
}
return "• Updated " . $data_atualizado;
}
}
// Custom Post types
// require get_template_directory() . '/custom_post_types/post-type-name.php';
// Custom Fields
// require get_template_directory() . '/custom_fields/field-name.php';
// Custom Taxonomies
// require get_template_directory() . '/custom_taxonomys/taxonomie-name.php';