Changeset 3207250
- Timestamp:
- 12/12/2024 11:07:57 PM (16 months ago)
- Location:
- empty-tags-remover
- Files:
-
- 2 added
- 2 edited
-
tags/1.1.0/empty-tags-remover.php (added)
-
tags/1.1.0/readme.txt (added)
-
trunk/empty-tags-remover.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
empty-tags-remover/trunk/empty-tags-remover.php
r135282 r3207250 2 2 /* 3 3 Plugin Name: Empty Tags Remover 4 Plugin URI: http ://deceblog.net/4 Plugin URI: https://wordpress.org/plugins/empty-tags-remover/ 5 5 Description: Removes the empty tags, tags with no posts attached. 6 Version: 1. 06 Version: 1.1.0 7 7 Author: Dan - Lucian Stefancu 8 Author URI: http ://deceblog.net/9 */ 8 Author URI: https://ospitalier.ro/ 9 */ 10 10 11 11 add_action('admin_menu', 'add_empty_tags_page'); // adds the options page 12 12 13 13 function add_empty_tags_page() { 14 if (function_exists('add_posts_page')) {15 add_posts_page('Remove empty tags', 'Remove empty tags', 8, __FILE__, 'empty_tags_page');16 }14 if (function_exists('add_posts_page')) { 15 add_posts_page('Remove empty tags', 'Remove empty tags', 'edit_posts', 'empty_tags', 'empty_tags_page'); 16 } 17 17 } 18 18 19 19 function empty_tags_page() { ?> 20 20 21 <div class="wrap">22 <h2>Remove Empty Tags</h2>21 <div class="wrap"> 22 <h2>Remove Empty Tags</h2> 23 23 24 <?php 25 if(empty($_POST['remove_my_empty_tags'])) { 26 27 $args = array('offset' => 0, 'number' => 0, 'hide_empty' => 0); 28 29 $tags = get_terms( 'post_tag', $args ); 30 31 $count_tags = 0; 32 echo '<strong>The following tags are empty:</strong><br />'; 33 echo '<ul>'; 34 foreach ($tags as $tag) { 35 if ($tag->count == 0) { 36 echo "<li><a href='edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=$tag->term_id'>" . $tag->name . "</a></li>\n"; 37 $count_tags++; 38 } 39 } 40 if ($count_tags == 0) { echo '<li>No empty tags found!</li>'; } 41 echo '</ul>'; 42 if ($count_tags > 0) { 43 ?> 44 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?page=<?php echo plugin_basename(__FILE__); ?>"> 45 <label for="remove_my_empty_tags">Do you want to remove now all the empty tags?</label> <input type="submit" name="remove_my_empty_tags" value="Yes" /> 46 </form> 47 <?php 48 } // if some empty tags 49 } else { 50 $args = array('offset' => 0, 'number' => 0, 'hide_empty' => 0); 51 52 $tags = get_terms( 'post_tag', $args ); 53 $count_tags = 0; 54 echo '<ul>'; 55 foreach ($tags as $tag) { 56 if ($tag->count == 0) { 57 wp_delete_term($tag->term_id,'post_tag'); 58 echo "<li>" . $tag->name . " deleted</li>"; 59 $count_tags++; 60 } 61 } 62 echo '</ul>'; 63 echo '<strong>' . $count_tags . " empty tag(s) deleted</strong>"; 64 } 65 ?> 66 </div><!-- //wrap --> 24 <?php 25 if(empty($_POST['remove_my_empty_tags'])) { 26 27 $args = array('offset' => 0, 'number' => 0, 'hide_empty' => 0); 28 29 $tags = get_terms( 'post_tag', $args ); 30 31 $count_tags = count($tags); 32 if ($count_tags) { 33 echo '<strong>The following tags are empty:</strong><br />'; 34 echo '<ul>'; 35 foreach ($tags as $tag) { 36 if ($tag->count == 0) { 37 echo "<li><a href='edit-tags.php?action=edit&taxonomy=post_tag&tag_ID=$tag->term_id'>" . $tag->name . "</a></li>\n"; 38 } 39 } 40 echo '</ul>'; 41 } else { 42 echo '<p>No empty tags found!</p>'; 43 } 44 45 if ($count_tags) { 46 ?> 47 <form method="post" action=""> 48 <label for="remove_my_empty_tags">Do you want to remove now all the empty tags?</label> <input type="submit" name="remove_my_empty_tags" value="Yes" /> 49 </form> 50 <?php 51 } 52 } else { 53 $args = array('offset' => 0, 'number' => 0, 'hide_empty' => 0); 54 55 $tags = get_terms( 'post_tag', $args ); 56 $count_tags = 0; 57 echo '<ul>'; 58 foreach ($tags as $tag) { 59 if ($tag->count == 0) { 60 wp_delete_term($tag->term_id,'post_tag'); 61 echo "<li>" . $tag->name . " deleted</li>"; 62 $count_tags++; 63 } 64 } 65 echo '</ul>'; 66 echo '<strong>' . $count_tags . " empty tags deleted</strong>"; 67 } 68 ?> 69 </div><!-- //wrap --> 67 70 <?php } // function ?> -
empty-tags-remover/trunk/readme.txt
r135173 r3207250 3 3 Tags: tags, remove, admin, edit, posts 4 4 Requires at least: 2.5 5 Tested up to: 2.8.1 5 Tested up to: 6.7.1 6 Stable tag: 1.1.0 6 7 7 8 Removes the empty tags, tags with no posts attached. … … 10 11 11 12 Empty Tags Remover adds a page called 'Remove empty tags' under 'Posts' admin menu where you can simply remove all the empty tags with just one click. 12 13 == Installation ==14 15 Instructions for installing the Empty Tags Remover plugin.16 17 1. Download the plugin and unzip it to a folder on your computer.18 1. Upload `empty-tags-remover` folder to the `/wp-content/plugins/` directory19 1. Activate 'Empty Tags Remover' plugin through the 'Plugins' menu in WordPress20 1. Find the page called 'Remove empty tags' under 'Posts' admin menu and remover the trash :)
Note: See TracChangeset
for help on using the changeset viewer.