Skip to content

Instantly share code, notes, and snippets.

@EmranAhmed
Last active September 10, 2016 13:59
Show Gist options
  • Select an option

  • Save EmranAhmed/c1c92455b2753e272f3200ac8fcc9a22 to your computer and use it in GitHub Desktop.

Select an option

Save EmranAhmed/c1c92455b2753e272f3200ac8fcc9a22 to your computer and use it in GitHub Desktop.
<?php
// this will enable button
if ( ! function_exists( 'fashionstore_wp_page_paging' ) ) :
function fashionstore_wp_page_paging( $mce_buttons ) {
if ( get_post_type() == 'post' or get_post_type() == 'page' ) {
$pos = array_search( 'wp_more', $mce_buttons, TRUE );
if ( $pos !== FALSE ) {
$buttons = array_slice( $mce_buttons, 0, $pos + 1 );
$buttons[] = 'wp_page';
$mce_buttons = array_merge( $buttons, array_slice( $mce_buttons, $pos + 1 ) );
}
}
return apply_filters( 'fashionstore_mce_buttons', $mce_buttons );
}
add_filter( 'mce_buttons', 'fashionstore_wp_page_paging', 9999 );
endif;
?>
<?php
if ( ! function_exists( 'fashionstore_link_pages' ) ) :
function fashionstore_link_pages( $args = array() ) {
$defaults = array(
'before' => '<div class="pagination-wrap clearfix">',
'after' => '</div>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'number',
'nextpagelink' => esc_html__( 'Next page', 'fashionstore' ),
'previouspagelink' => esc_html__( 'Previous page', 'fashionstore' ),
'pagelink' => '%',
'echo' => 1
);
$args = apply_filters( 'wp_link_pages_args', wp_parse_args( $args, $defaults ) );
global $page, $numpages, $multipage, $more, $pagenow;
$output = '';
if ( $multipage ) {
if ( 'number' == $args[ 'next_or_number' ] ) {
$output .= $args[ 'before' ] . '<ul class="pagination">';
$laquo = $page == 1 ? 'class="disabled"' : '';
$output .= '<li ' . $laquo . '>' . _wp_link_page( $page - 1 ) . ' <i class="zmdi zmdi-chevron-left"></i></a></li>';
for (
$i = 1;
$i < ( $numpages + 1 );
$i = $i + 1
) {
$j = str_replace( '%', $i, $args[ 'pagelink' ] );
if ( ( $i != $page ) || ( ( ! $more ) && ( $page == 1 ) ) ) {
$output .= '<li>';
$output .= _wp_link_page( $i );
} else {
$output .= '<li class="active">';
$output .= _wp_link_page( $i );
}
$output .= $args[ 'link_before' ] . $j . $args[ 'link_after' ];
$output .= '</a></li>';
}
$raquo = $page == $numpages ? 'class="disabled"' : '';
$output .= '<li ' . $raquo . '>' . _wp_link_page( $page + 1 ) . ' <i class="zmdi zmdi-chevron-right"></i> </a></li>';
$output .= '</ul>' . $args[ 'after' ];
} else {
if ( $more ) {
$output .= $args[ 'before' ] . '<ul class="pager">';
$i = $page - 1;
if ( $i && $more ) {
$output .= '<li class="previous">' . _wp_link_page( $i );
$output .= $args[ 'link_before' ] . $args[ 'previouspagelink' ] . $args[ 'link_after' ] . '</li>';
}
$i = $page + 1;
if ( $i <= $numpages && $more ) {
$output .= '<li class="next">' . _wp_link_page( $i );
$output .= $args[ 'link_before' ] . $args[ 'nextpagelink' ] . $args[ 'link_after' ] . '</a></li>';
}
$output .= '</ul>' . $args[ 'after' ];
}
}
}
if ( $args[ 'echo' ] ) {
echo $output;
} else {
return $output;
}
}
endif;
?>
<div class="entry-content">
<?php
the_content( '<span class="btn btn-default btn-primary readmore">' . esc_html__( 'Read More', 'fashionstore' ) . '</span>' );
fashionstore_link_pages();
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment