This repository has been archived by the owner on Jul 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
285 lines (225 loc) · 9.11 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
<?php
/**
* Theme Functions
*
* @package WordPress
* @subpackage octopress-classic
* @since 1.0
*/
if (function_exists('register_sidebar')) {
register_sidebar(
array(
'name' => __('Sidebar', 'octopress-classic'),
'id' => 'sidebar-1',
'before_widget' => '',
'after_widget' => '</section>',
'before_title' => '<section><h1>',
'after_title' => '</h1>',
)
);
}
function register_my_menu()
{
register_nav_menu('primary', __('Primary Menu', 'octopress-classic'));
}
add_action('after_setup_theme', 'register_my_menu');
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
// soil
//add_theme_support('soil-relative-urls');
//add_theme_support('soil-nice-search');
add_filter( 'show_recent_comments_widget_style', '__return_false', 99 );
// comments field
function my_update_comment_fields( $fields ) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$label = $req ? '*' : ' ' . __( '(optional)', 'octopress-classic' );
$aria_req = $req ? "aria-required='true'" : '';
$fields['author'] =
'<p class="comment-form-author">
<label for="author">' . __( "Name", "octopress-classic" ) . $label . '</label>
<input id="author" name="author" type="text" placeholder="' . esc_attr__( " Chuck Norris*", "octopress-classic" ) . '" value="' . esc_attr( $commenter['comment_author'] ) .
'" size="30" ' . $aria_req . ' />
</p>';
$fields['email'] =
'<p class="comment-form-email">
<label for="email">' . __( "Email", "octopress-classic" ) . $label . '</label>
<input id="email" name="email" type="email" placeholder="' . esc_attr__( " email@chucknorris.com*", "octopress-classic" ) . '" value="' . esc_attr( $commenter['comment_author_email'] ) .
'" size="30" ' . $aria_req . ' />
</p>';
$fields['url'] =
'<p class="comment-form-url">
<label for="url">' . __( "Website", "octopress-classic" ) . '</label>
<input id="url" name="url" type="url" placeholder="' . esc_attr__( " http://chucknorris.com", "octopress-classic" ) . '" value="' . esc_attr( $commenter['comment_author_url'] ) .
'" size="30" />
</p>';
return $fields;
}
add_filter( 'comment_form_default_fields', 'my_update_comment_fields' );
function my_update_comment_field( $comment_field ) {
$comment_field =
'<p class="comment-form-comment">
<label for="comment">' . __( "Comment", "octopress-classic" ) . '</label>
<textarea required id="comment" name="comment" placeholder="' . esc_attr__( " Enter comment here...*", "octopress-classic" ) . '" cols="45" rows="8" aria-required="true"></textarea>
</p>';
return $comment_field;
}
add_filter( 'comment_form_field_comment', 'my_update_comment_field' );
class comment_walker extends Walker_Comment {
var $tree_type = 'comment';
var $db_fields = array( 'parent' => 'comment_parent', 'id' => 'comment_ID' );
// constructor – wrapper for the comments list
function __construct() { ?>
<section class="comments-list">
<?php }
// start_lvl – wrapper for child comments list
function start_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 2; ?>
<section class="child-comments comments-list">
<?php }
// end_lvl – closing wrapper for child comments list
function end_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 2; ?>
</section>
<?php }
// start_el – HTML for comment template
function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
$parent_class = ( empty( $args['has_children'] ) ? '' : 'parent' );
if ( 'article' == $args['style'] ) {
$tag = 'article';
$add_below = 'comment';
} else {
$tag = 'article';
$add_below = 'comment';
} ?>
<article <?php comment_class(empty( $args['has_children'] ) ? '' :'parent') ?> id="comment-<?php comment_ID() ?>" itemprop="comment" itemscope itemtype="http://schema.org/Comment">
<figure class="gravatar"><?php echo get_avatar( $comment, 65, '[default gravatar URL]', 'Author’s gravatar' ); ?></figure>
<div class="comment-meta post-meta" role="complementary">
<h2 class="comment-author">
<a class="comment-author-link" href="<?php comment_author_url(); ?>" itemprop="author"><?php comment_author(); ?></a>
</h2>
<time class="comment-meta-item" datetime="<?php comment_date('Y-m-d') ?>T<?php comment_time('H:iP') ?>" itemprop="datePublished"><?php comment_date('jS F Y') ?>, <a href="#comment-<?php comment_ID() ?>" itemprop="url"><?php comment_time() ?></a></time>
<?php edit_comment_link('<p class="comment-meta-item">Edit this comment</p>','',''); ?>
<?php if ($comment->comment_approved == '0') : ?>
<p class="comment-meta-item">Your comment is awaiting moderation.</p>
<?php endif; ?>
</div>
<div class="comment-content post-content" itemprop="text">
<?php comment_text() ?>
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php }
// end_el – closing HTML for comment template
function end_el(&$output, $comment, $depth = 0, $args = array() ) { ?>
</article>
<?php }
// destructor – closing wrapper for the comments list
function __destruct() { ?>
</section>
<?php }
}
/* Register Features */
add_theme_support('title-tag'); // Let WP handle the title tag.
add_theme_support('post-formats', array('aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio'));
add_theme_support('automatic-feed-links');
add_theme_support('soil-clean-up'); // Roots Soil Plugin
/* Add Actions */
add_action('widgets_init', function () {
unregister_widget('WP_Widget_Search');
}, 1);
add_action('admin_init', function () {
add_editor_style('css/editor-style.css');
});
add_action('after_setup_theme', function () {
add_theme_support('title-tag');
});
add_action('wp_enqueue_scripts', function () {
if (is_singular() && comments_open() && absint(get_option('thread_comments')) === 1) {
wp_enqueue_script('comment-reply', 'wp-includes/js/comment-reply', array(), false, true);
}
});
add_action('wp_head', function () {
if (defined('OCTOPRESS_STYLES') && is_string(OCTOPRESS_STYLES)) {
echo OCTOPRESS_STYLES; // @codingStandardsIgnoreLine
}
});
/**
* Show search value.
*
* @author Arnab Wahid <arnabwahid@gmail.com>
* @since 1.0.0
*/
function octopress_s()
{
return isset($_REQUEST['s']) ? esc_html($_REQUEST['s']) : ''; // @codingStandardsIgnoreLine: REQUEST access okay here.
}
/**
* Octopress Pagination in Pages.
*
* @author Arnab Wahid <arnabwahid@gmail.com>
* @since 1.0.0
*/
function octopress_pagination()
{
?>
<?php if (!is_single()): ?>
<div class="pagination">
<?php next_posts_link('← Older');?>
<a href="<?php echo get_page_link(get_page_by_path('archives')); ?>"><?php esc_html_e('Blog Archives', 'octopress-classic');?></a>
<?php previous_posts_link('Newer →');?>
</div>
<?php endif;?>
<?php
}
/**
* The avatar.
*
* @author Arnab Wahid <arnabwahid@gmail.com>
* @since 1.0
*/
function octopress_avatar()
{
if (defined('OCTOPRESS_AVATAR') && OCTOPRESS_AVATAR) {
echo get_avatar(get_option('admin_email'), 96);
}
}
/**
* Where to go it archive page requests.
*
* @author Arnab Wahid <arnabwahid@gmail.com>
* @since 1.0
*/
function octopress_the_archive_link()
{
global $wpdb;
$years = $wpdb->get_results("SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC");
$year = current($years);
echo esc_url(home_url($year->year));
}
add_filter('next_posts_link_attributes', function () {
return 'class="prev"';
});
add_filter('previous_posts_link_attributes', function () {
return 'class="next"';
});
/* Theme Check fix */
if ( ! isset( $content_width ) ) $content_width = 900;
/**
* In case Linked List Plugin is disabled.
*
* @author Previous Author
* @since 1.0
*
* @return boolean false.
*/
function is_linked_list()
{
return false;
}
/* hide password protected posts */