Plugin Directory

Changeset 3111079


Ignore:
Timestamp:
07/02/2024 10:56:10 AM (20 months ago)
Author:
joostdevalk
Message:

Update to version 1.5 from GitHub

Location:
fewer-tags
Files:
2 added
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • fewer-tags/tags/1.5/fewer-tags.php

    r3029045 r3111079  
    44 *
    55 * @package FewerTags
    6  * @version 1.4.1
     6 * @version 1.5
    77 *
    88 * Plugin Name:       Fewer Tags
     
    1111 * Requires at least: 6.2
    1212 * Requires PHP:      7.4
    13  * Version:           1.4.1
     13 * Version:           1.5
    1414 * Author:            Joost de Valk
    1515 * Author URI:        https://joost.blog/
  • fewer-tags/tags/1.5/readme.txt

    r3064750 r3111079  
    33Tags: tag, tags, seo
    44Requires at least: 6.2
    5 Tested up to: 6.5
     5Tested up to: 6.6
    66Requires PHP: 7.4
    7 Stable tag: 1.4.1
     7Stable tag: 1.5
    88License: GPL3+
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    2020* Are hidden from visitors and search engines on your site, and are redirected to your homepage.
    2121* They don't show up in tag listings.
    22 * The are no longer linked in WordPress core's or Yoast SEO generated XML sitemaps.
     22* The are no longer linked in WordPress core's or Yoast SEO or Slim SEO generated XML sitemaps.
    2323
    2424This positively affects your site's SEO and also leads to less crawling, as you have less useless tag pages.
     
    6565== Changelog ==
    6666
     67= 1.5 =
     68
     69Enhancements:
     70
     71* Add support for Slim SEO, props [Anh Tran](https://profiles.wordpress.org/rilwis/).
     72
     73Bugfixes:
     74
     75* Reinstates the "View" action for other taxonomies than tags.
     76
     77Development:
     78
     79* Updated PHPCompatibility, added PHPStan and fixed all resulting issues.
     80
    6781= 1.4.1 =
    6882
  • fewer-tags/tags/1.5/src/class-admin.php

    r3028877 r3111079  
    1717    /**
    1818     * Register the needed hooks.
     19     *
     20     * @return void
    1921     */
    2022    public function register_hooks() {
    21         add_action( 'admin_init', [ $this, 'register_settings' ] );
    22         add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
    23         add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
    24         add_filter( 'tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
     23        \add_action( 'admin_init', [ $this, 'register_settings' ] );
     24        \add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
     25        \add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
     26        \add_filter( 'post_tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
    2527    }
    2628
    2729    /**
    2830     * Register settings and add settings field to the Reading settings page.
     31     *
     32     * @return void
    2933     */
    3034    public function register_settings() {
    31         add_settings_section(
     35        \add_settings_section(
    3236            'fewer_tags_section',
    33             __( 'Fewer tags settings', 'fewer-tags' ),
     37            __( 'Fewer Tags settings', 'fewer-tags' ),
    3438            [ $this, 'display_section' ],
    3539            'reading'
    3640        );
    3741
    38         add_settings_field(
     42        \add_settings_field(
    3943            Plugin::$option_name,
    4044            __( 'Tags need to have', 'fewer-tags' ),
     
    4448        );
    4549
    46         register_setting( 'reading', Plugin::$option_name );
     50        \register_setting( 'reading', Plugin::$option_name );
    4751    }
    4852
    4953    /**
    5054     * Display the section text.
     55     *
     56     * @return void
    5157     */
    5258    public function display_section() {
    53         esc_html_e( 'Set the minimum number of posts a tag should have to become live on the site and not be redirected to the homepage.', 'fewer-tags' );
     59        \esc_html_e( 'Set the minimum number of posts a tag should have to become live on the site and not be redirected to the homepage.', 'fewer-tags' );
    5460    }
    5561
    5662    /**
    5763     * Display the setting field in the Reading settings page.
     64     *
     65     * @return void
    5866     */
    5967    public function display_setting() {
    6068        ?>
    6169        <input
    62             name="<?php echo esc_attr( Plugin::$option_name ); ?>"
    63             id="<?php echo esc_attr( Plugin::$option_name ); ?>"
     70            name="<?php echo \esc_attr( Plugin::$option_name ); ?>"
     71            id="<?php echo \esc_attr( Plugin::$option_name ); ?>"
    6472            type="number"
    6573            min="1"
    66             value="<?php echo esc_attr( Plugin::$min_posts_count ); ?>"
     74            value="<?php echo (int) Plugin::$min_posts_count; ?>"
    6775            class="small-text"
    6876        />
    69         <?php esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
     77        <?php \esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
    7078        <?php
    7179    }
     
    94102    public function manage_tag_columns( $out, $column_name, $tag_ID ) {
    95103        if ( $column_name === 'active' ) {
    96             $term = get_term( $tag_ID );
    97             $out  = esc_html__( 'Live', 'fewer-tags' );
     104            $term = \get_term( $tag_ID );
     105            $out  = \esc_html__( 'Live', 'fewer-tags' );
    98106            if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
    99                 $out = '<span title="' . esc_html__( 'Not live due to not enough posts being in this tag.', 'fewer-tags' ) . '">' . esc_html__( 'Not live', 'fewer-tags' ) . '</span>';
     107                $out = '<span title="' . \esc_html__( 'Not live due to not enough posts being in this tag.', 'fewer-tags' ) . '">' . \esc_html__( 'Not live', 'fewer-tags' ) . '</span>';
    100108            }
    101109        }
     
    107115     * Removes the "View" action link for tags that have fewer than the minimum number of posts.
    108116     *
    109      * @param array   $actions An array of action links.
    110      * @param WP_Term $tag     Current WP_Term object.
     117     * @param array    $actions An array of action links.
     118     * @param \WP_Term $tag     Current WP_Term object.
    111119     *
    112120     * @return array Modified array of action links.
  • fewer-tags/tags/1.5/src/class-frontend.php

    r3028877 r3111079  
    1515    /**
    1616     * Register the needed hooks.
     17     *
     18     * @return void
    1719     */
    1820    public function register_hooks() {
    19         add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
    20         add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
    21         add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
    22         add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
    23         add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
     21        \add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
     22        \add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
     23        \add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
     24        \add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
     25        \add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
     26        \add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
    2427    }
    2528
    2629    /**
    2730     * Redirect tag pages with fewer than the specified number of posts to the home page.
     31     *
     32     * @return void
    2833     */
    2934    public function redirect_tag_pages() {
    30         if ( is_tag() ) {
    31             $tag = get_queried_object();
     35        if ( \is_tag() ) {
     36            $tag = \get_queried_object();
    3237            if ( $tag && $tag->count < \FewerTags\Plugin::$min_posts_count ) {
    33                 wp_safe_redirect( home_url(), 301 );
     38                \wp_safe_redirect( \home_url(), 301 );
    3439                // @codeCoverageIgnoreStart
    3540                exit;
     
    4449     * Only works on post_tag taxonomy.
    4550     *
    46      * @param WP_Term[]|WP_Error $terms    Array of attached terms, or WP_Error on failure.
    47      * @param int                $post_id  Post ID.
    48      * @param string             $taxonomy Name of the taxonomy.
     51     * @param \WP_Term[]|\WP_Error $terms    Array of attached terms, or WP_Error on failure.
     52     * @param int                  $post_id  Post ID.
     53     * @param string               $taxonomy Name of the taxonomy.
    4954     *
    5055     * @return array The filtered array of term objects.
     
    5560        }
    5661
    57         if ( is_array( $terms ) ) {
     62        if ( \is_array( $terms ) ) {
    5863            foreach ( $terms as $key => $tag ) {
    5964                if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
     
    7479     */
    7580    public function filter_get_the_tags( $tags ) {
    76         if ( is_array( $tags ) ) {
     81        if ( \is_array( $tags ) ) {
    7782            foreach ( $tags as $key => $tag ) {
    7883                if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
     
    103108
    104109        // exclude terms with too few posts.
    105         $args['exclude'] = array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
     110        $args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
     111        return $args;
     112    }
     113
     114    /**
     115     * Excludes tags with fewer than the minimum number of posts from the Slim SEO sitemap.
     116     *
     117     * @param array $args The arguments for the sitemap query.
     118     *
     119     * @return array The modified arguments for the sitemap query.
     120     */
     121    public function exclude_tags_from_slim_seo_sitemap( $args ) {
     122        if ( ! isset( $args['exclude'] ) ) {
     123            $args['exclude'] = [];
     124        }
     125
     126        // exclude terms with too few posts.
     127        $args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
    106128        return $args;
    107129    }
     
    120142
    121143        // Fetch all tag IDs.
    122         $tag_ids = get_terms( $args );
     144        $tag_ids = \get_terms( $args );
    123145
    124146        // Filter tag IDs based on post count.
    125         $filtered_tag_ids = array_filter(
     147        $filtered_tag_ids = \array_filter(
    126148            $tag_ids,
    127149            function ( $tag_id ) {
    128                 $tag = get_term( $tag_id, 'post_tag' );
     150                $tag = \get_term( $tag_id, 'post_tag' );
    129151                return ( $tag->count < \FewerTags\Plugin::$min_posts_count );
    130152            }
     
    154176        $tags = get_terms( $args );
    155177
    156         if ( ! is_wp_error( $tags ) ) {
     178        if ( ! \is_wp_error( $tags ) ) {
    157179            foreach ( $tags as $tag_id ) {
    158                 $term = get_term( $tag_id );
     180                $term = \get_term( $tag_id );
    159181                if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
    160182                    $excluded_term_ids[] = $tag_id;
  • fewer-tags/tags/1.5/src/class-playground.php

    r3009870 r3111079  
    1515    /**
    1616     * Register hooks.
     17     *
     18     * @return void
    1719     */
    1820    public function register_hooks() {
     
    2628    /**
    2729     * Print an admin notice helping people.
     30     *
     31     * @return void
    2832     */
    2933    public function admin_notices() {
     
    3842        echo '</p>';
    3943        echo '<p>';
    40         \esc_html_e( 'You can go to Settings → Reading to change how many tags a tag needs to have to be live on the site.', 'fewer-tags' );
     44        \esc_html_e( 'You can go to Settings → Reading to change how many posts a tag needs to have to be live on the site.', 'fewer-tags' );
    4145        echo '</p>';
    4246        echo '</div>';
     
    4549    /**
    4650     * Generate random posts & terms.
     51     *
     52     * @return void
    4753     */
    4854    public function generate_data() {
     
    6672     *
    6773     * @param string $common_tag Tag to attach to all posts.
     74     *
    6875     * @return int Post ID.
    6976     */
     
    8895     */
    8996    private function create_tag( $tag_name ) {
    90         if ( ! \term_exists( $tag_name, 'post_tag' ) ) {
     97        $term = \term_exists( $tag_name, 'post_tag' );
     98        if ( null === $term ) {
    9199            $term = \wp_insert_term( $tag_name, 'post_tag' );
    92             return $term['term_id'];
    93100        }
     101
     102        return $term['term_id'];
    94103    }
    95104
  • fewer-tags/tags/1.5/src/class-plugin.php

    r3028877 r3111079  
    2929    /**
    3030     * Register plugin hooks.
     31     *
     32     * @return void
    3133     */
    3234    public function register_hooks() {
     
    3739    /**
    3840     * Initialize the plugin and register hooks.
     41     *
     42     * @return void
    3943     */
    4044    public function init() {
  • fewer-tags/trunk/fewer-tags.php

    r3029045 r3111079  
    44 *
    55 * @package FewerTags
    6  * @version 1.4.1
     6 * @version 1.5
    77 *
    88 * Plugin Name:       Fewer Tags
     
    1111 * Requires at least: 6.2
    1212 * Requires PHP:      7.4
    13  * Version:           1.4.1
     13 * Version:           1.5
    1414 * Author:            Joost de Valk
    1515 * Author URI:        https://joost.blog/
  • fewer-tags/trunk/readme.txt

    r3064750 r3111079  
    33Tags: tag, tags, seo
    44Requires at least: 6.2
    5 Tested up to: 6.5
     5Tested up to: 6.6
    66Requires PHP: 7.4
    7 Stable tag: 1.4.1
     7Stable tag: 1.5
    88License: GPL3+
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    2020* Are hidden from visitors and search engines on your site, and are redirected to your homepage.
    2121* They don't show up in tag listings.
    22 * The are no longer linked in WordPress core's or Yoast SEO generated XML sitemaps.
     22* The are no longer linked in WordPress core's or Yoast SEO or Slim SEO generated XML sitemaps.
    2323
    2424This positively affects your site's SEO and also leads to less crawling, as you have less useless tag pages.
     
    6565== Changelog ==
    6666
     67= 1.5 =
     68
     69Enhancements:
     70
     71* Add support for Slim SEO, props [Anh Tran](https://profiles.wordpress.org/rilwis/).
     72
     73Bugfixes:
     74
     75* Reinstates the "View" action for other taxonomies than tags.
     76
     77Development:
     78
     79* Updated PHPCompatibility, added PHPStan and fixed all resulting issues.
     80
    6781= 1.4.1 =
    6882
  • fewer-tags/trunk/src/class-admin.php

    r3028877 r3111079  
    1717    /**
    1818     * Register the needed hooks.
     19     *
     20     * @return void
    1921     */
    2022    public function register_hooks() {
    21         add_action( 'admin_init', [ $this, 'register_settings' ] );
    22         add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
    23         add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
    24         add_filter( 'tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
     23        \add_action( 'admin_init', [ $this, 'register_settings' ] );
     24        \add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
     25        \add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
     26        \add_filter( 'post_tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
    2527    }
    2628
    2729    /**
    2830     * Register settings and add settings field to the Reading settings page.
     31     *
     32     * @return void
    2933     */
    3034    public function register_settings() {
    31         add_settings_section(
     35        \add_settings_section(
    3236            'fewer_tags_section',
    33             __( 'Fewer tags settings', 'fewer-tags' ),
     37            __( 'Fewer Tags settings', 'fewer-tags' ),
    3438            [ $this, 'display_section' ],
    3539            'reading'
    3640        );
    3741
    38         add_settings_field(
     42        \add_settings_field(
    3943            Plugin::$option_name,
    4044            __( 'Tags need to have', 'fewer-tags' ),
     
    4448        );
    4549
    46         register_setting( 'reading', Plugin::$option_name );
     50        \register_setting( 'reading', Plugin::$option_name );
    4751    }
    4852
    4953    /**
    5054     * Display the section text.
     55     *
     56     * @return void
    5157     */
    5258    public function display_section() {
    53         esc_html_e( 'Set the minimum number of posts a tag should have to become live on the site and not be redirected to the homepage.', 'fewer-tags' );
     59        \esc_html_e( 'Set the minimum number of posts a tag should have to become live on the site and not be redirected to the homepage.', 'fewer-tags' );
    5460    }
    5561
    5662    /**
    5763     * Display the setting field in the Reading settings page.
     64     *
     65     * @return void
    5866     */
    5967    public function display_setting() {
    6068        ?>
    6169        <input
    62             name="<?php echo esc_attr( Plugin::$option_name ); ?>"
    63             id="<?php echo esc_attr( Plugin::$option_name ); ?>"
     70            name="<?php echo \esc_attr( Plugin::$option_name ); ?>"
     71            id="<?php echo \esc_attr( Plugin::$option_name ); ?>"
    6472            type="number"
    6573            min="1"
    66             value="<?php echo esc_attr( Plugin::$min_posts_count ); ?>"
     74            value="<?php echo (int) Plugin::$min_posts_count; ?>"
    6775            class="small-text"
    6876        />
    69         <?php esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
     77        <?php \esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
    7078        <?php
    7179    }
     
    94102    public function manage_tag_columns( $out, $column_name, $tag_ID ) {
    95103        if ( $column_name === 'active' ) {
    96             $term = get_term( $tag_ID );
    97             $out  = esc_html__( 'Live', 'fewer-tags' );
     104            $term = \get_term( $tag_ID );
     105            $out  = \esc_html__( 'Live', 'fewer-tags' );
    98106            if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
    99                 $out = '<span title="' . esc_html__( 'Not live due to not enough posts being in this tag.', 'fewer-tags' ) . '">' . esc_html__( 'Not live', 'fewer-tags' ) . '</span>';
     107                $out = '<span title="' . \esc_html__( 'Not live due to not enough posts being in this tag.', 'fewer-tags' ) . '">' . \esc_html__( 'Not live', 'fewer-tags' ) . '</span>';
    100108            }
    101109        }
     
    107115     * Removes the "View" action link for tags that have fewer than the minimum number of posts.
    108116     *
    109      * @param array   $actions An array of action links.
    110      * @param WP_Term $tag     Current WP_Term object.
     117     * @param array    $actions An array of action links.
     118     * @param \WP_Term $tag     Current WP_Term object.
    111119     *
    112120     * @return array Modified array of action links.
  • fewer-tags/trunk/src/class-frontend.php

    r3028877 r3111079  
    1515    /**
    1616     * Register the needed hooks.
     17     *
     18     * @return void
    1719     */
    1820    public function register_hooks() {
    19         add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
    20         add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
    21         add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
    22         add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
    23         add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
     21        \add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
     22        \add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
     23        \add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
     24        \add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
     25        \add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
     26        \add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
    2427    }
    2528
    2629    /**
    2730     * Redirect tag pages with fewer than the specified number of posts to the home page.
     31     *
     32     * @return void
    2833     */
    2934    public function redirect_tag_pages() {
    30         if ( is_tag() ) {
    31             $tag = get_queried_object();
     35        if ( \is_tag() ) {
     36            $tag = \get_queried_object();
    3237            if ( $tag && $tag->count < \FewerTags\Plugin::$min_posts_count ) {
    33                 wp_safe_redirect( home_url(), 301 );
     38                \wp_safe_redirect( \home_url(), 301 );
    3439                // @codeCoverageIgnoreStart
    3540                exit;
     
    4449     * Only works on post_tag taxonomy.
    4550     *
    46      * @param WP_Term[]|WP_Error $terms    Array of attached terms, or WP_Error on failure.
    47      * @param int                $post_id  Post ID.
    48      * @param string             $taxonomy Name of the taxonomy.
     51     * @param \WP_Term[]|\WP_Error $terms    Array of attached terms, or WP_Error on failure.
     52     * @param int                  $post_id  Post ID.
     53     * @param string               $taxonomy Name of the taxonomy.
    4954     *
    5055     * @return array The filtered array of term objects.
     
    5560        }
    5661
    57         if ( is_array( $terms ) ) {
     62        if ( \is_array( $terms ) ) {
    5863            foreach ( $terms as $key => $tag ) {
    5964                if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
     
    7479     */
    7580    public function filter_get_the_tags( $tags ) {
    76         if ( is_array( $tags ) ) {
     81        if ( \is_array( $tags ) ) {
    7782            foreach ( $tags as $key => $tag ) {
    7883                if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
     
    103108
    104109        // exclude terms with too few posts.
    105         $args['exclude'] = array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
     110        $args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
     111        return $args;
     112    }
     113
     114    /**
     115     * Excludes tags with fewer than the minimum number of posts from the Slim SEO sitemap.
     116     *
     117     * @param array $args The arguments for the sitemap query.
     118     *
     119     * @return array The modified arguments for the sitemap query.
     120     */
     121    public function exclude_tags_from_slim_seo_sitemap( $args ) {
     122        if ( ! isset( $args['exclude'] ) ) {
     123            $args['exclude'] = [];
     124        }
     125
     126        // exclude terms with too few posts.
     127        $args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
    106128        return $args;
    107129    }
     
    120142
    121143        // Fetch all tag IDs.
    122         $tag_ids = get_terms( $args );
     144        $tag_ids = \get_terms( $args );
    123145
    124146        // Filter tag IDs based on post count.
    125         $filtered_tag_ids = array_filter(
     147        $filtered_tag_ids = \array_filter(
    126148            $tag_ids,
    127149            function ( $tag_id ) {
    128                 $tag = get_term( $tag_id, 'post_tag' );
     150                $tag = \get_term( $tag_id, 'post_tag' );
    129151                return ( $tag->count < \FewerTags\Plugin::$min_posts_count );
    130152            }
     
    154176        $tags = get_terms( $args );
    155177
    156         if ( ! is_wp_error( $tags ) ) {
     178        if ( ! \is_wp_error( $tags ) ) {
    157179            foreach ( $tags as $tag_id ) {
    158                 $term = get_term( $tag_id );
     180                $term = \get_term( $tag_id );
    159181                if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
    160182                    $excluded_term_ids[] = $tag_id;
  • fewer-tags/trunk/src/class-playground.php

    r3009870 r3111079  
    1515    /**
    1616     * Register hooks.
     17     *
     18     * @return void
    1719     */
    1820    public function register_hooks() {
     
    2628    /**
    2729     * Print an admin notice helping people.
     30     *
     31     * @return void
    2832     */
    2933    public function admin_notices() {
     
    3842        echo '</p>';
    3943        echo '<p>';
    40         \esc_html_e( 'You can go to Settings → Reading to change how many tags a tag needs to have to be live on the site.', 'fewer-tags' );
     44        \esc_html_e( 'You can go to Settings → Reading to change how many posts a tag needs to have to be live on the site.', 'fewer-tags' );
    4145        echo '</p>';
    4246        echo '</div>';
     
    4549    /**
    4650     * Generate random posts & terms.
     51     *
     52     * @return void
    4753     */
    4854    public function generate_data() {
     
    6672     *
    6773     * @param string $common_tag Tag to attach to all posts.
     74     *
    6875     * @return int Post ID.
    6976     */
     
    8895     */
    8996    private function create_tag( $tag_name ) {
    90         if ( ! \term_exists( $tag_name, 'post_tag' ) ) {
     97        $term = \term_exists( $tag_name, 'post_tag' );
     98        if ( null === $term ) {
    9199            $term = \wp_insert_term( $tag_name, 'post_tag' );
    92             return $term['term_id'];
    93100        }
     101
     102        return $term['term_id'];
    94103    }
    95104
  • fewer-tags/trunk/src/class-plugin.php

    r3028877 r3111079  
    2929    /**
    3030     * Register plugin hooks.
     31     *
     32     * @return void
    3133     */
    3234    public function register_hooks() {
     
    3739    /**
    3840     * Initialize the plugin and register hooks.
     41     *
     42     * @return void
    3943     */
    4044    public function init() {
Note: See TracChangeset for help on using the changeset viewer.