Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
<?php /** * Delete all tags for a given content object */ //allow only the app owner to delete tags from any object if (! XN_Profile::current()->isOwner()) { $signInUrl = XN_Request::signInUrl(); echo 'Not allowed <a href="'.$signInUrl.'" >Sign in</a> if you are the owner of this app.'; die(); } ?> <form action="" method="POST"> Object Id:<input type="text" name="object_id"/> <input type="submit" value="Delete All Tags"/> </form> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $content = XN_Content::load($_REQUEST['object_id']); $tagQuery = XN_Query::create('Tag'); $tagQuery->filter('content','=', $content); $tagsQueryResults = $tagQuery->execute(); $tags = array(); foreach($tagsQueryResults as $tag){ //add quotes tothe tags to ensure the full value is considered $tags[] = '"'.$tag->value.'"';; } $tagString = implode(', ',$tags); echo '<p>Content '.$content->id.' had the following tags: '.htmlentities($tagString).'</p>'; XN_Tag::deleteTags( $content , $tagString); echo "<p>They are history.</p>"; } ?>
This paste will be private.
From the Design Piracy series on my blog: