• joh

    (@joh)


    I’ve been staring long and hard at the plugin API for a while now, but to no avail. All filter hooks seem to deal with filtering the output, that is the content going from the database on its way to the browser. What I need is a hook to filter the input when editing/saving a posting on its way to the database.
    For what I’m trying to do: I’d like to write a plugin that converts short wiki-like markup into HTML while saving the posting. Note that this is a totally different thing from what the markdown or textile plugins do: these convert to HTML on the way out, leaving me with awkward markup in the database forever (which is something I don’t like at all for various reasons).
    The action hooks don’t seem to fit the bill either. There’s nothing like “save_post”…
    Any ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Anonymous

    I don’t have any ideas, but I am curious about what you are doing. Do you mind sharing any details?

    dissurion

    (@dissurion)

    I’ve asked the same 2 days ago after hard work trying to get it done. And I’m still lost. So I hope you’ll get an answer.
    One thing I see is that you probably can manipulate to post data in post.php itself. But I still have no idea how to do this through a plugin.

    dissurion

    (@dissurion)

    Ofcourse an alternative approach would be to go directly for the database itself. Think that should be doable from within a plugin.

    Thread Starter joh

    (@joh)

    The problem with directly going to the database from within a plugin is that you have to hook something in at the right moment, intercept the data being inserted in the db, convert it and actually insert it then. I do not see how I should do this. Well, there is a filter hook called “format_to_post”, which sounds as if it could be the right thing, but it is nowhere documented. I have to dive into the sources, I guess.

    dissurion

    (@dissurion)

    I’ve delved into the posts too and some things are too advanced for me and it would take me too long to know the inner workings of WP. I could ofcourse alter the code itself but I prefer to do this with a plugin, else I have to worry about updating all the time and changing the files.
    So I’ve settled for not changing the database input but only the output. If you find a way to deal with it through plugins I would appreciate it if you post back.
    ps: I found a program that searches the texts itself in a directory easy to see which files (and which lines on them) have eg a funtion I’m looking for. That way I know all the places I should study.

    Thread Starter joh

    (@joh)

    The filter hook format_to_post seems to do the trick just fine.

    adsworth

    (@adsworth)

    Hi joh,
    From the looks of it the filter format_to_post is applied just before
    saving, so that is where you could hook in.
    Regards
    Adi

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Filtering input instead of output?’ is closed to new replies.