Skip to content

Instantly share code, notes, and snippets.

@onigetoc
Last active March 1, 2016 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onigetoc/40931fc5aafa827b159f to your computer and use it in GitHub Desktop.
Save onigetoc/40931fc5aafa827b159f to your computer and use it in GitHub Desktop.
Footer and pagination for Themekraft https://github.com/Themekraft/_tk
function _tk_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', '_tk' ),
'id' => 'sidebar-1',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', '_tk_widgets_init' );
/* GC PAGINATION */
//http://fellowtuts.com/wordpress/bootstrap-3-pagination-in-wordpress/
// Bootstrap pagination function
function wp_bs_pagination($pages = '', $range = 4){
$showitems = ($range * 2) + 1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo '<li class="disabled hidden-xs"><span><span aria-hidden="true">Page '.$paged.' of '.$pages.'</span></span></li>';
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."' aria-label='First'>&laquo;<span class='hidden-xs'> First</span></a></li>";
if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."' aria-label='Previous'>&lsaquo;<span class='hidden-xs'> Previous</span></a></li>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<li class=\"active\"><span>".$i." <span class=\"sr-only\">(current)</span></span>
</li>":"<li><a href='".get_pagenum_link($i)."'>".$i."</a></li>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<li><a href=\"".get_pagenum_link($paged + 1)."\" aria-label='Next'><span class='hidden-xs'>Next </span>&rsaquo;</a></li>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."' aria-label='Last'><span class='hidden-xs'>Last </span>&raquo;</a></li>";
echo "</ul>";
}
}
/* ADD FOOTER WIDGETS */
register_sidebar(array(
'id' => 'footer1',
'name' => __( 'Footer 1', 'bonestheme' ),
'description' => 'Right Footer widget position.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
register_sidebar(array(
'id' => 'footer2',
'name' => __( 'Footer 2', '_tk' ),
'description' => 'Right Footer widget position.',
'description' => 'Appears in the footer area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
register_sidebar(array(
'id' => 'footer3',
'name' => __( 'Footer 3', '_tk' ),
//'description' => __( 'The second (primary) sidebar.', '_tk' ),
'description' => 'Right Footer widget position.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
register_sidebar(array(
'id' => 'footer4',
'name' => __( 'Footer 4', '_tk' ),
'description' => 'Right Footer widget position.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment