Support » Plugins » plugin development best practice

  • Hello,

    I’m new to WordPress, but not new to LAMP development.

    I have reviewed the plugin development documentation and am ready to create my first plugin (for eventual community release.)

    Using a small JavaScript library, the plugin will display the full-size version of a thumbnail image. This is liken to Thumbnail Viewer except the image will appear instantly on mouseover instead of clicking.

    I therefore need to add the onmouseover and onmouseout attributes to each image tag. What’s the best way to accomplish this? Thumbnail Viewer manipulates the image tag on the fly with preg_replace. Is this the most efficient way to go about it or is there a better way?

    All comments/suggestions greatly appreciated.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Custom Fields for this..
    but codex doesn’t offer enough documentation about it.

    if you need help with custom fields…
    just say.

    Thanks for your reply.

    Yes, please kindly elaborate.

    When you say “custom fields” do you mean physical form fields or data fields (i.e. an array) that’s used programmatically?

    Just to clarify, I need to devise a way to insert the onmouseover/onmouseout attributes of the image tag to respectively show/hide the full-size version of the thumbnail. The path, caption, width and height params of the image passed to the JavaScript function are defined dynamically using the recordset data.

    as soon as possible I will answer, now I’m full of work,
    sorry if is urgent.
    tomorrow I explain to you how.

    ps.: if you could help me too I appreciate.
    see: http://wordpress.org/support/topic/131219?replies=2

    []’s

    physical form fields avaliable in WordPress on Write post Panel used to customize the data displayed in WordPress Posts…

    Thanks for the tip.

    However in this case no additional physical form fields are required. I only need to figure out the best way to modify or replace the outputted image tags so as to include the onmouseover/onmouseout attributes. I’ll keep digging and look at some other plugins for code examples.

    Hello,

    I also need to implement something like this, basically I need to write a plugin which is scanning all certain tags (I’m thinking to use html comment tag) on a page and then replace some of the tags (only some, not all), based on some algorithm. Can anyone suggest me a direction how to do this?

    Thanks.

    nobody knows?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    I know that, I have read the Action hook and Filters, but could you tell me which one can be applied to my case?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    What case is that? You haven’t said what it is you want to filter.

    Here I paste my case again:

    I also need to implement something like this, basically I need to write a plugin which is scanning all certain tags (I’m thinking to use html comment tag) on a page and then replace some of the tags (only some, not all), based on some algorithm. Can anyone suggest me a direction how to do this?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Again, I say the following: You haven’t said what it is you want to filter. For that matter, you also haven’t said what it is that your filter is going to do, exactly.

    You cannot filter the whole website. You can filter the content of the posts, you can filter the titles, you can filter lots of things, but filters aren’t magical.

    You need to tell me, in WordPress or WordPress-like terms, what specific items on your webpage that you want to add a filter to. Do you want it to happen on all pages of the site, or just some of them? If just some, then which ones? If all, then what specific things on the pages/posts are we talking about?

    Details. We need details. What will your filter do? What things on the page will pass through this filter? That’s what we need to know.

    I’m sorry, I thought my last post was representing my case, but okay, let me elaborate, I need to find certain tags, let’s say the tag is <!–mytag–>, it can be anywhere, in the post, on template etc, so I need to find all of <!–mytag–>’s in a whole page (actually, between <body> and </body> if we’re talking about html page, but let’s assume the whole page if it can make more simple).

    So I need to capture the page before it’s being sent to browser (therefore I can find those tags and replace some of them, leave it to me how to find and what to replace), what I couldn’t figure out is how to capture the page contents before being sent to browser. So I don’t think it’s limited to specific pages or part of a page.

    One idea I’m thinking right now is using output buffering, if you think this is the way please suggest me where to hook the ob_start and ob_end. That’s what I’m thinking, I don’t know if it’s the best way to do this (or maybe even not possible at all), that’s why I’m asking this here.

    I hope it’s detail enough, it can be very long if I tell you everything but what I’m writing and asking here is the part that I don’t know how to do it. Thanks in advance if you can help me here.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    I need to find certain tags, let’s say the tag is <!–mytag–>, it can be anywhere, in the post, on template etc, so I need to find all of <!–mytag–>’s in a whole page

    Filters can’t do that. If that’s really what you want to do, then you’ll need to work some PHP magic and customize the main code to some degree.

    PHP can do this with output buffering, of course. You’ll probably want to put the buffering and code inside the main index.php file in the root directory, so as to capture all of the WordPress output. Everything works through that main index.php file.

    In theory, you could hook onto the init and shutdown action hooks and buffer there using a plugin, but I’ve not tried it.

    One thing you’ll have to watch out for is the gzip compression. If you have gzip compression enabled in WordPress, it uses an output buffer to accomplish that. So if you don’t disable it, your buffer will get back already compressed text, which won’t work.

    ah okay, I’ve guessed about shutdown action hook but don’t know yet about init hook, I’ll try that. As for gzip compression, sure I think my plugin won’t run if gzip enabled, thanks for reminding me.
    And thanks for your help.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘plugin development best practice’ is closed to new replies.