Skip to content

Commit

Permalink
Coding Standards: Cast wp_count_terms() result to int before usin…
Browse files Browse the repository at this point in the history
…g in `ceil()`.

This addresses two instances of the (numeric string) return value from `wp_count_terms()` being used directly in `ceil()`, which expects an `int|float`.

Affected methods:
* `WP_Sitemaps_Taxonomies::get_max_num_pages()`
* `wp_nav_menu_item_taxonomy_meta_box()`

Reference: [https://www.php.net/manual/en/function.ceil.php PHP Manual: ceil()].

Follow-up to [14248], [14291], [14569], [14943], [48072], [57648].

Props justlevine.
See #52217.

git-svn-id: https://develop.svn.wordpress.org/trunk@59462 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Nov 26, 2024
1 parent c344148 commit 520e61d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
}

$num_pages = (int) ceil(
wp_count_terms(
(int) wp_count_terms(
array_merge(
$args,
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function get_max_num_pages( $object_subtype = '' ) {

$term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) );

return (int) ceil( $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
return (int) ceil( (int) $term_count / wp_sitemaps_get_max_urls( $this->object_type ) );
}

/**
Expand Down

0 comments on commit 520e61d

Please sign in to comment.