[wp-hackers] Deleting a lot of posts/terms on plugin deactivation

Nikola Nikolov nikolov.tmw at gmail.com
Fri Jun 28 09:07:57 UTC 2013

It should be a one-time operation indeed, but the question is how would I
use the command-line from inside PHP itself - the idea is that (for
instance)the user would go to a page and click a button that will then
trigger the uninstall process.

It should work on various set-ups and in some cases(well maybe most, I'm
not sure), you won't be able to execute CLI commands from PHP itself, since
that will be disabled.

On Fri, Jun 28, 2013 at 11:35 AM, Mo Braga <Mo.Braga at lbi.com> wrote:

> If this is a one-off operation, use php directly, from the command line:
> php <your-bulk-delete-program>.php
> You may need to load WordPress in your program.  For an example, see
> wp-cron.php
> -----Original Message-----
> From: wp-hackers [mailto:wp-hackers-bounces at lists.automattic.com] On
> Behalf Of Nikola Nikolov
> Sent: 28 June 2013 09:29
> To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] Deleting a lot of posts/terms on plugin deactivation
> Hello everyone,
> I'm currently working on a (yet-another)multilingual plugin for WordPress.
> I'm willing to add an uninstall functionality that would allow the user to
> remove all data created by the plugin(so any options, custom meta, posts,
> terms, etc). The plugin works by creating a duplicate post/term in a custom
> post type/taxonomy for each enabled language.
> I've noticed that when I have for instance 7 enabled languages and I want
> to delete a bunch of posts, my WAMP installation would time-out at 60
> seconds if I try to delete more than probably 10 posts, since I hook to the
> delete_post hook and use wp_delete_post to remove the corresponding
> translation posts - which means, that wp_delete_post is actually called for
> up to 80 posts.
> I realize that wp_delete_post is generally a heavy function, since deletes
> all post meta, comments(?), etc.
> What I'm wondering is whether I should use wp_delete_post or if there
> would be a different approach to deleting multiple files with less load on
> the server. Obviously if I stick to wp_delete_post(), I would use
> ajax-driven uninstall process which would only delete a handful of posts at
> a time.
> I assume one way to beat the timeout would be to try to use
> set_time_limit() whenever I delete translation posts, but obviously I
> can't use this solution for plugin uninstallation, since there could be a
> lot of data(let's say a thousands-of-posts situation).
> ----
> Nikola Nikolov
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
> ________________________________
> Confidentiality notice
> This communication is from LBi Ltd, a private limited company registered
> in Scotland with registered number SC177425 having its registered office at
> 51 Timberbush, Edinburgh, EH6 6QH.
> This electronic message contains information which may be privileged and
> confidential. The information is intended to be for the use of the
> individual(s) or entity named above. If you are not the intended recipient
> be aware that any disclosure, copying, distribution or use of the contents
> of this information is prohibited. If you have received this electronic
> message in error, please notify us by telephone or e-mail as above
> immediately.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list