jrothra

JLR Child Functions

Apr 2nd, 2015
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.40 KB | None | 0 0
  1. <?php
  2. add_filter('tc_global_layout', 'my_custom_layout' );
  3. function my_custom_layout( $layout ) {
  4.     $my_layout      = array(
  5.         'r' => array ('content' => 'span8' , 'sidebar' => 'span4'),//sidebar on the right
  6.         'l' => array ('content' => 'span8' , 'sidebar' => 'span4'),//sidebar on the left
  7.         'b' => array ('content' => 'span4' , 'sidebar' => 'span4'),//both : two sidebars
  8.         'f' => array ('content' => 'span12' , 'sidebar' => false),//full width : no sidebars
  9.     );
  10.  
  11.     //sets new values for content and sidebar (checks if there are new values to set first)
  12.     foreach ($layout as $key => $value) {
  13.         $layout[$key]['content']   = isset( $my_layout[$key]['content']) ? $my_layout[$key]['content'] : $layout_choices[$key]['content'];
  14.         $layout[$key]['sidebar']   = isset( $my_layout[$key]['sidebar']) ? $my_layout[$key]['sidebar'] : $layout_choices[$key]['sidebar'];
  15.     }
  16.     return $layout;
  17. }
  18.  
  19. add_action( 'wp_enqueue_scripts', 'my_google_font' );
  20. function my_google_font() {
  21.     wp_enqueue_style( $handle = 'my-google-font', $src = 'http://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400', $deps = array(), $ver = null, $media = null );
  22. }
  23.  
  24. add_filter( 'tc_meta_utility_text', 'my_meta_texts' );
  25. function my_meta_texts() {
  26.     if ( false != get_the_tags() ) {
  27.         $my_metas = __( '<span class="by-author"> By %4$s</span> on %3$s<br />Categories: %1$s  | Tags: %2$s' , 'customizr' );
  28.     } elseif ( false != get_the_category() ) {
  29.         $my_metas = __( '<span class="by-author"> By %4$s</span> on %3$s<br />Categories: %1$s' , 'customizr' );
  30.     } else {
  31.         $my_metas = __( '<span class="by-author"> By %4$s</span> on %3$s' , 'customizr' );
  32.     }
  33.     return $my_metas;
  34. }
  35.  
  36. add_action('wp_head','my_analytics',1,20);
  37.  
  38. function my_analytics() {
  39.     ?>
  40.  
  41. <script>
  42.   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  43.   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  44.   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  45.   })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  46.  
  47.   ga('create', 'UA-332083-1', 'auto');
  48.   ga('send', 'pageview');
  49.  
  50. </script>
  51.  
  52.     <?php
  53. }
  54.  
  55. // Adds a widget area.
  56. if (function_exists('register_sidebar')) {
  57.     register_sidebar(array(
  58.     'name' => 'Extra Header Widget Area',
  59.     'id' => 'extra-widget-area',
  60.     'description' => 'Extra widget area after the header',
  61.     'before_widget' => '<div class="widget my-extra-widget">',
  62.     'after_widget' => '</div>',
  63.     'before_title' => '<h2>',
  64.     'after_title' => '</h2>'
  65.     ));
  66. }
  67.  
  68. // Place the widget area after the header
  69. add_action ('__after_header', 'add_my_widget_area', 1);
  70. function add_my_widget_area() {
  71.     if (function_exists('dynamic_sidebar')) {
  72.     dynamic_sidebar('Extra Header Widget Area');
  73.     }
  74. }
  75.  
  76. // As of 3.1.10, Customizr doesn't output an html5 form.
  77. add_theme_support( 'html5', array( 'search-form' ) );
  78.  
  79. add_filter('wp_nav_menu_items', 'add_search_form_to_menu', 10, 2);
  80. function add_search_form_to_menu($items, $args) {
  81.  
  82.     // If this isn't the main navbar menu, do nothing
  83.     if( !($args->theme_location == 'main') )
  84.         return $items;
  85.  
  86.     // On main menu: put styling around search and append it to the menu items
  87.     return $items . '<li class="my-nav-menu-search">' . get_search_form(false) . '</li>';
  88. }
  89.  
  90. // Jetpack Related Files Headline Change
  91. function jetpackme_related_posts_headline( $headline ) {
  92. $headline = sprintf(
  93.             '<h3 class="jp-relatedposts-headline" style="font-size:1.5em;"><em>%s</em></h3>',
  94.             esc_html( 'Related Articles' )
  95.             );
  96. return $headline;
  97. }
  98. add_filter( 'jetpack_relatedposts_filter_headline', 'jetpackme_related_posts_headline' );
  99.  
  100. add_filter( 'tc_post_author_metas_html', 'my_author_metas_html', 20, 2);
  101. function my_author_metas_html( $html, $_auth = '' ){
  102.   if ( empty($_auth) )
  103.     return $_html;
  104.   return sprintf( '<span class="by-author">%s %s</span>' , __('By' , 'customizr'), $_auth );
  105. }
  106.  
  107. add_filter( 'tc_post_tax_metas_html', 'my_tax_metas_html', 20, 2);
  108. function my_tax_metas_html( $html, $_tax = array() ){
  109.   if ( empty($_tax) )
  110.     return $_html;
  111.   //extract "_show_cats" , "_show_tags" , "cat_list", "tag_list"
  112.   extract($_tax);
  113.   $cat_list = ! empty($cat_list) && $_show_cats ? sprintf( '<br />%s %s' , 'Category:' , $cat_list ) : '';
  114.   $tag_list = ! empty($tag_list) && $_show_tags ? sprintf( '%s %s %s' , ! empty( $cat_list) ? ' |' : '', 'Tags: ' , $tag_list ) : '';
  115.   return sprintf( '%s%s' , $cat_list, $tag_list );
  116. }
  117. add_filter( 'tc_set_metas_content', 'my_metas_content', 20, 2);
  118. function my_metas_content( $_html, $_parts){
  119.   if ( empty($_parts) )
  120.     return $_html;
  121.  
  122.   //extract $_tax_text , $_date_text, $_author_text, $_update_text
  123.   extract($_parts);
  124.  
  125.   return sprintf( '%3$s %1$s %2$s %4$s' , $_date_text, $_tax_text , $_author_text, $_update_text );
  126. }
  127.  
  128. add_filter( 'tc_grid_col_layout_map' , function( $_map ) {
  129.   return array_merge( $_map, array( 'span8' => '3' ) );
  130. });
  131.  
  132. //Change Footer Credits
  133. add_filter('tc_credits_display', 'my_custom_credits');
  134. function my_custom_credits(){
  135. $credits = '';
  136. $newline_credits = '';
  137. return '
  138. <div class="span4 credits">
  139.                     <p> &middot; &copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; '.($credits ? $credits : 'Customized by <a href="http://www.johnrothra.com/">John L. Rothra</a>').' &middot;'.($newline_credits ? '<br />&middot; '.$newline_credits.' &middot;' : '').'</p>      </div>';
  140. }
  141.  
  142. function jptweak_remove_share() {
  143.     remove_filter( 'the_content', 'sharing_display',19 );
  144.     remove_filter( 'the_excerpt', 'sharing_display',19 );
  145.     if ( class_exists( 'Jetpack_Likes' ) ) {
  146.         remove_filter( 'the_content', array( Jetpack_Likes::init(), 'post_likes' ), 30, 1 );
  147.     }
  148. }
  149.  
  150. add_action( 'loop_start', 'jptweak_remove_share' );
  151.  
  152. function jeherve_early_sharing_buttons( $content ) {
  153.     $sharing = '';
  154.  
  155.     if ( function_exists( 'sharing_display' ) ) {
  156.         $sharing = sharing_display( '', false );
  157.     }
  158.  
  159.     if ( class_exists( 'Jetpack_Likes' ) ) {
  160.         $custom_likes = new Jetpack_Likes;
  161.         $sharing .=  $custom_likes->post_likes( '' );
  162.     }
  163.  
  164.     return $content . $sharing;
  165. }
  166. add_filter( 'the_content', 'jeherve_early_sharing_buttons', 5 );
  167. ?>
Advertisement
Add Comment
Please, Sign In to add comment