代码提交

This commit is contained in:
yaoyuan2.chu
2021-03-14 01:30:38 +08:00
parent a29ff4b0b8
commit 055f77d499
11 changed files with 206 additions and 43 deletions
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* Pagination Functions
*
* @package cyywordpress
*/
if ( ! function_exists( 'cyywordpress_pagination' ) ) {
/**
* Add custom pagination class
*
* @link https://css-tricks.com/snippets/wordpress/add-class-to-links-generated-by-next_posts_link-and-previous_posts_link/
*/
function cyywordpress_pagination($args = [], $class = 'pagination') {
if ($GLOBALS['wp_query']->max_num_pages <= 1) return;
$args = wp_parse_args( $args, [
'mid_size' => 2,
'prev_next' => false,
'prev_text' => __('Older posts', 'cyywordpress'),
'next_text' => __('Newer posts', 'cyywordpress'),
'screen_reader_text' => __('Posts navigation', 'cyywordpress'),
]);
$links = paginate_links($args);
$next_link = get_previous_posts_link($args['next_text']);
$prev_link = get_next_posts_link($args['prev_text']);
$template = apply_filters( 'navigation_markup_template', '
<nav class="navigation %1$s" role="navigation">
<h2 class="screen-reader-text">%2$s</h2>
<div class="nav-links level">%3$s<div class="page-numbers-container level">%4$s</div>%5$s</div>
</nav>', $args, $class);
echo sprintf($template, $class, $args['screen_reader_text'], $next_link, $links, $prev_link);
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* cyywordpress Search Functions
*
* @package cyywordpress
*/
//<label class="screen-reader-text" for="s">' . __( 'Search for:' ) . '</label>
if ( ! function_exists( 'cyywordpress_search_form' ) ) {
function cyywordpress_search_form( $form ) {
$form = '
<form role="search" method="get" id="searchform" class="searchform" action="' . home_url( '/' ) . '" >
<h2 class="widget-title is-bold">搜索</h2>
<div class="control has-addons" style=" display: flex;">
<input class="input is-small" type="text" value="' . get_search_query() . '" name="s" id="s" />&nbsp;
<input class="button is-small" type="submit" id="searchsubmit" value="'. esc_attr__( 'Submit' ) .'" />
</div>
</form>';
return $form;
}
}
add_filter( 'get_search_form', 'cyywordpress_search_form', 100 );