Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PHPCompatibility to dev #29

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 11 additions & 11 deletions src/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ 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_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 );
}

/**
Expand All @@ -31,10 +31,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 @@ -58,7 +58,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 @@ -77,7 +77,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 @@ -106,7 +106,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 Down
Loading