Advertisement
Guest User

Untitled

a guest
Feb 18th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.32 KB | None | 0 0
  1. <?php
  2.  
  3. /** Twentyten child theme: twentyten-child-KN */
  4.  
  5. function favicon_link() {
  6. echo '<link rel="shortcut icon" type="image/x-icon" href="../wp-content/themes/twentyten-child-KN/images/favicon.ico" />' . "\n";
  7. }
  8. add_action('wp_head', 'favicon_link');
  9.  
  10. /** Tell WordPress to run child_theme_setup()
  11. when the 'after_setup_theme' hook is run.
  12. */
  13. add_action( 'after_setup_theme', 'child_theme_setup' );
  14.  
  15. /** This function will hold our new calls and over-rides */
  16. if ( !function_exists( 'child_theme_setup' ) ):
  17. function child_theme_setup() {
  18.  
  19. /*
  20. We want a Second Navigation Bar right at the top
  21. This theme uses wp_nav_menu() in two locations.
  22. */
  23. register_nav_menus( array(
  24. 'secondary' => __( 'Top Navigation', 'twentyten' ),
  25. ) );
  26.  
  27. /** Change header image path to child theme, edit size and remove default parent theme headers
  28. */
  29. // This theme allows users to set a custom background
  30. add_custom_background();
  31.  
  32. // Your changeable header business starts here
  33. define( 'HEADER_TEXTCOLOR', '' );
  34.  
  35. // Header images are now in Child Themes Directory
  36. define('HEADER_IMAGE', get_bloginfo('stylesheet_directory') . '/images/headers/KRSNA_NEWS_header_img.jpg');
  37.  
  38.  
  39. // The height and width of your custom header. You can hook into the theme's own filters to change these values.
  40. // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
  41. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); // choose any number you like here
  42. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 100 ) ); // choose any number you like here
  43.  
  44. // We'll be using post thumbnails for custom header images on posts and pages.
  45. // We want them to be 940 pixels wide by 100 pixels tall.
  46. // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
  47. set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
  48.  
  49. // Don't support text inside the header image.
  50. define( 'NO_HEADER_TEXT', true );
  51.  
  52.  
  53. }
  54. endif;
  55.  
  56. function child_theme_remove_twenty_ten_headers(){ //source: http://aaron.jorb.in/blog/2010/07/remove-all-default-header-images-in-a-twenty-ten-child-theme/
  57. unregister_default_headers( array(
  58. 'berries',
  59. 'cherryblossom',
  60. 'concave',
  61. 'fern',
  62. 'forestfloor',
  63. 'inkwell',
  64. 'path',
  65. 'sunset')
  66. );
  67. }
  68. add_action( 'after_setup_theme', 'child_theme_remove_twenty_ten_headers', 11 );
  69.  
  70.  
  71. // Add our own custom headers packaged with the theme. Theme template directory '/images/headers/'
  72. register_default_headers( cms_theme_headers() );
  73.  
  74. /* Build the Header Array from the theme headers - by David Cox, Digiraindrops */
  75. // No need to code the headers just loop through the folder and return a list
  76. $themename = 'twentyten-child-KN';
  77. function cms_theme_headers() {
  78. global $themename;
  79. $list = array();
  80. $imagepath = STYLESHEETPATH .'/images/headers/';
  81. $imageurl = get_bloginfo('stylesheet_directory');
  82. $dir_handle = @opendir($imagepath) or die("Unable to open $path");
  83. while($file = readdir($dir_handle)){
  84. if($file == "." || $file == ".."){continue;}
  85. $filename = explode(".",$file);
  86. $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
  87. if(strtolower($ext) == ('png' || 'jpg')){
  88. if (!strpos($file, '-thumbnail') > 0) {
  89. $header = array(
  90. 'url' => $imageurl .'/images/headers/' .$file,
  91. 'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
  92. 'description' => __( $filename[0], $themename )
  93. );
  94. array_push($list, $header);
  95. }
  96. }
  97. }
  98. return $list;
  99. }
  100. /** Change excerpt and content leads from "Continue reading" to text of our choice.
  101. * First call the parent functions file with 'after_setup_theme', then call the child's function to remove the parent function.
  102. * Lastly define new function to replace the removed parent function. */
  103. add_action( 'after_setup_theme', 'custom_excerpt_setup' );
  104. function custom_excerpt_setup() {
  105. remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
  106. remove_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
  107. }
  108.  
  109. function custom_auto_excerpt_more( $more ) {
  110. return ' &hellip; ' . child_custom_more_link();
  111. }
  112. add_filter( 'excerpt_more', 'custom_auto_excerpt_more' );
  113.  
  114. function child_custom_excerpt_more( $output ) {
  115. if ( has_excerpt() && ! is_attachment() ) {
  116. $output .= child_custom_more_link();
  117. }
  118. return $output;
  119. }
  120. add_filter( 'get_the_excerpt', 'child_custom_excerpt_more' );
  121.  
  122. function child_custom_more_link(){
  123. return '<a href="'. get_permalink() . '">' . __( 'more <span class="meta-nav">&rarr;</span>') . '</a>';
  124. }
  125. /** Disable WP autop using shortcode for selected text, courtesy of Matt Valvano, http://ideasandpixels.com/disable-wordpress-auto-formatting-short-code */
  126. $new_content = '';
  127. $pattern_full = '{(\[raw\].*?\[/raw\])}is';
  128. $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
  129. $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
  130. foreach ($pieces as $piece) {
  131. if (preg_match($pattern_contents, $piece, $matches)) {
  132. $new_content .= $matches[1];
  133. } else {
  134. $new_content .= wptexturize(wpautop($piece));
  135. }
  136. }
  137. return $new_content;
  138. }
  139. remove_filter(‘the_content’, ‘wpautop’);
  140. remove_filter(‘the_content’, ‘wptexturize’);
  141. add_filter(‘the_content’, ‘my_formatter’, 99);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement