* @copyright Copyright (c) 2013-2015, Nicolas GUILLAUME * @link http://presscustomizr.com/customizr * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ if ( ! class_exists( 'TC_post_navigation' ) ) : class TC_post_navigation { static $instance; function __construct () { self::$instance =& $this; add_action ( '__after_loop' , array( $this , 'tc_post_nav' ), 20 ); } /*********************** * VISIBILITY SETUP ***********************/ /** * Set the post navigation visibility based on Customizer options * * returns an array which contains, @bool whether or not show the navigation , @array css classes of the navigation, @string the context * @package Customizr * @since Customizr 3.3.22 */ function tc_set_visibility_options(){ $_nav_classes = array('navigation'); $_context = $this -> tc_get_context(); $_post_nav_enabled = $this -> tc_is_post_navigation_enabled(); $_post_nav_context_enabled = $this -> tc_is_post_navigation_context_enabled( $_context ); $_is_customizing = TC___::$instance -> tc_is_customizing() ; if ( $_is_customizing ){ if ( ! $_post_nav_enabled ) array_push( $_nav_classes, 'hide-all-post-navigation' ); if ( ! $_post_nav_context_enabled ) array_push( $_nav_classes, 'hide-post-navigation' ); $_post_nav_enabled = true; }else $_post_nav_enabled = $_post_nav_enabled && $_post_nav_context_enabled; return array( apply_filters( 'tc_show_post_navigation', $_post_nav_enabled ), implode( ' ', apply_filters( 'tc_show_post_navigation_class' , $_nav_classes ) ), $_context ); } /** * The template part for displaying nav links * * @package Customizr * @since Customizr 3.0 */ function tc_post_nav() { list( $post_navigation_bool, $post_nav_class, $_context) = $this -> tc_set_visibility_options(); if( ! $post_navigation_bool ) return; $prev_arrow = is_rtl() ? '→' : '←' ; $next_arrow = is_rtl() ? '←' : '→' ; $html_id = 'nav-below'; global $wp_query; ob_start(); ?> '); ?> max_num_pages > 1 && in_array($_context, array('archive', 'home') ) ) : ?> tc_opt( "tc_show_post_navigation_{$_context}" ) ); } /* * @return bool */ function tc_is_post_navigation_enabled(){ return 1 == esc_attr( TC_utils::$inst -> tc_opt( 'tc_show_post_navigation' ) ) ; } }//end of class endif;