コード例 #1
0
ファイル: theme_utils.php プロジェクト: boutitinizar/bati-men
 public static function display_pager($max_num_pages)
 {
     $pattern = '#(www\\.|https?:\\/\\/){1}[a-zA-Z0-9]{2,254}\\.[a-zA-Z0-9]{2,4}[a-zA-Z0-9.?&=_/]*#i';
     $big = 999999999;
     // need an unlikely integer
     $pager_links = paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $max_num_pages, 'prev_text' => __('<', 'socialchef'), 'next_text' => __('>', 'socialchef'), 'type' => 'array'));
     $count_links = count($pager_links);
     if ($count_links > 0) {
         $first_link = $pager_links[0];
         $last_link = $first_link;
         //var_dump($pager_links);
         preg_match_all($pattern, $first_link, $matches, PREG_PATTERN_ORDER);
         if (count($matches) > 0 && isset($matches[0][0])) {
             echo '<span><a href="' . esc_url($matches[0][0]) . '">' . __('&laquo;', 'socialchef') . '</a></span>';
         }
         for ($i = 0; $i < $count_links; $i++) {
             $pager_link = $pager_links[$i];
             if (!SocialChef_Theme_Utils::string_contains($pager_link, 'current')) {
                 echo '<span>' . $pager_link . '</span>';
             } else {
                 echo $pager_link;
             }
             $last_link = $pager_link;
         }
         preg_match_all($pattern, $last_link, $matches, PREG_PATTERN_ORDER);
         if (count($matches) > 0 && isset($matches[0][0])) {
             echo '<span><a href="' . esc_url($matches[0][0]) . '">' . __('&raquo;', 'socialchef') . '</a></span>';
         }
     }
 }