bluecafe (February 6th, 2012), dbatista (March 21st, 2012), dikiyforester (February 5th, 2012), rubencio (February 5th, 2012)
// slimmed down non-plugin version of WP-PageNavi (2.50) by Lester 'GaMerZ' Chan http://lesterchan.net -- Vienna "special mod"
function appthemes_pagination_special($before = '', $after = '') {
global $wpdb, $wp_query;
if (!is_single()) :
$pagenavi_options = array(
'pages_text' => __('Page %CURRENT_PAGE% of %TOTAL_PAGES%','appthemes'),
'current_text' => '%PAGE_NUMBER%',
'page_text' => '%PAGE_NUMBER%',
'first_text' => __('‹‹ First','appthemes'),
'last_text' => __('Last ››','appthemes'),
'next_text' => __('View More Ads ››','appthemes'),
'prev_text' => __('‹‹ View Previous Ads','appthemes'),
'dotright_text' => '',
'dotleft_text' => '',
'style' => 1,
'num_pages' => 15,
'always_show' => 0,
'num_larger_page_numbers' => 3,
'larger_page_numbers_multiple' => 10,
);
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if(empty($paged) || $paged == 0) $paged = 1;
$pages_to_show = intval($pagenavi_options['num_pages']);
$larger_page_to_show = intval($pagenavi_options['num_larger_page_numbers']);
$larger_page_multiple = intval($pagenavi_options['larger_page_numbers_multiple']);
$pages_to_show_minus_1 = $pages_to_show - 1;
$half_page_start = floor($pages_to_show_minus_1/2);
$half_page_end = ceil($pages_to_show_minus_1/2);
$start_page = $paged - $half_page_start;
if($start_page <= 0) $start_page = 1;
$end_page = $paged + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_1) $end_page = $start_page + $pages_to_show_minus_1;
if($end_page > $max_page) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if($start_page <= 0) $start_page = 1;
$larger_per_page = $larger_page_to_show*$larger_page_multiple;
$larger_start_page_start = (appthemes_round($start_page, 10) + $larger_page_multiple) - $larger_per_page;
$larger_start_page_end = appthemes_round($start_page, 10) + $larger_page_multiple;
$larger_end_page_start = appthemes_round($end_page, 10) + $larger_page_multiple;
$larger_end_page_end = appthemes_round($end_page, 10) + ($larger_per_page);
if($larger_start_page_end - $larger_page_multiple == $start_page) {
$larger_start_page_start = $larger_start_page_start - $larger_page_multiple;
$larger_start_page_end = $larger_start_page_end - $larger_page_multiple;
}
if($larger_start_page_start <= 0) $larger_start_page_start = $larger_page_multiple;
if($larger_start_page_end > $max_page) $larger_start_page_end = $max_page;
if($larger_end_page_end > $max_page) $larger_end_page_end = $max_page;
if($max_page > 1 || intval($pagenavi_options['always_show']) == 1) :
$pages_text = str_replace("%CURRENT_PAGE%", number_format_i18n($paged), $pagenavi_options['pages_text']);
$pages_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pages_text);
echo $before.'<div class="paging">'."\n";
if(!empty($pages_text)) echo '<div class="pages">';
if ($start_page >= 2 && $pages_to_show < $max_page) :
$first_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['first_text']);
echo '<a href="'.esc_url(get_pagenum_link()).'" class="first" title="'.$first_page_text.'">'.$first_page_text.'</a>';
if(!empty($pagenavi_options['dotleft_text']))
echo '<span class="extend">'.$pagenavi_options['dotleft_text'].'</span>';
endif;
if($larger_page_to_show > 0 && $larger_start_page_start > 0 && $larger_start_page_end <= $max_page) :
for($i = $larger_start_page_start; $i < $larger_start_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['']);
//echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
endif;
echo '<span class="prevPage">';
// give us the previous post link
previous_posts_link($pagenavi_options['prev_text']);
echo '</span>';
for($i = $start_page; $i <= $end_page; $i++) :
if($i == $paged) {
$current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['']);
//echo '<span class="current">'.$current_page_text.'</span>';
} else {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['']);
if ( 'ad_listing' == $wp_query->query['post_type'] && is_tax( 'ad_cat' ) ) { ?>
<form method="post" action="<?php echo esc_url(get_pagenum_link( $i ) ); ?>" name="pagination<?php echo esc_attr( $i ); ?>">
<?php foreach ( $_POST as $key => $value ) :
if ( !is_array( $value ) ) : ?>
<input type="hidden" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" />
<?php else :
foreach ( $value as $v ) : ?>
<input type="hidden" name="<?php echo esc_attr( $key ); ?>[]" id="<?php echo esc_attr( $key ); ?>[]" value="<?php echo esc_attr( $v ); ?>" />
<?php endforeach;
endif; ?>
<?php endforeach; ?>
<a href="javascript: void(0);" onclick="document.pagination<?php echo esc_attr( $i ); ?>.submit();"><?php echo esc_html( $page_text ); ?></a>
</form>
<?php } else {
//echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
}
endfor;
echo '<span class="nextPage">';
// give us the next post link
next_posts_link($pagenavi_options['next_text'], $max_page);
echo '</span>';
if($larger_page_to_show > 0 && $larger_end_page_start < $max_page) :
for($i = $larger_end_page_start; $i <= $larger_end_page_end; $i+=$larger_page_multiple) {
$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $pagenavi_options['page_text']);
//echo '<a href="'.esc_url(get_pagenum_link($i)).'" class="page" title="'.$page_text.'">'.$page_text.'</a>';
}
endif;
if ($end_page < $max_page) :
if(!empty($pagenavi_options['dotright_text']))
echo '<span class="extend">'.$pagenavi_options['dotright_text'].'</span>';
$last_page_text = str_replace("%TOTAL_PAGES%", number_format_i18n($max_page), $pagenavi_options['last_text']);
echo '<a href="'.esc_url(get_pagenum_link($max_page)).'" class="last" title="'.$last_page_text.'">'.$last_page_text.'</a>';
endif;
echo '</div><div class="clr"></div></div>'.$after."\n";
endif;
endif;
}
bluecafe (February 6th, 2012), dbatista (March 21st, 2012), dikiyforester (February 5th, 2012), rubencio (February 5th, 2012)
arthemes.org - AppThemes plugins, tutorials, modifications and services |
There are currently 1 users browsing this thread. (0 members and 1 guests)