%2$s
%3$s' , '' ); ?>
must always check the local context inside the callback before appending new css //fired on hook : wp_enqueue_scripts //Set thumbnail specific design based on user options //Set top border style option add_filter( 'tc_user_options_style' , array( $this , 'czr_fn_write_header_inline_css') ); } /*************************** * HEADER HOOKS SETUP ****************************/ /** * Set all header hooks * wp callback * @return void * * @package Customizr * @since Customizr 3.2.6 */ function czr_fn_set_header_hooks() { //The WP favicon (introduced in WP 4.3) will be used in priority add_action ( 'wp_head' , array( $this , 'czr_fn_favicon_display' )); //html > header actions add_action ( '__before_main_wrapper' , 'get_header'); //boolean filter to control the header's rendering if ( ! apply_filters( 'tc_display_header', true ) ) return; add_action ( '__header' , array( $this , 'czr_fn_prepare_logo_title_display' ) , 10 ); add_action ( '__header' , array( $this , 'czr_fn_tagline_display' ) , 20, 1 ); add_action ( '__header' , array( $this , 'czr_fn_navbar_display' ) , 30 ); //New menu view (since 3.2.0) add_filter ( 'tc_navbar_display', array( $this , 'czr_fn_new_menu_view'), 10, 2); //body > header > navbar actions ordered by priority // GY : switch order for RTL sites if (is_rtl()) { add_action ( '__navbar' , array( $this , 'czr_fn_social_in_header' ) , 20, 2 ); add_action ( '__navbar' , array( $this , 'czr_fn_tagline_display' ) , 10, 1 ); } else { add_action ( '__navbar' , array( $this , 'czr_fn_social_in_header' ) , 10, 2 ); add_action ( '__navbar' , array( $this , 'czr_fn_tagline_display' ) , 20, 1 ); } //add a 100% wide container just after the sticky header to reset margin top if ( 1 == esc_attr( czr_fn_opt( 'tc_sticky_header' ) ) || czr_fn_is_customizing() ) add_action( '__after_header' , array( $this, 'czr_fn_reset_margin_top_after_sticky_header'), 0 ); } /** * Callback for wp * Set customizer user options * * @package Customizr * @since Customizr 3.2.0 */ function czr_fn_set_header_options() { //Set some body classes add_filter( 'body_class' , array( $this , 'czr_fn_add_body_classes') ); //Set header classes from options add_filter( 'tc_header_classes' , array( $this , 'czr_fn_set_header_classes') ); //Set logo layout with a customizer option (since 3.2.0) add_filter( 'tc_logo_class' , array( $this , 'czr_fn_set_logo_title_layout') ); } /*************************** * VIEWS ****************************/ /** * Render favicon from options * Since WP 4.3 : let WP do the job if user has set the WP site_icon setting. * * @package Customizr * @since Customizr 3.0 */ function czr_fn_favicon_display() { //is there a WP favicon set ? //if yes then let WP do the job if ( function_exists('has_site_icon') && has_site_icon() ) return; $_fav_option = esc_attr( czr_fn_opt( 'tc_fav_upload') ); if ( ! $_fav_option || is_null($_fav_option) ) return; $_fav_src = ''; //check if option is an attachement id or a path (for backward compatibility) if ( is_numeric($_fav_option) ) { $_attachement_id = $_fav_option; $_attachment_data = apply_filters( 'tc_fav_attachment_img' , wp_get_attachment_image_src( $_fav_option , 'full' ) ); $_fav_src = $_attachment_data[0]; } else { //old treatment $_saved_path = esc_url ( czr_fn_opt( 'tc_fav_upload') ); //rebuild the path : check if the full path is already saved in DB. If not, then rebuild it. $upload_dir = wp_upload_dir(); $_fav_src = ( false !== strpos( $_saved_path , '/wp-content/' ) ) ? $_saved_path : $upload_dir['baseurl'] . $_saved_path; } //makes ssl compliant url $_fav_src = apply_filters( 'tc_fav_src' , is_ssl() ? str_replace('http://', 'https://', $_fav_src) : $_fav_src ); if( null == $_fav_src || !$_fav_src ) return; $type = "image/x-icon"; if ( strpos( $_fav_src, '.png') ) $type = "image/png"; if ( strpos( $_fav_src, '.gif') ) $type = "image/gif"; echo apply_filters( 'tc_favicon_display', sprintf('' , $_fav_src, $type ) ); } /** * Prepare the logo / title view * * * @package Customizr * @since Customizr 3.2.3 */ function czr_fn_prepare_logo_title_display() { $logos_type = array( '_sticky_', '_'); $logos_img = array(); $accepted_formats = apply_filters( 'tc_logo_img_formats' , array('jpg', 'jpeg', 'png' ,'gif', 'svg', 'svgz' ) ); $logo_classes = array( 'brand', 'span3'); foreach ( $logos_type as $logo_type ){ // check if we have to print the sticky logo if ( '_sticky_' == $logo_type && ! $this -> czr_fn_use_sticky_logo() ) continue; //check if the logo is a path or is numeric //get src for both cases $_logo_src = ''; $_width = false; $_height = false; $_attachement_id = false; //for the standard logo use the wp custom logo feature if set, otherwise fall back on the customizr custom logo $_logo_option = '_' === $logo_type ? get_theme_mod( 'custom_logo', '' ) : ''; $_logo_option = $_logo_option ? $_logo_option : esc_attr( czr_fn_opt( "tc{$logo_type}logo_upload") ); //check if option is an attachement id or a path (for backward compatibility) if ( is_numeric($_logo_option) ) { $_attachement_id = $_logo_option; $_attachment_data = apply_filters( "tc{$logo_type}logo_attachment_img" , wp_get_attachment_image_src( $_logo_option , 'full' ) ); $_logo_src = $_attachment_data[0]; $_width = ( isset($_attachment_data[1]) && $_attachment_data[1] > 1 ) ? $_attachment_data[1] : $_width; $_height = ( isset($_attachment_data[2]) && $_attachment_data[2] > 1 ) ? $_attachment_data[2] : $_height; } else { //old treatment //rebuild the logo path : check if the full path is already saved in DB. If not, then rebuild it. $upload_dir = wp_upload_dir(); $_saved_path = esc_url ( czr_fn_opt( "tc{$logo_type}logo_upload") ); $_logo_src = ( false !== strpos( $_saved_path , '/wp-content/' ) ) ? $_saved_path : $upload_dir['baseurl'] . $_saved_path; } //hook + makes ssl compliant $_logo_src = apply_filters( "tc{$logo_type}logo_src" , is_ssl() ? str_replace('http://', 'https://', $_logo_src) : $_logo_src ) ; $logo_resize = ( $logo_type == '_' ) ? esc_attr( czr_fn_opt( 'tc_logo_resize') ) : ''; $filetype = czr_fn_check_filetype($_logo_src); if( ! empty($_logo_src) && in_array( $filetype['ext'], $accepted_formats ) ) { $_args = array( 'logo_src' => $_logo_src, 'logo_resize' => $logo_resize, 'logo_attachment_id' => $_attachement_id, 'logo_width' => $_width, 'logo_height' => $_height, 'logo_type' => trim($logo_type,'_') ); $logos_img[] = $this -> czr_fn_logo_img_view($_args); } }//end foreach //render if ( count($logos_img) == 0 ) $this -> czr_fn_title_view($logo_classes); else $this -> czr_fn_logo_view( array ( 'logo_class' => $logo_classes, // normal logo first 'logos_img' => array_reverse($logos_img) ) ); } /** * Title view * * @package Customizr * @since Customizr 3.2.3 */ function czr_fn_title_view( $logo_classes ) { ob_start(); ?>
%2$s
%3$s' , '' ); ?>
' . __( 'Edit' , 'customizr' ) . '
' : '' ), sprintf( '' , esc_url( get_comment_link( $comment->comment_ID ) ), get_comment_time( 'c' ), /* translators: 1: date, 2: time */ sprintf( __( '%1$s at %2$s' , 'customizr' ), get_comment_date(), get_comment_time() ) ) ), ( '0' == $comment->comment_approved ) ? sprintf('%1$s
', __( 'Your comment is awaiting moderation.' , 'customizr' ) ) : '', 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( czr_fn_opt( 'tc_featured_page_button_text') ) , $fp_single_id ); if ( $tc_fp_button_text || czr_fn_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('%3$s', $tc_fp_button_class, $featured_page_link, $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 ); } ?> czr_fn_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 czr_fn_show_featured_pages() { //gets display fp option $tc_show_featured_pages = esc_attr( czr_fn_opt( 'tc_show_featured_pages' ) ); return apply_filters( 'tc_show_fp', 0 != $tc_show_featured_pages && czr_fn__f('__is_home') ); } function czr_fn_show_featured_pages_img() { //gets display img option return apply_filters( 'tc_show_featured_pages_img', esc_attr( czr_fn_opt( 'tc_show_featured_pages_img' ) ) ); } }//end of class endif; ?> czr_fn_is_gallery_enabled() && apply_filters( 'tc_gallery_style', esc_attr( czr_fn_opt( 'tc_gallery_style' ) ) ) ) array_push($_classes, 'tc-gallery-style'); return $_classes; } /** * Add an optional rel="tc-fancybox[]" attribute to all images embedded in a post gallery * Based on the original WP function * @package Customizr * @since Customizr 3.0.5 * */ function czr_fn_modify_attachment_link( $markup, $id, $size, $permalink, $icon, $text ) { if ( ! $this -> czr_fn_is_gallery_enabled() ) return $markup; $tc_gallery_fancybox = apply_filters( 'tc_gallery_fancybox', esc_attr( czr_fn_opt( 'tc_gallery_fancybox' ) ) , $id ); if ( $tc_gallery_fancybox == 1 && $permalink == false ) //add the filter only if link to the attachment file/image { $id = intval( $id ); $_post = get_post( $id ); if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) return __( 'Missing Attachment' , 'customizr'); if ( $permalink ) $url = get_attachment_link( $_post->ID ); $post_title = esc_attr( $_post->post_title ); if ( $text ) $link_text = $text; elseif ( $size && 'none' != $size ) $link_text = wp_get_attachment_image( $id, $size, $icon ); else $link_text = ''; if ( trim( $link_text ) == '' ) $link_text = $_post->post_title; $markup = ''.$link_text.''; } return $markup; } /* * HELPERS */ function czr_fn_is_gallery_enabled(){ return apply_filters('tc_enable_gallery', esc_attr( czr_fn_opt('tc_enable_gallery') ) ); } }//end of class endif; ?> czr_fn_archive_title_and_class_callback() || is_feed() ) ) return; //Headings for archives, authors, search, 404 add_action ( '__before_loop' , array( $this , 'czr_fn_render_headings_view' ) ); //Set archive icon with customizer options (since 3.2.0) add_filter ( 'tc_archive_icon' , array( $this , 'czr_fn_set_archive_icon' ) ); add_filter( 'tc_archive_header_class' , array( $this , 'czr_fn_archive_title_and_class_callback'), 10, 2 ); add_filter( 'tc_headings_archive_html' , array( $this , 'czr_fn_archive_title_and_class_callback'), 10, 1 ); global $wp_query; if ( czr_fn__f('__is_home') ) add_filter( 'tc_archive_headings_separator' , '__return_false' ); } /** * @return void * set up hooks for post and page headings * callback of template_redirect * * @package Customizr * @since Customizr 3.2.6 */ function czr_fn_set_post_page_heading_hooks() { //by default don't display the Customizr title of the front page and in feeds if ( apply_filters('tc_display_customizr_headings', ( is_front_page() && 'page' == get_option( 'show_on_front' ) ) ) || is_feed() ) return; //Set single post/page icon with customizer options (since 3.2.0) add_filter ( 'tc_content_title_icon' , array( $this , 'czr_fn_set_post_page_icon' ) ); //Prepare the headings for post, page, attachment add_action ( '__before_content' , array( $this , 'czr_fn_render_headings_view' ) ); //Populate heading with default content add_filter ( 'tc_headings_content_html' , array( $this , 'czr_fn_post_page_title_callback'), 10 ); //Create the Customizr title add_filter( 'tc_the_title' , array( $this , 'czr_fn_content_heading_title' ) , 0 ); //Add edit link add_filter( 'tc_the_title' , array( $this , 'czr_fn_add_edit_link_after_title' ), 2 ); //Set user defined archive titles add_filter( 'tc_category_archive_title' , array( $this , 'czr_fn_set_archive_custom_title' ) ); add_filter( 'tc_tag_archive_title' , array( $this , 'czr_fn_set_archive_custom_title' ) ); add_filter( 'tc_search_results_title' , array( $this , 'czr_fn_set_archive_custom_title' ) ); add_filter( 'tc_author_archive_title' , array( $this , 'czr_fn_set_archive_custom_title' ) ); //SOME DEFAULT OPTIONS //No hr if not singular if ( ! is_singular() ) add_filter( 'tc_content_headings_separator' , '__return_false' ); //No headings for some post formats add_filter( 'tc_headings_content_html' , array( $this, 'czr_fn_post_formats_heading') , 100 ); } /****************************************** * VIEWS *********************************** ******************************************/ /** * Generic heading view : archives, author, search, 404 and the post page heading (if not font page) * This is the place where every heading content blocks are hooked * hook : __before_content AND __before_loop (for post lists) * * @package Customizr * @since Customizr 3.1.0 */ function czr_fn_render_headings_view() { $_heading_type = in_the_loop() ? 'content' : 'archive'; ob_start(); ?>%2$s
%3$s%3$s
', implode( ' ', apply_filters( 'tc_slide_text_class', array( 'lead' ), $data['text'], $slider_name_id ) ), $data['color_style'], $data['text'] ) : '', //button call to action ( apply_filters( 'tc_slide_show_button', $data['button_text'] != null, $slider_name_id ) ) ? sprintf('%4$s', implode( ' ', apply_filters( 'tc_slide_button_class', array( 'btn', 'btn-large', 'btn-primary' ), $data['button_text'], $slider_name_id ) ), $button_link, $data['link_target'], $data['button_text'] ) : '' ); } /** * Slide edit link subview * @param $_view_model = array( $id, $data , $slider_name_id, $img_size ) * * @package Customizr * @since Customizr 3.3+ * */ function czr_fn_render_slide_edit_link_view( $_view_model ) { //never display when customizing if ( czr_fn_is_customizing() ) return; //extract $_view_model = array( $id, $data , $slider_name_id, $img_size ) extract( $_view_model ); //display edit link for logged in users with edit_post capabilities //upload_files cap isn't a good lower limit 'cause for example and Author can upload_files but actually cannot edit medias he/she hasn't uploaded $show_slide_edit_link = ( is_user_logged_in() && current_user_can( 'edit_post', $id ) ) ? true : false; $show_slide_edit_link = apply_filters('tc_show_slide_edit_link' , $show_slide_edit_link && ! is_null($data['link_id']), $id ); if ( ! $show_slide_edit_link ) return; $_edit_link_suffix = 'tc_posts_slider' == $slider_name_id ? '' : '#slider_sectionid'; //in case of tc_posts_slider the $id is the *post* id, otherwise it's the attachment id $_edit_link = get_edit_post_link($id) . $_edit_link_suffix; printf('%2$s', $_edit_link, __( 'Edit' , 'customizr' ) ); } /** * Slider Edit deeplink * @param $slides, array of slides * @param $slider_name_id string, the name of the current slider * * hook : __after_carousel_inner * @since v3.4.9 */ function czr_fn_render_slider_edit_link_view( $slides, $slider_name_id ) { //never display when customizing if ( czr_fn_is_customizing() ) return; if ( 'demo' == $slider_name_id ) return; $show_slider_edit_link = false; //We have to show the slider edit link to //a) users who can edit theme options for the slider in home -> deep link in the customizer //b) users who can edit the post/page where the slider is displayed for users who can edit the post/page -> deep link in the post/page slider section if ( czr_fn__f('__is_home') ){ $show_slider_edit_link = ( is_user_logged_in() && current_user_can('edit_theme_options') ) ? true : false; $_edit_link = czr_fn_get_customizer_url( array( 'control' => 'tc_front_slider', 'section' => 'frontpage_sec') ); }else if ( is_singular() ){ // we have a snippet to display sliders in categories, we don't want the slider edit link displayed there global $post; $show_slider_edit_link = ( is_user_logged_in() && ( current_user_can('edit_pages') || current_user_can( 'edit_posts', $post -> ID ) ) ) ? true : false; $_edit_link = get_edit_post_link( $post -> ID ) . '#slider_sectionid'; } $show_slider_edit_link = apply_filters( 'tc_show_slider_edit_link' , $show_slider_edit_link, $slider_name_id ); if ( ! $show_slider_edit_link ) return; // The posts slider shows a different text $_text = sprintf( __( 'Customize or remove %s' , 'customizr' ), ( 'tc_posts_slider' == $slider_name_id ) ?__('the posts slider', 'customizr') : __('this slider', 'customizr' ) ); printf('%2$s', $_edit_link, $_text ); } /* * Slider controls view * @param slides * @hook : __after_carousel_inner * @since v3.2.0 * */ function czr_fn_slider_control_view( $_slides ) { if ( count( $_slides ) <= 1 ) return; if ( ! apply_filters('tc_show_slider_controls' , ! wp_is_mobile() ) ) return; $_html = ''; $_html .= sprintf('%1$s %2$s %3$s
', apply_filters( 'tc_copyright_link', sprintf( '· © %1$s %3$s', esc_attr( date( 'Y' ) ), esc_url( home_url() ), esc_attr( get_bloginfo() ) ) ), apply_filters( 'tc_wp_powered', sprintf( '· %1$s ·', __('Powered by', 'customizr'), __('Powered by WordPress', 'customizr') ) ), apply_filters( 'tc_credit_link', sprintf( '%1$s ·', sprintf( __('Designed with the %s', 'customizr'), sprintf( '%2$s', esc_url( CZR_WEBSITE . 'customizr' ), __('Customizr theme', 'customizr') ) ) ) ) ) ) ); } /** * Displays the back to top fixed text block in the colophon * * * @package Customizr * @since Customizr 3.0.10 */ function czr_fn_colophon_right_block() { //since 3.4.16 BTT button excludes BTT text if ( ! apply_filters('tc_show_text_btt', 0 == esc_attr( czr_fn_opt( 'tc_show_back_to_top' ) ) ) ) return; echo apply_filters( 'tc_colophon_right_block', sprintf('', implode( ' ', apply_filters( 'tc_colophon_right_block_class', array( 'span3', 'backtop' ) ) ), __( 'Back to top' , 'customizr' ), is_rtl() ? 'pull-left' : 'pull-right' ) ); } /****************************** * CALLBACKS / SETTERS *******************************/ /** * Set priorities for right and left colophon blocks, depending on the hook and is_rtl bool * hooks : tc_rtl_colophon_priority * @return void * @param priority number, location string * @package Customizr * @since Customizr 3.3+ */ function czr_fn_set_rtl_colophon_priority( $_priority, $_location ) { if ( ! is_rtl() ) return $_priority; //tc_colophon_right_priority OR tc_colophon_left_priority return 'right' == $_location ? 10 : 30; } /* * Callback of tc_user_options_style hook * @return css string * * @package Customizr * @since Customizr 3.3.27 */ function czr_fn_write_sticky_footer_inline_css( $_css ){ if ( ! ( $this -> is_sticky_footer_enabled() || czr_fn_is_customizing() ) ) return $_css; $_css = sprintf("%s\n%s", $_css, "#tc-push-footer { display: none; visibility: hidden; } .tc-sticky-footer #tc-push-footer.sticky-footer-enabled { display: block; } \n" ); return $_css; } /* * Callback of body_class hook * * @package Customizr * @since Customizr 3.3.27 */ function czr_fn_add_sticky_footer_body_class($_classes) { if ( $this -> is_sticky_footer_enabled() ) $_classes = array_merge( $_classes, array( 'tc-sticky-footer') ); return $_classes; } /** * * Print hookable sticky footer push div * * * @package Customizr * @since Customizr 3.3.27 * * @hook __after_main_container * */ function czr_fn_sticky_footer_push() { if ( ! ( $this -> is_sticky_footer_enabled() || czr_fn_is_customizing() ) ) return; echo ''; } /** * Displays the back to top on scroll * Has to be enabled in the customizer * * @package Customizr * @since Customizr 3.2.0 */ function czr_fn_render_back_to_top() { if ( 0 == esc_attr( czr_fn_opt( 'tc_show_back_to_top' ) ) ) return; printf('