Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /** Twentyten child theme: twentyten-child-KN */
- function favicon_link() {
- echo '<link rel="shortcut icon" type="image/x-icon" href="../wp-content/themes/twentyten-child-KN/images/favicon.ico" />' . "\n";
- }
- add_action('wp_head', 'favicon_link');
- /** Tell WordPress to run child_theme_setup()
- when the 'after_setup_theme' hook is run.
- */
- add_action( 'after_setup_theme', 'child_theme_setup' );
- /** This function will hold our new calls and over-rides */
- if ( !function_exists( 'child_theme_setup' ) ):
- function child_theme_setup() {
- /*
- We want a Second Navigation Bar right at the top
- This theme uses wp_nav_menu() in two locations.
- */
- register_nav_menus( array(
- 'secondary' => __( 'Top Navigation', 'twentyten' ),
- ) );
- /** Change header image path to child theme, edit size and remove default parent theme headers
- */
- // This theme allows users to set a custom background
- add_custom_background();
- // Your changeable header business starts here
- define( 'HEADER_TEXTCOLOR', '' );
- // Header images are now in Child Themes Directory
- define('HEADER_IMAGE', get_bloginfo('stylesheet_directory') . '/images/headers/KRSNA_NEWS_header_img.jpg');
- // The height and width of your custom header. You can hook into the theme's own filters to change these values.
- // Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
- define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) ); // choose any number you like here
- define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 100 ) ); // choose any number you like here
- // We'll be using post thumbnails for custom header images on posts and pages.
- // We want them to be 940 pixels wide by 100 pixels tall.
- // Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
- set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
- // Don't support text inside the header image.
- define( 'NO_HEADER_TEXT', true );
- }
- endif;
- 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/
- unregister_default_headers( array(
- 'berries',
- 'cherryblossom',
- 'concave',
- 'fern',
- 'forestfloor',
- 'inkwell',
- 'path',
- 'sunset')
- );
- }
- add_action( 'after_setup_theme', 'child_theme_remove_twenty_ten_headers', 11 );
- // Add our own custom headers packaged with the theme. Theme template directory '/images/headers/'
- register_default_headers( cms_theme_headers() );
- /* Build the Header Array from the theme headers - by David Cox, Digiraindrops */
- // No need to code the headers just loop through the folder and return a list
- $themename = 'twentyten-child-KN';
- function cms_theme_headers() {
- global $themename;
- $list = array();
- $imagepath = STYLESHEETPATH .'/images/headers/';
- $imageurl = get_bloginfo('stylesheet_directory');
- $dir_handle = @opendir($imagepath) or die("Unable to open $path");
- while($file = readdir($dir_handle)){
- if($file == "." || $file == ".."){continue;}
- $filename = explode(".",$file);
- $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
- if(strtolower($ext) == ('png' || 'jpg')){
- if (!strpos($file, '-thumbnail') > 0) {
- $header = array(
- 'url' => $imageurl .'/images/headers/' .$file,
- 'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
- 'description' => __( $filename[0], $themename )
- );
- array_push($list, $header);
- }
- }
- }
- return $list;
- }
- /** Change excerpt and content leads from "Continue reading" to text of our choice.
- * First call the parent functions file with 'after_setup_theme', then call the child's function to remove the parent function.
- * Lastly define new function to replace the removed parent function. */
- add_action( 'after_setup_theme', 'custom_excerpt_setup' );
- function custom_excerpt_setup() {
- remove_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
- remove_filter( 'get_the_excerpt', 'twentyten_custom_excerpt_more' );
- }
- function custom_auto_excerpt_more( $more ) {
- return ' … ' . child_custom_more_link();
- }
- add_filter( 'excerpt_more', 'custom_auto_excerpt_more' );
- function child_custom_excerpt_more( $output ) {
- if ( has_excerpt() && ! is_attachment() ) {
- $output .= child_custom_more_link();
- }
- return $output;
- }
- add_filter( 'get_the_excerpt', 'child_custom_excerpt_more' );
- function child_custom_more_link(){
- return '<a href="'. get_permalink() . '">' . __( 'more <span class="meta-nav">→</span>') . '</a>';
- }
- /** Disable WP autop using shortcode for selected text, courtesy of Matt Valvano, http://ideasandpixels.com/disable-wordpress-auto-formatting-short-code */
- $new_content = '';
- $pattern_full = '{(\[raw\].*?\[/raw\])}is';
- $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
- $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
- foreach ($pieces as $piece) {
- if (preg_match($pattern_contents, $piece, $matches)) {
- $new_content .= $matches[1];
- } else {
- $new_content .= wptexturize(wpautop($piece));
- }
- }
- return $new_content;
- }
- remove_filter(‘the_content’, ‘wpautop’);
- remove_filter(‘the_content’, ‘wptexturize’);
- add_filter(‘the_content’, ‘my_formatter’, 99);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement