WordPress.org

Ready to get started?Download WordPress

Forums

Remove Support for Headers and Background ..[Request] (10 posts)

  1. Digital Raindrops
    Member
    Posted 3 years ago #

    Not sure if this is the right place, WordPress encourage the use of Child Themes and there is a movement in this direction.

    One problem area is when you create a child theme and you do not want the "Custom Background" and "Custom Header" support, as the design of the theme relies on these being left as default.

    There are functions to add theme support but not to remove theme support for all theme features.

    Some are listed as "Extra Theme Support" but there is no function to remove support for these functions.

    You can remove support for "Theme Functions":
    -> Post Thumbnails
    -> Navigation Menus
    -> Widgets
    -> Post Formats

    You cannot remove support for "Extra Theme Functions":
    -> Custom Backgrounds
    -> Custom Headers
    -> Editor Style
    -> Automatic Feed Links

    The pages are added with the function add_theme_page(), but there is also no remove_theme_page().

    Rather than having to create core functions for these, could the header and background support functions in the twenty ten "Default Theme" just be wrapped in a conditional function that can be overwritten in the child themes function.php

    Regards

    David

  2. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    I'd also like to ask for filters to be added to HEADER_TEXTCOLOR, HEADER_IMAGE and NO_HEADER_TEXT.

  3. Digital Raindrops
    Member
    Posted 3 years ago #

    I'd also like to ask for filters to be added to HEADER_TEXTCOLOR, HEADER_IMAGE and NO_HEADER_TEXT.

    Hi esmi,
    Looking at the soon to be default theme in the "3.1 beta 2" the standard code is different, giving a chance to define these in the child theme functions.php, this would be outside of any 'after_theme_setup' function, as they need to load before the parents function.php file.

    When WordPress 3.1 is released we will have in the updated twenty ten theme functions.php

    if ( ! defined( 'HEADER_TEXTCOLOR' ) )
    	define( 'HEADER_TEXTCOLOR', '' );
    
    if ( ! defined( 'HEADER_IMAGE' ) )
    	define( 'HEADER_IMAGE', '%s/images/headers/path.jpg' );
    
    if ( ! defined( 'NO_HEADER_TEXT' ) )
    	define( 'NO_HEADER_TEXT', true );

    Not sure, but we could add these in an 'init' function in the child theme.

    add_action( 'init', 'init_child_theme_setup' );
    
    function init_child_theme_setup() {
    	define( 'HEADER_IMAGE', get_stylesheet_directory_uri() .'/images/header.jpg' );
    }

    But add_custom_image_header(); and add_custom_background(); are not conditional so we will not be able to unset these from the Appearance sub menu, unless they were wrapped in a function call.

    Regards

    David

    Note / Warning:
    Anyone that has edited the default twenty ten theme, looking at the next beta release the theme folder will be over-written and changes will be lost!

  4. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    Looking at the soon to be default theme in the "3.1 beta 2" the standard code is different

    My bad. I was looking at a beta1 version. Just updated to the latest nightly now. I wonder why they opted for a conditional rather than adding a filter?

    But add_custom_image_header(); and add_custom_background(); are not conditional

    But they're inside twentyten_setup() - which is conditional - so you can get around it by re-writing the setup function in the child.

  5. Digital Raindrops
    Member
    Posted 3 years ago #

    But they're inside twentyten_setup() - which is conditional - so you can get around it by re-writing the setup function in the child.

    Good one, never thought about re-writing the function twentyten_setup() in a child theme, and that would be no problem to me.

    It might be a bit daunting for anyone learning theme development to have to copy across 130+ lines, just to edit a single line of the function to disable say custom backgrounds or headers!

    I am working on a plugin for automatic creation of 2010 Child Themes, so this idea will be very useful for setting the options, and creating the childs functions.php file.

    Many Thanks

    David

  6. esmi
    Theme Diva & Forum Moderator
    Posted 3 years ago #

    I agree - rewriting the entire function just to get rid of 2 lines is a little clunky but, in theory, a quick copy'n'paste of the function into the child theme followed by removal of 4(?) lines should do it. So it should be possible to talk someone through it.

    That plugin sounds very interesting. Excellent idea!

  7. Digital Raindrops
    Member
    Posted 3 years ago #

    The only problem with moving the whole function is that as the theme is updated, you lose the new functions.php code and any code changes.

    In the upcoming release there is new code in the twentyten_setup() function inside the functions.php file, when the default theme is over-written this code will not be availiable to the child theme.

    add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );

    This may or may not be relevent to a child theme.

    David

  8. Well that's what child themes are for :) You can overwrite the functions in the child theme. Otto wrote about that: http://ottopress.com/2010/wordpress-protip-child-themes/

  9. Digital Raindrops
    Member
    Posted 3 years ago #

    Hi Ipstenu,
    I know all about "Child Themes" and overwriting functions, conditional functions, remove action and remove filters, the problem is that the header and background support still cannot be removed in the child themes functions.php.

    As discussed above we could add a function with the same name as the twentyten_setup() in the child theme, copy the whole function code over and remove lines.

    This would then be loaded instead of the parents, but it would be better if we could just, remove_filter(), remove_action(), remove_theme_support() or had wrapper functions for the "Extra Theme Functions":

    Just by wrapping the extra theme function calls, in a parent function would be ok, but something more like this would be ideal:

    remove_theme_support( 'Custom Backgrounds' );
    remove_theme_support( 'Custom Headers' );
    remove_theme_support( 'Editor Style' );
    remove_theme_support( 'Automatic Feed Links' );

    There might be another way, for the twenty ten authors to split down the calls in the twenty ten functions.php, so we have several 'after_setup_theme' functions for different areas.

    add_action( 'after_setup_theme', 'twentyten_setup_general' );
    add_action( 'after_setup_theme', 'twentyten_setup_headers' );
    add_action( 'after_setup_theme', 'twentyten_setup_postimages' );
    add_action( 'after_setup_theme', 'twentyten_setup_background' );

    Just floating ideas, but we need a way in the child theme to loose the Appearance > Headers and Appearance > Background

    Regards

    David

  10. You may want to open trac tickets on it, then. If you can rewrite the calls to be more flexible, put that in too.

Topic Closed

This topic has been closed to new replies.

About this Topic