Plugin Directory

Changeset 3207250


Ignore:
Timestamp:
12/12/2024 11:07:57 PM (16 months ago)
Author:
de-ce
Message:

fix: address XSS vulnerability and minor text adjustment

Location:
empty-tags-remover
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • empty-tags-remover/trunk/empty-tags-remover.php

    r135282 r3207250  
    22/*
    33Plugin Name: Empty Tags Remover
    4 Plugin URI: http://deceblog.net/
     4Plugin URI: https://wordpress.org/plugins/empty-tags-remover/
    55Description: Removes the empty tags, tags with no posts attached.
    6 Version: 1.0
     6Version: 1.1.0
    77Author: Dan - Lucian Stefancu
    8 Author URI: http://deceblog.net/
    9 */ 
     8Author URI: https://ospitalier.ro/
     9*/
    1010
    1111add_action('admin_menu', 'add_empty_tags_page'); // adds the options page
    1212
    1313function 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    }
    1717}
    1818
    1919function empty_tags_page() { ?>
    2020
    21 <div class="wrap">
    22     <h2>Remove Empty Tags</h2>
     21    <div class="wrap">
     22        <h2>Remove Empty Tags</h2>
    2323
    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&amp;taxonomy=post_tag&amp;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&amp;taxonomy=post_tag&amp;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 -->
    6770<?php } // function ?>
  • empty-tags-remover/trunk/readme.txt

    r135173 r3207250  
    33Tags: tags, remove, admin, edit, posts 
    44Requires at least: 2.5
    5 Tested up to: 2.8.1
     5Tested up to: 6.7.1
     6Stable tag: 1.1.0
    67
    78Removes the empty tags, tags with no posts attached.
     
    1011
    1112Empty 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/` directory
    19 1. Activate 'Empty Tags Remover' plugin through the 'Plugins' menu in WordPress
    20 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.