Skip to content

Commit

Permalink
Fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
jdevalk committed Jul 2, 2024
2 parents 5af5fbf + 428f5b0 commit 37a881b
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/composer-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to make it possible to compare with PR base branch

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require-dev": {
"wp-coding-standards/wpcs": "^3.0",
"phpcompatibility/phpcompatibility-wp": "*",
"php-parallel-lint/php-parallel-lint": "^1.3",
"yoast/wp-test-utils": "^1.2",
"phpstan/phpstan": "^1.10",
"szepeviktor/phpstan-wordpress": "^1.3",
"phpstan/extension-installer": "^1.3"
"phpstan/extension-installer": "^1.3",
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99"
},
"scripts": {
"check-cs": [
Expand Down
69 changes: 53 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 14 additions & 14 deletions src/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class Admin {
* @return void
*/
public function register_hooks() {
add_action( 'admin_init', [ $this, 'register_settings' ] );
add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
add_filter( 'tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
\add_action( 'admin_init', [ $this, 'register_settings' ] );
\add_filter( 'manage_edit-post_tag_columns', [ $this, 'add_tag_columns' ] );
\add_filter( 'manage_post_tag_custom_column', [ $this, 'manage_tag_columns' ], 10, 3 );
\add_filter( 'tag_row_actions', [ $this, 'remove_view_action' ], 10, 2 );
}

/**
Expand All @@ -32,22 +32,22 @@ public function register_hooks() {
* @return void
*/
public function register_settings() {
add_settings_section(
\add_settings_section(
'fewer_tags_section',
__( 'Fewer Tags settings', 'fewer-tags' ),
[ $this, 'display_section' ],
'reading'
);

add_settings_field(
\add_settings_field(
Plugin::$option_name,
__( 'Tags need to have', 'fewer-tags' ),
[ $this, 'display_setting' ],
'reading',
'fewer_tags_section'
);

register_setting( 'reading', Plugin::$option_name );
\register_setting( 'reading', Plugin::$option_name );
}

/**
Expand All @@ -56,7 +56,7 @@ public function register_settings() {
* @return void
*/
public function display_section() {
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' );
\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' );
}

/**
Expand All @@ -67,14 +67,14 @@ public function display_section() {
public function display_setting() {
?>
<input
name="<?php echo esc_attr( Plugin::$option_name ); ?>"
id="<?php echo esc_attr( Plugin::$option_name ); ?>"
name="<?php echo \esc_attr( Plugin::$option_name ); ?>"
id="<?php echo \esc_attr( Plugin::$option_name ); ?>"
type="number"
min="1"
value="<?php echo (int) Plugin::$min_posts_count; ?>"
class="small-text"
/>
<?php esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
<?php \esc_html_e( 'posts before being live on the site.', 'fewer-tags' ); ?>
<?php
}

Expand All @@ -101,10 +101,10 @@ public function add_tag_columns( $columns ) {
*/
public function manage_tag_columns( $out, $column_name, $tag_ID ) {
if ( $column_name === 'active' ) {
$term = get_term( $tag_ID );
$out = esc_html__( 'Live', 'fewer-tags' );
$term = \get_term( $tag_ID );
$out = \esc_html__( 'Live', 'fewer-tags' );
if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
$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>';
$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>';
}
}

Expand Down
36 changes: 18 additions & 18 deletions src/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class Frontend {
* @return void
*/
public function register_hooks() {
add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
\add_action( 'template_redirect', [ $this, 'redirect_tag_pages' ] );
\add_filter( 'get_the_tags', [ $this, 'filter_get_the_tags' ] );
\add_filter( 'get_the_terms', [ $this, 'filter_get_the_terms' ], 10, 3 );
\add_filter( 'wpseo_exclude_from_sitemap_by_term_ids', [ $this, 'exclude_tags_from_yoast_sitemap' ] );
\add_filter( 'wp_sitemaps_taxonomies_query_args', [ $this, 'exclude_tags_from_core_sitemap' ], 10, 2 );
\add_filter( 'slim_seo_taxonomy_query_args', [ $this, 'exclude_tags_from_slim_seo_sitemap' ] );
}

/**
Expand All @@ -32,10 +32,10 @@ public function register_hooks() {
* @return void
*/
public function redirect_tag_pages() {
if ( is_tag() ) {
$tag = get_queried_object();
if ( \is_tag() ) {
$tag = \get_queried_object();
if ( $tag && $tag->count < \FewerTags\Plugin::$min_posts_count ) {
wp_safe_redirect( home_url(), 301 );
\wp_safe_redirect( \home_url(), 301 );
// @codeCoverageIgnoreStart
exit;
// @codeCoverageIgnoreEnd
Expand All @@ -59,7 +59,7 @@ public function filter_get_the_terms( $terms, $post_id, $taxonomy ) {
return $terms;
}

if ( is_array( $terms ) ) {
if ( \is_array( $terms ) ) {
foreach ( $terms as $key => $tag ) {
if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
unset( $terms[ $key ] );
Expand All @@ -78,7 +78,7 @@ public function filter_get_the_terms( $terms, $post_id, $taxonomy ) {
* @return array The filtered array of tag objects.
*/
public function filter_get_the_tags( $tags ) {
if ( is_array( $tags ) ) {
if ( \is_array( $tags ) ) {
foreach ( $tags as $key => $tag ) {
if ( $tag->count < \FewerTags\Plugin::$min_posts_count ) {
unset( $tags[ $key ] );
Expand Down Expand Up @@ -107,7 +107,7 @@ public function exclude_tags_from_core_sitemap( $args, $taxonomy ) {
}

// exclude terms with too few posts.
$args['exclude'] = array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
$args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
return $args;
}

Expand All @@ -124,7 +124,7 @@ public function exclude_tags_from_slim_seo_sitemap( $args ) {
}

// exclude terms with too few posts.
$args['exclude'] = array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
$args['exclude'] = \array_merge( $args['exclude'], $this->get_tag_ids_with_fewer_than_min_posts() );
return $args;
}

Expand All @@ -141,13 +141,13 @@ public function get_tag_ids_with_fewer_than_min_posts() {
];

// Fetch all tag IDs.
$tag_ids = get_terms( $args );
$tag_ids = \get_terms( $args );

// Filter tag IDs based on post count.
$filtered_tag_ids = array_filter(
$filtered_tag_ids = \array_filter(
$tag_ids,
function ( $tag_id ) {
$tag = get_term( $tag_id, 'post_tag' );
$tag = \get_term( $tag_id, 'post_tag' );
return ( $tag->count < \FewerTags\Plugin::$min_posts_count );
}
);
Expand Down Expand Up @@ -175,9 +175,9 @@ public function exclude_tags_from_yoast_sitemap( $excluded_term_ids ) {

$tags = get_terms( $args );

if ( ! is_wp_error( $tags ) ) {
if ( ! \is_wp_error( $tags ) ) {
foreach ( $tags as $tag_id ) {
$term = get_term( $tag_id );
$term = \get_term( $tag_id );
if ( $term->count < \FewerTags\Plugin::$min_posts_count ) {
$excluded_term_ids[] = $tag_id;
}
Expand Down

0 comments on commit 37a881b

Please sign in to comment.