Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/pagination.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");


/*
 * Plugin Name	: WP-PageNavi
 * Plugin URI	: http://lesterchan.net/portfolio/programming/php/
 * Description	: Adds a more advanced paging navigation to your WordPress blog
 * Version		: 2.87
 * Author		: Lester 'GaMerZ' Chan
 * Author URI	: http://lesterchan.net
 * Note			: this functions is important do not remove from here
 *
*/
function mwp_pagenavi( $args = array() ) {
	if ( !is_array( $args ) ) {
		$argv = func_get_args();
		$args = array();
		foreach ( array( 'before', 'after', 'options' ) as $i => $key )
			$args[ $key ] = isset( $argv[ $i ]) ? $argv[ $i ] : "";
	}
	$args = wp_parse_args( $args, array(
		'before' => '',
		'after' => '',
		'options' => array(),
		'query' => $GLOBALS['wp_query'],
		'type' => 'posts',
		'echo' => true
	) );
	extract( $args, EXTR_SKIP );
	$options = array(
		'pages_text'    => __( 'Page %CURRENT_PAGE% of %TOTAL_PAGES%', MWP_TEXT_DOMAIN ),
		'current_text'  => '%PAGE_NUMBER%',
		'page_text'     => '%PAGE_NUMBER%',
		'first_text'    => __( '&laquo; First', MWP_TEXT_DOMAIN ),
		'last_text'     => __( 'Last &raquo;', MWP_TEXT_DOMAIN ),
		'prev_text'     => '&laquo;',
		'next_text'     => '&raquo;',
		'dotleft_text'  => '',
		'dotright_text' => '',
		'num_pages' => 5,
		'num_larger_page_numbers' => 3,
		'larger_page_numbers_multiple' => 10,
		'always_show' => false,
		'use_pagenavi_css' => false,
		'style' => 1,
	) ;
	$options = wp_parse_args( $options );
	$instance = new MWP_PageNavi_Call( $args );
	list( $posts_per_page, $paged, $total_pages ) = $instance->get_pagination_args();
	if ( 1 == $total_pages && !$options['always_show'] )
		return;
	$pages_to_show = absint( $options['num_pages'] );
	$larger_page_to_show = absint( $options['num_larger_page_numbers'] );
	$larger_page_multiple = absint( $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 > $total_pages ) {
		$start_page = $total_pages - $pages_to_show_minus_1;
		$end_page = $total_pages;
	}
	if ( $start_page < 1 )
		$start_page = 1;
	$out = '';
			if ( !empty( $options['pages_text'] ) ) {
				$pages_text = str_replace(
					array( "%CURRENT_PAGE%", "%TOTAL_PAGES%" ),
					array( number_format_i18n( $paged ), number_format_i18n( $total_pages ) ),
				$options['pages_text'] );
				$out .= "<span class='pages'>$pages_text</span>";
			}
			if ( $start_page >= 2 && $pages_to_show < $total_pages ) {
				$first_text = str_replace( '%TOTAL_PAGES%', number_format_i18n( $total_pages ), $options['first_text'] );
				$out .= $instance->get_single( 1, $first_text, array(
					'class' => 'first'
				), '%TOTAL_PAGES%' );
			}
			if ( $paged > 1 && !empty( $options['prev_text'] ) ) {
				$out .= $instance->get_single( $paged - 1, $options['prev_text'], array(
					'class' => 'previouspostslink',
					'rel'	=> 'prev'
				) );
			}
			if ( $start_page >= 2 && $pages_to_show < $total_pages ) {
				if ( !empty( $options['dotleft_text'] ) )
					$out .= "<span class='extend'>{$options['dotleft_text']}</span>";
			}
			$larger_pages_array = array();
			if ( $larger_page_multiple )
				for ( $i = $larger_page_multiple; $i <= $total_pages; $i+= $larger_page_multiple )
					$larger_pages_array[] = $i;

			$larger_page_start = 0;
			foreach ( $larger_pages_array as $larger_page ) {
				if ( $larger_page < ($start_page - $half_page_start) && $larger_page_start < $larger_page_to_show ) {
					$out .= $instance->get_single( $larger_page, $options['page_text'], array(
						'class' => 'smaller page',
					) );
					$larger_page_start++;
				}
			}
			if ( $larger_page_start )
				$out .= "<span class='extend'>{$options['dotleft_text']}</span>";
			$timeline = 'smaller';
			foreach ( range( $start_page, $end_page ) as $i ) {
				if ( $i == $paged && !empty( $options['current_text'] ) ) {
					$current_page_text = str_replace( '%PAGE_NUMBER%', number_format_i18n( $i ), $options['current_text'] );
					$out .= "<span class='current'>$current_page_text</span>";
					$timeline = 'larger';
				} else {
					$out .= $instance->get_single( $i, $options['page_text'], array(
						'class' => "page $timeline",
					) );
				}
			}
			$larger_page_end = 0;
			$larger_page_out = '';
			foreach ( $larger_pages_array as $larger_page ) {
				if ( $larger_page > ($end_page + $half_page_end) && $larger_page_end < $larger_page_to_show ) {
					$larger_page_out .= $instance->get_single( $larger_page, $options['page_text'], array(
						'class' => 'larger page',
					) );
					$larger_page_end++;
				}
			}
			if ( $larger_page_out ) {
				$out .= "<span class='extend'>{$options['dotright_text']}</span>";
			}
			$out .= $larger_page_out;
			if ( $end_page < $total_pages ) {
				if ( !empty( $options['dotright_text'] ) )
					$out .= "<span class='extend'>{$options['dotright_text']}</span>";
			}
			if ( $paged < $total_pages && !empty( $options['next_text'] ) ) {
				$out .= $instance->get_single( $paged + 1, $options['next_text'], array(
					'class' => 'nextpostslink',
					'rel'	=> 'next'
				) );
			}
			if ( $end_page < $total_pages ) {
				$out .= $instance->get_single( $total_pages, $options['last_text'], array(
					'class' => 'last',
				), '%TOTAL_PAGES%' );
			}
	$out = $before . "<div class='pagination'>\n$out\n</div>" . $after;
	$out = apply_filters( 'mwp_pagenavi', $out );
	if ( !$echo )
		return $out;
	echo $out;
}
class MWP_PageNavi_Call {
	protected $args;
	function __construct( $args ) {
		$this->args = $args;
	}
	function __get( $key ) {
		return $this->args[ $key ];
	}
	function get_pagination_args() {
		global $numpages;
		$query = $this->query;
		switch( $this->type ) {
		case 'multipart':
			$posts_per_page = 1;
			$paged = max( 1, absint( get_query_var( 'page' ) ) );
			$total_pages = max( 1, $numpages );
			break;
		case 'users':
			$posts_per_page = $query->query_vars['number'];
			$paged = max( 1, floor( $query->query_vars['offset'] / $posts_per_page ) + 1 );
			$total_pages = max( 1, ceil( $query->total_users / $posts_per_page ) );
			break;
		default:
			$posts_per_page = intval( $query->get( 'posts_per_page' ) );
			$paged = max( 1, absint( $query->get( 'paged' ) ) );
			$total_pages = max( 1, absint( $query->max_num_pages ) );
			break;
		}
		return array( $posts_per_page, $paged, $total_pages );
	}
	function get_single( $page, $raw_text, $attr, $format = '%PAGE_NUMBER%' ) {
		if ( empty( $raw_text ) )
			return '';
		$text = str_replace( $format, number_format_i18n( $page ), $raw_text );
		$attr['href'] = $this->get_url( $page );
		return html( 'a', $attr, $text );
	}
	function get_url( $page ) {
		return ( 'multipart' == $this->type ) ? get_multipage_link( $page ) : get_pagenum_link( $page );
	}
}
if ( !function_exists( 'get_multipage_link' ) ) :
function get_multipage_link( $page = 1 ) {
	global $post, $wp_rewrite;
	if ( 1 == $page ) {
		$url = get_permalink();
	} else {
		if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array( 'draft', 'pending') ) )
			$url = add_query_arg( 'page', $page, get_permalink() );
		elseif ( 'page' == get_option( 'show_on_front' ) && get_option('page_on_front') == $post->ID )
			$url = trailingslashit( get_permalink() ) . user_trailingslashit( $wp_rewrite->pagination_base . "/$page", 'single_paged' );
		else
			$url = trailingslashit( get_permalink() ) . user_trailingslashit( $page, 'single_paged' );
	}
	return $url;
}
endif;
if ( ! function_exists( 'html' ) ):
function html( $tag ) {
	static $SELF_CLOSING_TAGS = array( 'area', 'base', 'basefont', 'br', 'hr', 'input', 'img', 'link', 'meta' );
	$args = func_get_args();
	$tag = array_shift( $args );
	if ( is_array( $args[0] ) ) {
		$closing = $tag;
		$attributes = array_shift( $args );
		foreach ( $attributes as $key => $value ) {
			if ( false === $value )
				continue;
			if ( true === $value )
				$value = $key;
			$tag .= ' ' . $key . '="' . esc_attr( $value ) . '"';
		}
	} else {
		list( $closing ) = explode( ' ', $tag, 2 );
	}
	if ( in_array( $closing, $SELF_CLOSING_TAGS ) ) {
		return "<{$tag} />";
	}
	$content = implode( '', $args );
	return "<{$tag}>{$content}</{$closing}>";
}
endif;

