-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
218 lines (205 loc) · 6.19 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
<?php
function tema_enqueue() {
wp_enqueue_script(
'bootstrap',
get_template_directory_uri().'/js/bootstrap.min.js',
array('jquery')
);
// untuk mengaktifkan customizer
wp_enqueue_script(
get_template_directory_uri().'/js/customizer.js',
array('customize-preview'),
'20170407',
'true'
);
}
add_action('wp_footer', 'tema_enqueue');
function tema_setup_nav() {
register_nav_menu('primary', __('Navigation Menu', 'temaku'));
// tampilkan fitur foto pada post
add_theme_support('post-thumbnails');
set_post_thumbnail_size(604, 270, true);
}
add_action('after_setup_theme', 'tema_setup_nav');
function tema_widget_init() {
register_sidebar(array(
'name' => __('Area Widget Utama', 'temaku'),
'id' => 'kanan',
'description' => __('Tampil pada bagian kanan website', 'temaku'),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>'
));
// membuat header untuk custom widget
register_sidebar(array(
'name' => __('Area Widget Konten', 'temaku'),
'id' => 'konten',
'description' => __('Tampil pada konten website', 'temaku'),
'before_widget' => '<aside id="%1$s" class="%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>'
));
register_sidebar(array(
'name' => __('Area Widget Footer Kiri', 'temaku'),
'id' => 'footer1',
'description' => __('Tampil pada footer bagian kiri', 'temaku'),
'before_widget' => '<aside id="%1$s" class="%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>'
));
register_sidebar(array(
'name' => __('Area Widget Footer Tengah', 'temaku'),
'id' => 'footer2',
'description' => __('Tampil pada footer bagian tengah', 'temaku'),
'before_widget' => '<aside id="%1$s" class="%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>'
));
register_sidebar(array(
'name' => __('Area Widget Footer Kanan', 'temaku'),
'id' => 'footer3',
'description' => __('Tampil pada footer bagian kanan', 'temaku'),
'before_widget' => '<aside id="%1$s" class="%2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="widget-title"><span>',
'after_title' => '</span></h4>'
));
//---
}
add_action('widgets_init', 'tema_widget_init');
// aktifkan support html5 untuk modifikasi form pencarian
add_theme_support('html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption'
)
);
// tampilkan fitur foto pada post
function tema_image_post() {
if(has_post_thumbnail()) {
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-thumbnail">
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'temaku'); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width="100%" />
</a>
<?php
} else {
?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>">
<img src="<?php echo get_template_directory_uri(); ?>/images/default-image.png" alt="<?php the_title(); ?>" width="100%">
</a>
<?php
}
};
// tampilkan fitur foto pada halaman single
function tema_image_single() {
if(has_post_thumbnail() && is_single()) {
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-thumbnail">
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'temaku'); ?>
<img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width="100%">
</a><br><br>
<?php
}
};
// membuat pagination
function tema_pagination() {
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'format' => '?paged=%#%',
'prev_next' => true,
'prev_text' => '< Sebelumnya',
'next_text' => 'Selanjutnya >',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages
));
}
// modifikasi tampilan daftar komentar
function tema_list_komentar($comment, $args, $depth) {
$GLOBALS['comment'] = $comment;
switch ($comment->comment_type):
case 'pingback':
case 'trackback':
?>
<li class="media">
<p><?php _e('Pingback: ', 'temaku'); ?> <?php comment_author_link(); ?> <?php edit_comment_link(__('Edit', 'temaku'), '<span>', '</span>'); ?></p>
</li>
<?php
break;
default:
?>
<li class="media" id="comment-<?php comment_ID(); ?>">
<div class="media-left">
<?php
$avatar_size = 65;
echo get_avatar($comment, $avatar_size);
?>
</div>
<div class="media-body">
<div class="comment-header">
<?php
printf(
'%1$s %2$s ',
sprintf(
'<div class="author"><b>%s</b></div>',
get_comment_author_link()
),
sprintf(
'%2$s <a href="%1$s"><span class="time">%3$s</span></a>',
esc_url(
get_comment_link($comment->comment_ID)
),
get_comment_time(),
get_comment_date()
)
);
?>
</div>
<?php
edit_comment_link(__('Edit', 'temaku'), '<span>', '</span>');
if($comment->comment_approved == '0'):
?>
<em class="comment-awaiting">
<?php _e('Komentar anda menunggu disetujui.', 'temaku'); ?>
</em><br>
<?php
endif;
?>
<div class="comment_content">
<?php comment_text(); ?>
<div class="reply-link">
<span class="glyphicon glyphicon-share-alt"></span>
<?php
comment_reply_link(
array_merge(
$args,
array(
'reply-text' => __('Balas', 'temaku'),
'depth' => $depth,
'max_depth' => $args['max_depth']
)
)
);
?>
</div>
</div>
</div>
</li>
<?php
break;
endswitch;
}
// import file customizer.php
require get_template_directory().'/inc/customizer.php';
// import file widgets.php
require get_template_directory().'/inc/widgets.php';
?>