• primathon

    (@primathon)


    Not sure if this is the best place to request this, but I would love to see ‘created_at’ and ‘updated_at’ columns added to the wp_snippets table (ala Laravel). I’ve written a number of custom snippets that I use on a few dozen client sites, but keeping everything updated as I refine those snippets can become quite a chore. Having those fields in the snippets database would at least give me a way to internally see roughly what “version” each client site is running. Any chance of this happening? Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hey,

    Thanks for the suggestion. This something I have considered before, but when adding new database table columns I always need to weigh up the cost to sites to how useful they will be to the plugin. So far, I don’t feel that having a modified and created date is super necessary, but if there is enough push to add them then I will certainly do so.

    If you really want to, you can actually add these yourself without modifying the plugin. Simply run this SQL code (you may need to change the table name if you are running WordPress multisite or use a different table prefix):

    ALTER TABLE wp_snippets
    ADD COLUMN created datetime NOT NULL DEFAULT current_timestamp(),
    ADD COLUMN modified datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp();

    The nice thing about this is that the columns will automatically update when the table is written to by either the plugin or if you make manual alterations through a database administration tool.

    Thread Starter primathon

    (@primathon)

    Shea – thanks for responding so quickly! In keeping with the ethos of the Code Snippets plugin, I really try to avoid modifying any core files directly, as there’s no telling when an update may disrupt or break the site.

    This feature request is actually more of a prerequisite for building out a master/client “repository” functionality that I’ve been working on, where one “master” site can run the most up-to-date versions of the snippets, and the “client” sites can pull down the most recent version from master. It may not be super useful for a single-site user, but for those of us who use Code Snippets as an extremely important (read: crucial) dev tool in managing many client sites, this would be a huge help in keeping things updated across the board.

    I’m actually about 80% done coding this already; is there a good way to contact you directly about how to possibly implement this power-user functionality while still keeping things lightweight for most users? I looked around for an email address but didn’t find anything. Thanks again for your time.

    Plugin Author Shea Bunge

    (@bungeshea)

    I fully understand not wanting to modify core files. The solution I provided doesn’t involve editing any files, however – you only need to run the SQL code on your WordPress database using a tool like Sequel Pro, PhpMyAdmin, or Adminer.

    The master/client feature is also one I have heard before, so clearly it would be useful to a number of people. It would be great to get more input on what it could look like – you can find my email address here.

    Thread Starter primathon

    (@primathon)

    Very true; in this instance I suppose I was expanding the definition of “core files” to include the database tables created by the plugins.

    I’ll send you a separate message with some ideas on the master/client feature and share what I’ve experimented with so far. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘‘created_at’ and ‘updated_at’ columns in wp_snippets table?’ is closed to new replies.