TF1
thArr as $value) { switch ($value) { case ‘qq’: $opname = ‘QQ’; $fa = ‘qq’; break; case ‘weixin’: $opname = ‘微信’; $fa = ‘weixin’; break; case ‘mpweixin’: $opname = ‘公众号’; $fa = ‘weixin’; break; case ‘weibo’: $opname = ‘微博’; $fa = ‘weibo’; break; } if (_cao(‘is_oauth_’ . $value)) { if (_is_bind_openid($value)) { echo ‘[LT]a href=”javascript:%20void(0);” title=”‘ . $opname . ‘登录” class=”btn unset-bind” data-id=”‘ . $value . ‘”>[LT]i class=”fa fa-‘ . $fa . ‘”>[LT]/i> 解绑’ . $opname . ‘[LT]/a>’; } else { if ($value == ‘mpweixin’) { echo ‘[LT]a href=”‘%20.%20esc_url(home_url(‘/oauth/mpweixin’))%20.%20′” title=”‘ . $opname . ‘登录” class=”bind-mpweixin btn”>[LT]i class=”fa fa-‘ . $fa . ‘”>[LT]/i> 绑定’ . $opname . ‘[LT]/a>’; } else { echo ‘[LT]a href=”‘%20.%20esc_url(home_url(‘/oauth/’%20.%20$value))%20.%20′” title=”‘ . $opname . ‘登录” class=”btn”>[LT]i class=”fa fa-‘ . $fa . ‘”>[LT]/i> 绑定’ . $opname . ‘[LT]/a>’; } } } } } //获取用户头像地址 根据类型 function _get_user_avatar_url($type = ‘gravatar’, $user_id = 0) { if ($user_id > 0) { $uid = $user_id; } else { global $current_user; $uid = $current_user->ID; } $user = get_user_by(‘id’, $uid); $user_email = $user->data->user_email; $_user_avatar_type = (get_user_meta($uid, ‘user_avatar_type’, true)); if ($type == ‘user’) { $this_type = $_user_avatar_type; } else { $this_type = $type; } $_qqAvatarAPI = ‘https://q.qlogo.cn/qqapp/’; $_gravatarAPI = ‘https://cn.gravatar.com/avatar/’; // 判断头像类型 switch ($this_type) { case ‘gravatar’: $user_custom_avatar = get_user_meta($uid, ‘user_custom_avatar’, true); $avatar_url = ($user_custom_avatar) ? $user_custom_avatar : _the_theme_avatar(); break; case ‘qq’: $qqConfig = _cao(‘oauth_qq’); $avatar_url = $_qqAvatarAPI . $qqConfig[‘appid’] . ‘/’ . get_user_meta($uid, ‘open_qq_openid’, true) . ‘/100’; break; case ‘weibo’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘open_weibo_avatar’, true)); break; case ‘weixin’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘open_weixin_avatar’, true)); break; case ‘custom’: $avatar_url = set_url_scheme(get_user_meta($uid, ‘user_custom_avatar’, true)); default: $avatar_url = _the_theme_avatar(); } return $avatar_url; } /** * [_get_user_avatar 获取头像] * @Author Dadong2g * @DateTime 2019-05-28T12:17:13+0800 * @param string $user_email [description] * @param boolean $src [description] * @param integer $size [description] * @return [type] [description] */ function _get_user_avatar($user_email = ”, $src = false, $size = 50) { global $current_user; if (!$user_email) { $user_email = $current_user->user_email; } $avatar = get_avatar($user_email, $size); if ($src) { return $avatar; } else { return $avatar; } } // 文章是否下载资源文章 function _get_post_shop_status() { global $post; $post_ID = $post->ID; if (get_post_meta($post_ID, ‘cao_status’, true)) { return true; } return false; } //检测文章是否付费查看内容 function _get_post_shop_hide() { global $post; if (has_shortcode($post->post_content, ‘rihide’)) { return true; } return false; } //检测文章是否付费观看内容 function _get_post_video_status() { global $post; $post_ID = $post->ID; if (get_post_meta($post_ID, ‘cao_video’, true)) { return true; } return false; } //检测文章是否有设置视频 function _get_post_video_url() { global $post; $video_url = get_post_meta($post->ID, ‘video_url’, true); if ($video_url != ”) { return $video_url; } return false; } //文章资源价格 function _get_post_price() { global $post; $post_ID = $post->ID; $price = get_post_meta($post_ID, ‘cao_price’, true); $priceVal = ($price) ? $price : ‘0’; // $after = _cao(‘site_money_ua’); return $priceVal; } //文章分类信息 function _get_post_cat() { global $post; $post_ID = $post->ID; $category = get_the_category($post->ID); $cat_neme = $category[0]->cat_name; $cat_links = get_category_link($category[0]->cat_ID); return ‘[LT]a href=”‘%20.%20$cat_links%20.%20′”>’ . $cat_neme . ‘[LT]/a>’; } /** * post 文章阅读次数 */ function _post_views_record() { if (is_singular()) { global $post; $post_ID = $post->ID; if ($post_ID) { $post_views = (int) get_post_meta($post_ID, ‘views’, true); if (!update_post_meta($post_ID, ‘views’, ($post_views + 1))) { add_post_meta($post_ID, ‘views’, 1, true); } } } } function _get_post_views($before = ”, $after = ”) { global $post; $post_ID = $post->ID; $views = (int) get_post_meta($post_ID, ‘views’, true); if ($views >= 1000) { $views = round($views / 1000, 2) . ‘K’; } return $before . $views . $after; } /** * [_set_postthumbnail 自动设置文章缩略图] * @Author Dadong2g * @DateTime 2019-05-28T12:27:23+0800 */ if (_cao(‘set_postthumbnail’) && !function_exists(‘_set_postthumbnail’)): function _set_postthumbnail() { global $post; if (empty($post)) { return; } $already_has_thumb = has_post_thumbnail($post->ID); if (!$already_has_thumb) { $attached_image = get_children(“post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1″); if ($attached_image) { foreach ($attached_image as $attachment_id => $attachment) { set_post_thumbnail($post->ID, $attachment_id); } } } } // add_action(‘the_post’, ‘_set_postthumbnail’); add_action(‘save_post’, ‘_set_postthumbnail’); add_action(‘draft_to_publish’, ‘_set_postthumbnail’); add_action(‘new_to_publish’, ‘_set_postthumbnail’); add_action(‘pending_to_publish’, ‘_set_postthumbnail’); add_action(‘future_to_publish’, ‘_set_postthumbnail’); endif; /** * [_the_theme_thumb 默认缩略图] * @Author Dadong2g * @DateTime 2019-05-29T10:35:28+0800 * @return [type] [description] */ function _the_theme_thumb() { return _cao(‘post_default_thumb’)[‘url’] ? _cao(‘post_default_thumb’)[‘url’] : get_template_directory_uri() . ‘/assets/images/thumb/1.jpg’; $rand = mt_rand(1, 10); return get_template_directory_uri() . ‘/assets/images/thumb/’ . $rand . ‘.jpg’; } function _the_theme_thumb_full() { return get_template_directory_uri() . ‘/assets/images/thumb/full.jpg’; } function _the_loader_img() { return get_template_directory_uri() . ‘/assets/images/loader/preloader.gif’; } /** * [_get_post_thumbnail_url 输出缩略图地址] * @Author Dadong2g * @DateTime 2019-05-28T12:16:30+0800 * @param [type] $post [post] * @return [type] [description] */ if (!function_exists(‘_get_post_thumbnail_url’)): function _get_post_thumbnail_url($post = null, $size = null) { if ($post === null) { global $post; } if (is_numeric($post)) { $post = get_post($post); } if (empty($post)) { return _the_theme_thumb(); } //获取默认缩略图大小设置 $thumbnail_def_get_size = ($size) ? $size : _cao(‘thumbnail_def_get_size’, ‘full’) ; // cao_is_gif() if (has_post_thumbnail($post)) { //如果有特色缩略图,则输出缩略图地址 $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), $thumbnail_def_get_size); $post_thumbnail_src = $image[0]; } else { $post_thumbnail_src = ”; @$output = preg_match_all(‘/[LT]img.+src=[‘”]([^'”]+)[‘”].*>/i’, $post->post_content, $matches); if (!empty($matches[1][0])) { global $wpdb; $att = $wpdb->get_row($wpdb->prepare(“SELECT ID FROM $wpdb->posts WHERE guid LIKE ‘%s'”, $matches[1][0])); if ($att) { $post_thumbnail_src = $att->ID; } else { $post_thumbnail_src = $matches[1][0]; } } else { $post_thumbnail_src = _the_theme_thumb(); } } return $post_thumbnail_src; } endif; /** * [timthumb 图像裁切] * @Author Dadong2g * @DateTime 2019-05-28T12:16:48+0800 * @param [type] $src [description] * @param [type] $size [description] * @param [type] $set [description] * @return [type] [description] */ if (!function_exists(‘timthumb’)): function timthumb($src, $size = null, $set = null) { if (cao_is_gif()) { return $src; } $modular = _cao(‘thumbnail_handle’); if (is_numeric($src)) { if ($modular == ‘timthumb_mi’) { $src = image_downsize($src, ‘thumbnail’); } else { $src = image_downsize($src, ‘full’); } $src = $src[0]; } if ($set == ‘original’) { return $src; } if ($modular == ‘timthumb_php’ || empty($modular) || $set == ‘tim’) { return get_template_directory_uri() . ‘/timthumb.php?src=’ . $src . ‘&h=’ . $size[“h”] . ‘&w=’ . $size[‘w’] . ‘&zc=1&a=c&q=100&s=1’; } elseif ($modular == ‘other’) { $thumbnail_other = _cao(‘thumbnail_other’, ”); return $src . $thumbnail_other; } else { return $src; } } endif; /** * [_get_post_thumbnail 获取缩略图代码] * @Author Dadong2g * @DateTime 2019-05-28T12:16:54+0800 * @return [type] [description] */ if (!function_exists(‘_get_post_timthumb_src’)): function _get_post_timthumb_src() { $thum_px = _cao(‘thumbnail-px’); $img_w = ($thum_px) ? $thum_px[‘width’] : ‘300’; $img_h = ($thum_px) ? $thum_px[‘height’] : ‘200’; $src = timthumb(_get_post_thumbnail_url(), array(‘w’ => $img_w, ‘h’ => $img_h)); return $src; } endif; /** * [_str_cut description] * @Author Dadong2g * @DateTime 2019-05-28T12:15:45+0800 * @param [type] $str [description] * @param [type] $start [description] * @param [type] $width [description] * @param [type] $trimmarker [description] * @return [type] [description] */ function _str_cut($str, $start, $width, $trimmarker) { $output = preg_replace(‘/^(?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,’ . $start . ‘}((?:[x00-x7F]|[xC0-xFF][x80-xBF]+){0,’ . $width . ‘}).*/s’, ‘1’, $str); return $output . $trimmarker; } // 分享文字处理 function substr_ext($str, $start = 0, $length, $charset = ‘utf-8’, $suffix = ”) { if (function_exists(‘mb_substr’)) { return mb_substr($str, $start, $length, $charset) . $suffix; } if (function_exists(‘iconv_substr’)) { return iconv_substr($str, $start, $length, $charset) . $suffix; } $re[‘utf-8’] = ‘/[-]|[?-?][?-?]|[?-?][?-?]{2}|[?-?][?-?]{3}/’; $re[‘gb2312’] = ‘/[-]|[?-?][?-?]/’; $re[‘gbk’] = ‘/[-]|[?-?][@-?]/’; $re[‘big5’] = ‘/[-]|[?-?]([@-~]|?-?])/’; preg_match_all($re[$charset], $str, $match); $slice = join(”, array_slice($match[0], $start, $length)); return $slice . $suffix; } function mi_str_encode($string) { return $string; $len = strlen($string); $buf = ”; $i = 0; while ($i [LT] $len) { if (ord($string[$i]) [LT]= 127) { $buf .= $string[$i]; } elseif (ord($string[$i]) [LT] 192) { $buf .= ‘�’; } elseif (ord($string[$i]) [LT] 224) { $buf .= sprintf(‘&#%d;’, ord($string[$i + 0]) + ord($string[$i + 1])); $i = $i + 1; $i += 1; } elseif (ord($string[$i]) [LT] 240) { ord($string[$i + 2]); $buf .= sprintf(‘&#%d;’, ord($string[$i + 0]) + ord($string[$i + 1]) + ord($string[$i + 2])); $i = $i + 2; $i += 2; } else { ord($string[$i + 2]); ord($string[$i + 3]); $buf .= sprintf(‘&#%d;’, ord($string[$i + 0]) + ord($string[$i + 1]) + ord($string[$i + 2]) + ord($string[$i + 3])); $i = $i + 3; $i += 3; } $i = $i + 1; } return $buf; } function draw_txt_to($card, $pos, $str, $iswrite, $font_file) { $_str_h = $pos[‘top’]; $fontsize = $pos[‘fontsize’]; $width = $pos[‘width’]; $margin_lift = $pos[‘left’]; $hang_size = $pos[‘hang_size’]; $temp_string = ”; $tp = 0; $font_color = imagecolorallocate($card, $pos[‘color’][0], $pos[‘color’][1], $pos[‘color’][2]); $i = 0; $str = strip_tags(str_replace(‘ ‘, ”, $str)); while ($i [LT] mb_strlen($str)) { $box = imagettfbbox($fontsize, 0, $font_file, mi_str_encode($temp_string)); $_string_length = $box[2] – $box[0]; $temptext = mb_substr($str, $i, 1); $temp = imagettfbbox($fontsize, 0, $font_file, mi_str_encode($temptext)); if ($_string_length + $temp[2] – $temp[0] [LT] $width) { $temp_string .= mb_substr($str, $i, 1); if ($i == mb_strlen($str) – 1) { $_str_h = $_str_h + $hang_size; $_str_h += $hang_size; $tp = $tp + 1; if ($iswrite) { imagettftext($card, $fontsize, 0, $margin_lift, $_str_h, $font_color, $font_file, mi_str_encode($temp_string)); } } } else { $texts = mb_substr($str, $i, 1); $isfuhao = preg_match(‘/[\pP]/u’, $texts) ? true : false; if ($isfuhao) { $temp_string .= $texts; $f = mb_substr($str, $i + 1, 1); $fh = preg_match(‘/[\pP]/u’, $f) ? true : false; if ($fh) { $temp_string .= $f; $i = $i + 1; } } else { $i = $i+-1; } $tmp_str_len = mb_strlen($temp_string); $s = mb_substr($temp_string, $tmp_str_len – 1, 1); if (is_firstfuhao($s)) { $temp_string = rtrim($temp_string, $s); $i = $i+-1; } $_str_h = $_str_h + $hang_size; $_str_h += $hang_size; $tp = $tp + 1; if ($iswrite) { imagettftext($card, $fontsize, 0, $margin_lift, $_str_h, $font_color, $font_file, mi_str_encode($temp_string)); } $temp_string = ”; } $i = $i + 1; } return $tp * $hang_size; } function is_firstfuhao($str) { $fuhaos = array(‘0’ => ‘”‘, ‘1’ => ‘“’, ‘2’ => ”’, ‘3’ => ‘[LT]’, ‘4’ => ‘《’); return in_array($str, $fuhaos); } // 分享文字处理END function _excerpt_length($length) { return _cao(‘_site_excerpt_length’, ’42’); } add_filter(‘excerpt_length’, ‘_excerpt_length’); /** * [_get_excerpt 截取文章摘要] * @Author Dadong2g * @DateTime 2019-05-28T12:15:48+0800 * @param integer $limit [长度] * @param string $after [description] * @return [type] [description] */ function _get_excerpt($limit = 40, $after = ‘…’) { $excerpt = get_the_excerpt(); $limit = _cao(‘_site_excerpt_length’, ’42’); if (mb_strlen($excerpt) > $limit) { return _str_cut(strip_tags($excerpt), 0, $limit, $after); } else { return $excerpt; } } /** * [_get_category_tags 获取文章标签 10条] * @Author Dadong2g * @DateTime 2019-05-28T12:20:43+0800 * @param [type] $args [description] * @return [type] [description] */ function _get_category_tags($args) { if (empty($args[‘categories’])) { return false; } global $wpdb; $tags_num = (int)_cao(‘filter_item_tags_num’,10); $tags = $wpdb->get_results (” SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name FROM $wpdb->posts as p1 LEFT JOIN $wpdb->term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN $wpdb->term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN $wpdb->terms as terms1 ON t1.term_id = terms1.term_id, $wpdb->posts as p2 LEFT JOIN $wpdb->term_relationships as r2 ON p2.ID = r2.object_ID LEFT JOIN $wpdb->term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id LEFT JOIN $wpdb->terms as terms2 ON t2.term_id = terms2.term_id WHERE t1.taxonomy = ‘category’ AND p1.post_status = ‘publish’ AND terms1.term_id IN (” . $args[‘categories’] . “) AND t2.taxonomy = ‘post_tag’ AND p2.post_status = ‘publish’ AND p1.ID = p2.ID ORDER by tag_name LIMIT {$tags_num} “); $count = 0; if (!empty($tags)) { foreach ($tags as $tag) { $mytag[$count] = get_term_by(‘id’, $tag->tag_id, ‘post_tag’); $count++; } } else { $mytag = null; } return $mytag; } /** * [_get_post_comments 文章评论] * @Author Dadong2g * @DateTime 2019-05-28T12:20:33+0800 * @param string $before [description] * @param string $after [description] * @return [type] [description] */ function _get_post_comments($before = ‘[LT]i class=”fa fa-comments-o”>[LT]/i> ‘, $after = ”) { return $before . get_comments_number(‘0’, ‘1’, ‘%’) . $after; } /** * [_get_post_time 文章时间] * @Author Dadong2g * @DateTime 2019-05-28T12:18:48+0800 * @return [type] [description] */ function _get_post_time() { if (_cao(‘post_is_timeago’, ‘1’)) { return sprintf( __( ‘%s前’,’rizhuti-v2′ ), human_time_diff( get_the_time( ‘U’ ), current_time( ‘timestamp’ ) ) ); } return get_the_date(‘Y-m-d’); } function cao_comment($comment, $args, $depth) { $GLOBALS[‘comment’] = $comment; if (‘pingback’ == $comment->comment_type || ‘trackback’ == $comment->comment_type): ?> [LT]li id=”comment-[LT]?php comment_ID();?>” [LT]?php comment_class();?>> [LT]div class=”comment-body”> [LT]?php esc_html_e(‘Pingback:’, ‘cao’);?> [LT]?php comment_author_link();?> [LT]?php edit_comment_link(esc_html__(‘编辑’, ‘cao’), ‘[LT]span class=”edit-link”>’, ‘[LT]/span>’);?> [LT]/div> [LT]?php else: ?> [LT]li id=”comment-[LT]?php comment_ID();?>” [LT]?php comment_class(empty($args[‘has_children’]) ? ” : ‘parent’);?>> [LT]article id=”div-comment-[LT]?php comment_ID();?>” class=”comment-wrapper u-clearfix” itemscope itemtype=”https://schema.org/Comment”> [LT]div class=”comment-author-avatar vcard”> [LT]?php echo get_avatar($comment->comment_author_email); ?> [LT]/div> [LT]div class=”comment-content”> [LT]div class=”comment-author-name vcard” itemprop=”author”> [LT]?php $CaoUser = new CaoUser($comment->user_id); if ($CaoUser->vip_status()) { $vip_name_class = ‘fn vip’; } else { $vip_name_class = ‘fn’; } printf(‘[LT]cite class=”%s”>[LT]i class=”fa fa-diamond”>[LT]/i> %s[LT]/cite>’, $vip_name_class, $CaoUser->vip_name() . ‘ ‘ . get_comment_author_link()); ?> [LT]/div> [LT]div class=”comment-metadata”> [LT]time datetime=”[LT]?php comment_time(‘c’);?>” itemprop=”datePublished”> [LT]?php printf(_x(‘%1$s at %2$s’, ‘1: date, 2: time’, ‘cao’), get_comment_date(), get_comment_time());?> [LT]/time> [LT]?php edit_comment_link(esc_html__(‘编辑’, ‘cao’), ‘ [LT]span class=”edit-link”>’, ‘[LT]/span>’); comment_reply_link(array_merge($args, array( ‘add_below’ => ‘div-comment’, ‘depth’ => $depth, ‘max_depth’ => $args[‘max_depth’], ‘before’ => ‘[LT]span class=”reply-link”>’, ‘after’ => ‘[LT]/span>’, )));?> [LT]/div> [LT]div class=”comment-body” itemprop=”comment”> [LT]?php comment_text();?> [LT]/div> [LT]?php if (‘0’ == $comment->comment_approved): ?> [LT]p class=”comment-awaiting-moderation”>[LT]?php esc_html_e(‘你的评论正在等待审核.’, ‘cao’);?>[LT]/p> [LT]?php endif;?> [LT]/div> [LT]/article> [LT]?php endif; } /** * [_paging 分页导航] * @Author Dadong2g * @DateTime 2019-05-29T11:35:44+0800 * @return [type] [description] */ if (!function_exists(‘_paging’)): function _paging() { global $wp_query; $total = $wp_query->max_num_pages; $big = 999999999; if ($total > 1) { if (!$current_page = get_query_var(‘paged’)) { $current_page = 1; } if (get_option(‘permalink_structure’)) { $format = ‘page/%#%/’; } else { $format = ‘&paged=%#%’; } echo ‘[LT]div class=”col-12″>[LT]div class=”numeric-pagination”>’; echo paginate_links(array( ‘base’ => str_replace($big, ‘%#%’, esc_url(get_pagenum_link($big))), ‘format’ => $format, ‘current’ => max(1, get_query_var(‘paged’)), ‘total’ => $total, ‘mid_size’ => 3, ‘type’ => ‘list’, ‘prev_text’ => ‘[LT]i class=”mdi mdi-chevron-left”>[LT]/i>’, ‘next_text’ => ‘[LT]i class=”mdi mdi-chevron-right”>[LT]/i>’, )); echo ‘[LT]/div>[LT]/div>’; } } endif; /** * [cao_the_pagenavi 分页自定义] * @Author Dadong2g * @DateTime 2019-06-06T09:58:21+0800 * @param [type] $total_count [总数] * @param integer $number_per_page [每页数量] * @param integer $paged [当前页数] * @param [type] $the_url [当前页面] * @return [type] [htm] */ function cao_the_pagenavi($total_count, $number_per_page = 15, $paged, $the_url) { $current_page = $paged; $base_url = add_query_arg($_GET, $the_url); $total_pages = ceil($total_count / $number_per_page); $first_page_url = $base_url . ‘&paged=1’; $last_page_url = $base_url . ‘&paged=’ . $total_pages; if ($current_page > 1 && $current_page [LT] $total_pages) { $prev_page = $current_page – 1; $prev_page_url = $base_url . ‘&paged=’ . $prev_page; $next_page = $current_page + 1; $next_page_url = $base_url . ‘&paged=’ . $next_page; } elseif ($current_page == 1) { $prev_page_url = ‘#’; $first_page_url = ‘#’; if ($total_pages > 1) { $next_page = $current_page + 1; $next_page_url = $base_url . ‘&paged=’ . $next_page; } else { $next_page_url = ‘#’; $class = ‘class=”disabled”‘; } } elseif ($current_page == $total_pages) { $prev_page = $current_page – 1; $prev_page_url = $base_url . ‘&paged=’ . $prev_page; $next_page_url = ‘#’; $last_page_url = ‘#’; } ?> [LT]div class=”cao-pagination pagination-area”> [LT]nav aria-label=”Page navigation”> [LT]ul class=”pagination cao-pagination”> [LT]!– [LT]li>[LT]span>共[LT]?php //echo $total_count;;?>条[LT]/span>[LT]/li> –> [LT]li> [LT]a href=”[LT]?php%20echo%20$first_page_url;%20?>” aria-label=”Previous”> [LT]span aria-hidden=”true”>«[LT]/span> [LT]/a> [LT]/li> [LT]li>[LT]a href=”[LT]?php%20echo%20$prev_page_url;%20?>”>上一页[LT]/a>[LT]/li> [LT]li>[LT]span>第[LT]?php echo $current_page; ?>页,共[LT]?php echo $total_pages; ?>页[LT]/span>[LT]/li> [LT]li>[LT]a href=”[LT]?php%20echo%20$next_page_url;%20?>”>下一页[LT]/a>[LT]/li> [LT]li> [LT]a href=”[LT]?php%20echo%20$last_page_url;%20?>” aria-label=”Next”> [LT]span aria-hidden=”true”>»[LT]/span> [LT]/a> [LT]/li> [LT]/ul> [LT]/nav> [LT]/div> [LT]?php } function cao_admin_pagenavi($total_count, $number_per_page = 20) { $current_page = isset($_GET[‘paged’]) ? $_GET[‘paged’] : 1; if (isset($_GET[‘paged’])) { unset($_GET[‘paged’]); } $base_url = add_query_arg($_GET, admin_url(‘admin.php’)); @$total_pages = ceil($total_count / $number_per_page); $first_page_url = $base_url . ‘&paged=1’; $last_page_url = $base_url . ‘&paged=’ . $total_pages; if ($current_page > 1 && $current_page [LT] $total_pages) { $prev_page = $current_page – 1; $prev_page_url = $base_url . ‘&paged=’ . $prev_page; $next_page = $current_page + 1; $next_page_url = $base_url . ‘&paged=’ . $next_page; } elseif ($current_page == 1) { $prev_page_url = ‘#’; $first_page_url = ‘#’; if ($total_pages > 1) { $next_page = $current_page + 1; $next_page_url = $base_url . ‘&paged=’ . $next_page; } else { $next_page_url = ‘#’; } } elseif ($current_page == $total_pages) { $prev_page = $current_page – 1; $prev_page_url = $base_url . ‘&paged=’ . $prev_page; $next_page_url = ‘#’; $last_page_url = ‘#’; } ?> [LT]div class=”tablenav”> [LT]div class=”tablenav-pages”> [LT]span class=”displaying-num “>每页 [LT]?php echo $number_per_page; ?> 共 [LT]?php echo $total_count; ?>[LT]/span> [LT]span class=”pagination-links”> [LT]a class=”first-page button [LT]?php if ($current_page == 1) { echo ‘disabled’; } ?>” title=”前往第一页” href=”[LT]?php%20echo%20$first_page_url;%20?>”>«[LT]/a> [LT]a class=”prev-page button [LT]?ph
本篇文章来源于微信公众号:
