* @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_featured_pages' ) ) : class TC_featured_pages { static $instance; function __construct () { self::$instance =& $this; add_action( '__before_main_container' , array( $this , 'tc_fp_block_display'), 10 ); add_action( '__after_fp' , array( $this , 'tc_maybe_display_dismiss_notice')); } /****************************** * FP NOTICE VIEW *******************************/ /** * hook : __after_fp * @since v3.4+ */ function tc_maybe_display_dismiss_notice() { if ( ! TC_placeholders::tc_is_fp_notice_on() ) return; $_customizer_lnk = apply_filters( 'tc_fp_notice_customizer_url', TC_utils::tc_get_customizer_url( array( 'control' => 'tc_show_featured_pages', 'section' => 'frontpage_sec') ) ); ?>
%1$s

', sprintf( __("Edit those featured pages %s, or %s (you'll be able to add yours later)." , "customizr"), sprintf( '%2$s', __( "Edit those featured pages", "customizr" ), __( "now", "customizr" ), $_customizer_lnk ), sprintf( '%2$s', __( "Remove the featured pages", "customizr" ), __( "remove them", "customizr" ) ) ) ); printf('%1$s x', __( 'dismiss notice', 'customizr') ); ?>
tc_show_featured_pages() ) return; $tc_show_featured_pages_img = $this -> tc_show_featured_pages_img(); //gets the featured pages array and sets the fp layout $fp_ids = apply_filters( 'tc_featured_pages_ids' , TC_init::$instance -> fp_ids); $fp_nb = count($fp_ids); $fp_per_row = apply_filters( 'tc_fp_per_line', 3 ); //defines the span class $span_array = array( 1 => 12, 2 => 6, 3 => 4, 4 => 3, 5 => 2, 6 => 2, 7 => 2 ); $span_value = 4; $span_value = ( $fp_per_row > 7) ? 1 : $span_value; $span_value = isset( $span_array[$fp_per_row] ) ? $span_array[$fp_per_row] : $span_value; //save $args for filter $args = array($fp_ids, $fp_nb, $fp_per_row, $span_value); ?>
%4$s
%5$s', ( 1 == $j ) ? sprintf('' : '' ); //set $j back to start value if reach $fp_per_row $j++; $j = ($j == ($fp_per_row + 1)) ? 1 : $j; } do_action ('__after_fp') ; ?> ' ) : ''; ?> tc_get_skin_color(); $fp_holder_img = apply_filters ( 'tc_fp_holder_img' , sprintf('Holder Thumbnail', ( '#E4E4E4' != $_skin_color ) ? '#EEE' : '#5A5A5A', $_skin_color ) ); $featured_page_id = 0; //if fps are not set if ( null == TC_utils::$inst->tc_opt( 'tc_featured_page_'.$fp_single_id ) || ! TC_utils::$inst->tc_opt( 'tc_featured_page_'.$fp_single_id ) ) { //admin link if user logged in $featured_page_link = ''; $customizr_link = ''; if ( ! TC___::$instance -> tc_is_customizing() && is_user_logged_in() && current_user_can('edit_theme_options') ) { $customizr_link = sprintf( '%3$s', TC_utils::tc_get_customizer_url( array( 'control' => 'tc_featured_text_'.$fp_single_id, 'section' => 'frontpage_sec') ), __( 'Customizer screen' , 'customizr' ), __( 'Edit now.' , 'customizr' ) ); $featured_page_link = apply_filters( 'tc_fp_link_url', TC_utils::tc_get_customizer_url( array( 'control' => 'tc_featured_page_'.$fp_single_id, 'section' => 'frontpage_sec') ) ); } //rendering $featured_page_id = null; $featured_page_title = apply_filters( 'tc_fp_title', __( 'Featured page' , 'customizr' ), $fp_single_id, $featured_page_id); $text = apply_filters( 'tc_fp_text', sprintf( '%1$s %2$s', __( 'Featured page description text : use the page excerpt or set your own custom text in the Customizr screen.' , 'customizr' ), $customizr_link ), $fp_single_id, $featured_page_id ); $fp_img = apply_filters ('fp_img_src' , $fp_holder_img, $fp_single_id , $featured_page_id ); } else { $featured_page_id = apply_filters( 'tc_fp_id', esc_attr( TC_utils::$inst->tc_opt( 'tc_featured_page_'.$fp_single_id) ), $fp_single_id ); $featured_page_link = apply_filters( 'tc_fp_link_url', get_permalink( $featured_page_id ), $fp_single_id ); $featured_page_title = apply_filters( 'tc_fp_title', get_the_title( $featured_page_id ), $fp_single_id, $featured_page_id ); $edit_enabled = false; //when are we displaying the edit link? //never display when customizing if ( ! TC___::$instance -> tc_is_customizing() ) { $edit_enabled = ( (is_user_logged_in()) && current_user_can('edit_pages') && is_page( $featured_page_id ) ) ? true : $edit_enabled; $edit_enabled = ( (is_user_logged_in()) && current_user_can('edit_post' , $featured_page_id ) && ! is_page( $featured_page_id ) ) ? true : $edit_enabled; } $edit_enabled = apply_filters( 'tc_edit_in_fp_title', $edit_enabled ); $featured_text = apply_filters( 'tc_fp_text', TC_utils::$inst->tc_opt( 'tc_featured_text_'.$fp_single_id ), $fp_single_id, $featured_page_id ); $featured_text = apply_filters( 'tc_fp_text_sanitize', strip_tags( html_entity_decode( $featured_text ) ), $fp_single_id, $featured_page_id ); //get the page/post object $page = get_post($featured_page_id); //set page excerpt as default text if no $featured_text $text = ( empty($featured_text) && !post_password_required($featured_page_id) ) ? strip_tags(apply_filters( 'the_content' , $page->post_excerpt )) : $featured_text ; $text = ( empty($text) && !post_password_required($featured_page_id) ) ? strip_tags(apply_filters( 'the_content' , $page->post_content )) : $text ; //limit text to 200 car $default_fp_text_length = apply_filters( 'tc_fp_text_length', 200, $fp_single_id, $featured_page_id ); $text = ( strlen($text) > $default_fp_text_length ) ? substr( $text , 0 , strpos( $text, ' ' , $default_fp_text_length) ). ' ...' : $text; //set the image : uses thumbnail if any then >> the first attached image then >> a holder script $fp_img_size = apply_filters( 'tc_fp_img_size' , 'tc-thumb', $fp_single_id, $featured_page_id ); //allow user to specify a custom image id $fp_custom_img_id = apply_filters( 'fp_img_id', null , $fp_single_id , $featured_page_id ); $fp_img = $this -> tc_get_fp_img( $fp_img_size, $featured_page_id, $fp_custom_img_id); $fp_img = $fp_img ? $fp_img : $fp_holder_img; $fp_img = apply_filters ('fp_img_src' , $fp_img , $fp_single_id , $featured_page_id ); }//end if //Let's render this ob_start(); ?>
%2$s%3$s
', ( $fp_img == $fp_holder_img ) ? 'tc-holder' : '', apply_filters('tc_fp_round_div' , sprintf('', $featured_page_link, $featured_page_title ) , $fp_single_id, $featured_page_id ), $fp_img ); }//end if image enabled check //title block $tc_fp_title_block = sprintf('<%1$s>%2$s %3$s', apply_filters( 'tc_fp_title_tag' , 'h2', $fp_single_id, $featured_page_id ), $featured_page_title, ( isset($edit_enabled) && $edit_enabled )? sprintf('%2$s', get_edit_post_link($featured_page_id), __( 'Edit' , 'customizr' ) ) : '' ); echo apply_filters( 'tc_fp_title_block' , $tc_fp_title_block , $featured_page_title , $fp_single_id, $featured_page_id ); //text block $tc_fp_text_block = sprintf('

%2$s

', $fp_single_id, $text ); echo apply_filters( 'tc_fp_text_block' , $tc_fp_text_block , $fp_single_id , $text, $featured_page_id); //button block $tc_fp_button_text = apply_filters( 'tc_fp_button_text' , esc_attr( TC_utils::$inst->tc_opt( 'tc_featured_page_button_text') ) , $fp_single_id ); if ( $tc_fp_button_text || TC___::$instance -> tc_is_customizing() ){ $tc_fp_button_class = apply_filters( 'tc_fp_button_class' , 'btn btn-primary fp-button', $fp_single_id ); $tc_fp_button_class = $tc_fp_button_text ? $tc_fp_button_class : $tc_fp_button_class . ' hidden'; $tc_fp_button_block = sprintf('%4$s', $tc_fp_button_class, $featured_page_link, $featured_page_title, $tc_fp_button_text ); echo apply_filters( 'tc_fp_button_block' , $tc_fp_button_block , $featured_page_link , $featured_page_title , $fp_single_id, $featured_page_id ); } ?> tc_get_thumbnail_model( $fp_img_size, $featured_page_id, $fp_custom_img_id ); //finally we define a default holder if no thumbnail found or page is protected if ( isset( $_fp_img_model["tc_thumb"]) && ! empty( $_fp_img_model["tc_thumb"] ) && ! post_password_required( $featured_page_id ) ) $fp_img = $_fp_img_model["tc_thumb"]; else $fp_img = false; return $fp_img; } function tc_show_featured_pages() { //gets display fp option $tc_show_featured_pages = esc_attr( TC_utils::$inst->tc_opt( 'tc_show_featured_pages' ) ); return apply_filters( 'tc_show_fp', 0 != $tc_show_featured_pages && tc__f('__is_home') ); } function tc_show_featured_pages_img() { //gets display img option return apply_filters( 'tc_show_featured_pages_img', esc_attr( TC_utils::$inst->tc_opt( 'tc_show_featured_pages_img' ) ) ); } }//end of class endif;