WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] My First Plugin - Two Questions (3 posts)

  1. Aleister
    Member
    Posted 8 years ago #

    I have written a lot of custom code for WP, but this is my first attempt at creating a 'true' plugin. I am making an updated version of my sitemap generator script. I just have two little questions :)

    1) Currently I am using an action hook to first check if the phrase "generate_sitemap()" is found in the content. If it is, the plugin generates the sitemap, and does a str_replace to put the sitemap on the page. I think this is a decent way to do this, but I just wanted to be sure :)

    2) Since I will be setting up an options page for the plugin configuration, I will need to create the table for this. I have been reading the documentation, and have a pretty good feel of it, but I did not see any mention of removing the table when the plugin is de-activated. Is it common practice to do this? Or do most plugins just leave the table there in - so that the options are kept if it is re-enabled?

    Thanks for any feedback!

  2. skippy
    Member
    Posted 8 years ago #

    1) I suggest you use an HTML comment as your token: <!-- sitemap --> In this way, de-activating the plugin will not cause the literal string "generate_sitemap()" to be displayed to visitors. Otherwise, you're on the right track.

    2) Leave the table there. People often disable plugins (testing, upgrading, etc), and it would be a shame to lose all the data therein for those transitory reasons.

  3. Aleister
    Member
    Posted 8 years ago #

    Thanks for the super fast reply! That answered my questions perfectly. The comment token method is a great idea as well :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.