WordPress.org

Ready to get started?Download WordPress

Forums

Plugin/Hack authors READ THIS (4 posts)

  1. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    If you've written hacks in the past, or even if you haven't this is a question for you.
    Where do you want hooks in the WordPress architecture? We have add_filter called most everywhere, and add_action called a few places. Where else would you like each used? add_action is usually passed a relevant ID, like the comment ID or the post ID.

  2. TechGnome
    Moderator
    Posted 10 years ago #

    *bump* This is importaint enough to bump, I think.
    for add_action, would there be a way to know what ID is being passed in? Would they come in as different parameters? or would there be a second parameter that indicates if it's a post or a comment?
    TG

  3. davidchait
    Member
    Posted 10 years ago #

    I can tell you where I've inserted tighter hacks... ;)
    1. In the post-content breakdown. I have a custom nextpage tag system, so I want to be able to pre-process the content before the page breakdown occurs (before the wacky nextpage replacement rules...). I guess this might also then include the ability to strip out the nextpage page breaks and insert something in their place, for a 'single page' layout.
    2. In the actual get_the_content function, I post-process the current content with a number of feature hooks.
    First, I do a custom process for extracting my own feature tags. If it's not a single-post view, I parse $content[1] (I <b>always</b> have a more tag for posts with extra feature tags...), otherwise I process $output. In multi-post pages, I'm just caching information for sidebars and don't touch the content, but in single-post I actually do 'rewire' $output as part of the processing.
    Second, I again post-process $output, in this case for the ability to insert 'dropcaps', which requires modding $output further.
    Both require that I know the $page and my custom $onepost variable (only showing a single post entry)... the latter is effectively a boolean storing [!empty($p)].
    3. In the wp-blog-header, there's a number of customizing hacks for things like sticky/drafts/private (i.e., what posts to get as part of query, showing or not showing based on status and other vars), as well as how to order (like the hack I just posted, if $cat, show sticky and order by status -- otherwise just show published and order by date as normal...).
    I'm assuming add_filter might allow me to do some of my postprocessing (if I know if comes before other content processing, and if it gives me full access to $post, $content, $page, $pages, etc.). Sounds like add_action wouldn't be helpful for my things -- I need tighter integration. :)
    That's just a quick list off the top of my head. ;)
    -d
    http://www.chait.net

  4. omgwtf
    Member
    Posted 10 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.