1) || ( isset($multipage) && $multipage && is_singular() ) ) {
if($args) {
$page = isset($args['paged']) ? $args['paged'] : $page;
$numpages = isset($args['numpages']) ? $args['numpages'] : $numpages;
}
echo '
';
}else if( ($max_page = $wp_query->max_num_pages) > 1 ){
echo ' ';
}
}
function wpcom_link_page( $i, $args ) {
if(isset($args['url']) && $args['url']){
if ( (isset($args['paged_type']) && $args['paged_type'] === 'query') || '' == get_option( 'permalink_structure' ) ) {
$url = add_query_arg( isset($args['paged_arg']) && $args['paged_arg'] ? $args['paged_arg'] : 'page', $i, $args['url'] );
} else {
$url = trailingslashit( $args['url'] ) . user_trailingslashit( $i, 'single_paged' );
}
$url = '';
}else{
$url = _wp_link_page($i);
}
return wp_kses($url, wpmx_allowed_html());
}
function wpcom_pagination_form($name = 'paged', $search = false){
$search = $search && is_search() ? '' : '';
return '';
}
add_filter('previous_posts_link_attributes', 'wpcom_prev_posts_link_attr');
function wpcom_prev_posts_link_attr($attr){
return $attr.' class="prev"';
}
add_filter('next_posts_link_attributes', 'wpcom_next_posts_link_attr');
function wpcom_next_posts_link_attr($attr){
return $attr.' class="next"';
}
}
if(!function_exists('wpcom_empty_icon')){
function wpcom_empty_icon($type='post'){
return '
';
}
}
if(!function_exists('wpcom_pre_handle_404')){
add_action('pre_handle_404', 'wpmx_pre_handle_404');
function wpmx_pre_handle_404($res){
global $wp_query, $wp_version;
if ( $wp_query->posts && version_compare($wp_version, '5.5') >= 0) {
$content_found = true;
if ( is_singular() ) {
$post = isset( $wp_query->post ) ? $wp_query->post : null;
// Only set X-Pingback for single posts that allow pings.
if ( $post && pings_open( $post ) && ! headers_sent() ) {
header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) );
}
$paged = get_query_var( 'page' );
if ( $post && ! empty( $paged ) ) {
$shortcode_tags = array('wpcom_tags', 'wpcom-member');
preg_match_all( '@\[([^<>&/\[\]\x00-\x20=]++)@', $post->post_content, $matches );
$tagnames = array_intersect( $shortcode_tags, $matches[1] );
if ( empty($tagnames) ) {
$content_found = false;
}else if(in_array('wpcom_tags', $tagnames)){
preg_match( '/\[wpcom_tags[^\]]*\]/i', $post->post_content, $matches2 );
if(isset($matches2[0])){
$text = ltrim($matches2[0], '[wpcom_tags');
$text = rtrim($text, ']');
$atts = shortcode_parse_atts($text);
if(isset($atts['per_page']) && $atts['per_page']){ // 分页
$tax = isset($atts['taxonomy']) && $atts['taxonomy'] ? $atts['taxonomy'] : 'post_tag';
$max = wp_count_terms( $tax, array( 'hide_empty' => true ) );
$pages = ceil( $max / $atts['per_page'] );
if($pages<$paged) $content_found = false; // 页数超过
}else{ // 未分页,则一页全部显示
$content_found = false;
}
}
}
}
}
if ( $content_found ) $res = true;
}
return $res;
}
}