Support » Plugins » My First Plugin – Two Questions

  • Resolved Aleister


    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • skippy



    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.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘My First Plugin – Two Questions’ is closed to new replies.