/*
 * Source Plugin 	: WP-CommentNavi
 * Description 		: Adds a more advanced paging navigation for your comments
 * Author 			: Lester 'GaMerZ' Chan
 * Source 			: https://wordpress.org/plugins/wp-commentnavi/
 * Note 			: do not install plugin from wordpress.org im just use part of plugins 
*/
function mwp_commentnavi() {
	global $wp_query;
	$mwp_current_text = '%PAGE_NUMBER%';
	$mwp_page_text = '%PAGE_NUMBER%';
	$mwp_always_show = 0;
	$comments_per_page = intval(get_query_var('comments_per_page'));
	$paged = intval(get_query_var('cpage'));
	$numcomments = intval($wp_query->comment_count);
	$max_page = intval($wp_query->max_num_comment_pages);
	if(empty($paged) || $paged == 0) {
		$paged = 1;
	}
	$pages_to_show = intval(5);
	$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;
	}
	if($max_page > 1 || intval($mwp_always_show) == 1) {

		for($i = $start_page; $i  <= $end_page; $i++) {
			if($i == $paged) {
				$current_page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $mwp_current_text);
				echo '<span class="page-numbers current">'.$current_page_text.'</span>';
			} else {
				$page_text = str_replace("%PAGE_NUMBER%", number_format_i18n($i), $mwp_page_text);
				echo '<a href="'.esc_url(get_comments_pagenum_link($i)).'" class="page-numbers" title="'.$page_text.'">'.$page_text.'</a>';
			}
		}
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists