Plugin Directory

Changeset 3207820


Ignore:
Timestamp:
12/13/2024 11:50:20 PM (16 months ago)
Author:
de-ce
Message:

fix: add none field and check, better escape html and url

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

Legend:

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

    r3207259 r3207820  
    44Plugin URI: https://wordpress.org/plugins/empty-tags-remover/
    55Description: Removes the empty tags, tags with no posts attached.
    6 Version: 1.2.2
     6Version: 1.2.3
    77Author: Ospitalier Timisoara
    88Author URI: https://ospitalier.ro/
     
    3737                foreach ($tags as $tag) {
    3838                    if ($tag->count == 0) {
    39                         echo esc_html("<li><a href='edit-tags.php?action=edit&amp;taxonomy=post_tag&amp;tag_ID=$tag->term_id'>" . $tag->name . "</a></li>\n");
     39                        echo "<li><a href='edit-tags.php?action=edit&amp;taxonomy=post_tag&amp;tag_ID=" . esc_url($tag->term_id) . "'>" . esc_html($tag->name) . "</a></li>\n";
    4040                    }
    4141                }
     
    4747            if ($count_tags) {
    4848                ?>
    49                 <form method="post" action="">
    50                     <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 method="post">
     50                    <label for="remove_my_empty_tags">Do you want to remove now all the empty tags?</label>
     51                    <input type="submit" name="remove_my_empty_tags" value="Yes" />
     52                    <?php wp_nonce_field( 'remove_my_empty_tags' ); ?>
    5153                </form>
    5254                <?php
    5355            }
    5456        } else {
     57            $count_tags = 0;
    5558
    56             $tags = get_terms( array(
    57                 'taxonomy'   => 'post_tag',
    58                 'hide_empty' => false,
    59             ) );
    60             $count_tags = 0;
    61             echo '<ul>';
    62             foreach ($tags as $tag) {
    63                 if ($tag->count == 0) {
    64                     wp_delete_term($tag->term_id,'post_tag');
    65                     echo "<li>" . esc_html($tag->name) . " deleted</li>";
    66                     $count_tags++;
     59            if (check_admin_referer( 'remove_my_empty_tags')) {
     60                $tags = get_terms( array(
     61                    'taxonomy'   => 'post_tag',
     62                    'hide_empty' => false,
     63                ) );
     64                echo '<ul>';
     65                foreach ($tags as $tag) {
     66                    if ($tag->count == 0) {
     67                        wp_delete_term($tag->term_id,'post_tag');
     68                        echo "<li>" . esc_html($tag->name) . " deleted</li>";
     69                        $count_tags++;
     70                    }
    6771                }
     72                echo '</ul>';
    6873            }
    69             echo '</ul>';
     74
    7075            echo sprintf("<strong>%s empty tags deleted</strong>", esc_html($count_tags)) ;
    7176        }
  • empty-tags-remover/trunk/readme.txt

    r3207259 r3207820  
    44Requires at least: 2.5
    55Tested up to: 6.7.1
    6 Stable tag: 1.2.2
     6Stable tag: 1.2.3
    77License: GPLv2 or later
    88
Note: See TracChangeset for help on using the changeset viewer.