ThemeShaper Forums » Thematic

[closed]

childtheme_override bug?

(7 posts)
  • Started 2 years ago by thespareroomstudio
  • Latest reply from thespareroomstudio
  • This topic is resolved
  1. thespareroomstudio
    Member

    Hello,

    Just started using Thematic, great work. I have a question though. It seems like all the childtheme_overrides in the thematic_header hook have the add_action in the wrong place in the conditional statement. For example, here is the code for childtheme_override_brandingclose():

    if (function_exists('childtheme_override_brandingclose'))  {
    	    function thematic_brandingclose() {
    	    	childtheme_override_brandingclose();
    	    }
    	} else {
    	    function thematic_brandingclose() {
    	    	echo "\t\t</div><!--  #branding -->\n";
    	    }
    	    add_action('thematic_header','thematic_brandingclose',7);
    	}

    Is this done on purpose? If so, how do I add the hook correctly in my own function. I have tried both add_action('thematic_header', 'thematic_brandingclose', 7); and add_action('thematic_header', 'childtheme_override_brandingclose', 7); in my child theme's functions.php file. Both ways seem to not execute what I put in the function. Thanks for the help.

    function childtheme_override_brandingclose() {
    	echo "\t\t</div><!--  #branding -->\n";
    	add_action('themeatic_header', 'thematic_brandingclose', 7);
    	}
    Posted 2 years ago #
  2. sowingseeds
    Member

    Couple of things. If using childtheme_override_brandingclose you are overriding what is in thematic_brandingclose. Your code above 1) you are seeking to replace what is there with exactly the same code? 2) When you use an override you do not add it with an 'add_action' but simply:
    function chidtheme_override_***(){
    //my replacement code to what is in the original function;
    }

    No add_action needed.

    Posted 2 years ago #
  3. thespareroomstudio
    Member

    sowingseeds, thanks for your reply.

    I actually have a different echo statement in my own function, I just chose to echo the closing div as an example to show add_action(). Sorry for the confusion. Allow me to clarify.

    I originally DID NOT have add_action in my function, but noticed that childtheme_override_brandingclose() was not executing. Upon inspecting the code in Thematic's core, I noticed that there is NO add_action if using childtheme_override_brandingclose() according to the conditional statement I included above. add_action is only implemented if there is NO childtheme_override_brandingclose(). Which brought me to my question... is that on purpose? To me, it would make sense if add_action('thematic_header', 'thematic_brandingclose', 7)'; was after the conditional. Such is the case in other childtheme_overrides that are NOT in the header. So I am wondering if this was missed or intentional. And if it is intentional, what would be the correct way for me to use the overrides?

    If I edit the Thematic Core file (gasp!) and move add_action after the conditional, my override function works. Obviously, this is not what I want to do.

    Hopefully that clarifies things a bit. Sorry about that. Thanks for the help.

    Posted 2 years ago #
  4. sowingseeds
    Member

    OK I think I get what you are looking for. Don't go and edit the thematic files. The hook you are looking to add to is thematic_header,6. 'thematic_brandingclose' is basically the closing division of branding, so assuming you want to add a function into branding - after blog-title and blog-description... but still inside branding:

    function before_branding_closes() {
    	//place function here
            }
    add_action('thematic_header', 'before_branding_closes', 6);

    The '6' places it after 5 - site-description and before 7 - branding close.

    Posted 2 years ago #
  5. thespareroomstudio
    Member

    sowingseeds,

    Worked like a charm. Thanks. I feel better that I didn't have to edit Thematic's core.

    Do we know yet if this was intentional? I'm trying to find the logic of doing it this way, verses the rest of the overrides.

    Posted 2 years ago #
  6. sowingseeds
    Member

    Can't answer for the design, but I would say 'yes'. Most action hooks have nothing attached to them: aboveheader etc. They are there to have some action attached to them if needed. The ones in the header have division openings (+ other aspects) and division closure (as per brandingclose. The numbers position where in the header they appear - hence by using no 6 we are placing a function b4 the close of branding. We could have made an adjustment to the override and placed a function in the brandingclose hook - placing our function b4 the final echo command.

    Here is a generic guide to hooks and filters:
    http://wpcandy.com/teaches/how-to-use-wordpress-hooks
    And for Thematic:
    post-22638

    Posted 2 years ago #
  7. thespareroomstudio
    Member

    Thanks for the help and links. Much appreciated.

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.