ThemeShaper Forums » Thematic

[closed]

Bug: Overriding action hook calls

(5 posts)
  • Started 3 years ago by de_ce
  • Latest reply from Jonny Janiero
  • This topic is resolved
  1. There are many actions hooks that are not called if a ovverriding function in a child theme is used.

    ex:


    // Create the blog description
    // In the header div
    if (function_exists('childtheme_override_blogdescription')) {
    function thematic_blogdescription() {
    childtheme_override_blogdescription();
    }
    } else {
    function thematic_blogdescription() {
    $blogdesc = '"blog-description">' . get_bloginfo('description');
    if (is_home() || is_front_page()) {
    echo "\t\t<h1 id=$blogdesc</h1>\n\n";
    } else {
    echo "\t\t<div id=$blogdesc</div>\n\n";
    }
    }
    add_action('thematic_header','thematic_blogdescription',5);
    }

    The action hook is called before the end of the if clause. It's kinda unintuitive to make a override function and call an action for the default function after it.

    Ex:


    function childtheme_override_blogdescription() { ?>
    <p><?php get_bloginfo('description'); ?></p>
    <?php
    }
    add_action('thematic_header','thematic_blogdescription',5);

    For some functions, the hooks are calld, but for other aren't. It's messy. A consitent rule would be nice.

    Posted 3 years ago #
  2. Thanks for pointing this out. This has been corrected in the latest svn branch.

    You can download the latest stable development version here : http://developing.thematic4you.com/thematic-development-release/
    The sometimes experimental svn branch is here: http://code.google.com/p/thematic/source/checkout
    And bug reports are best made here: http://code.google.com/p/thematic/issues/list and in the forums ;)

    Thanks again,
    Gene

    Posted 3 years ago #
  3. @de_ce good find
    @em hr many thanks for the corrections.

    can i ask,
    for example...

    childtheme_override_blogtitle

    without using the 'add_action' part, is there a way you can still specify its position within the override

    example...

    add_action('thematic_header','thematic_blogtitle',3);

    or do you just have to use the override, then remove/add new action to change position.

    hope any of this makes sense?

    Posted 3 years ago #
  4. Jonny,

    Yes, you have to override and then remove the action in a function that is hooked into init and then add again to change the priority parameter of the add_action hook. If you do not remove_action from the original priority the override will execute twice.

    -Gene

    Posted 3 years ago #
  5. thanks for clearing that up Gene

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.