Skip to content

Commit

Permalink
Relax WP_Term arg type in slugs (#1314)
Browse files Browse the repository at this point in the history
The WordPress hook documentation is not very precise, giving WP_Term
but it can be other than this in some cases.
  • Loading branch information
herrvigg committed Apr 10, 2023
1 parent 17b43b5 commit 4332d94
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/admin/admin_taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ function qtranxf_term_set_translation( int $term_id, int $tt_id, string $taxonom

add_action( 'created_term', 'qtranxf_term_set_translation', 5, 3 );
add_action( 'edited_term', 'qtranxf_term_set_translation', 5, 3 );

function qtranxf_term_delete( int $term, int $tt_id, string $taxonomy, WP_Term $deleted_term, array $object_ids ): void {
;
function qtranxf_term_delete( int $term, int $tt_id, string $taxonomy, $deleted_term, array $object_ids ): void {
global $q_config;
if ( isset( $deleted_term->i18n_config['name'] ) ) {
$default_language = $q_config['default_language'];
Expand Down
6 changes: 3 additions & 3 deletions src/modules/slugs/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function qtranxf_slugs_sanitize_term_slug( $slug, $term, $lang ) {
*
* @since 1.0
*/
function qtranxf_slugs_unique_term_slug( string $slug, WP_Term $term, string $lang ): string {
function qtranxf_slugs_unique_term_slug( string $slug, $term, string $lang ): string {
global $wpdb;

$query = $wpdb->prepare( "SELECT term_id FROM $wpdb->termmeta WHERE meta_key = '%s' AND meta_value = '%s' AND term_id != %d ", QTX_SLUGS_META_PREFIX . $lang, $slug, $term->term_id );
Expand Down Expand Up @@ -392,7 +392,7 @@ function qtranxf_slugs_save_term( int $term_id, int $tt_id, $taxonomy ): void {
*
* @return void
*/
function qtranxf_slugs_show_list_term_fields( ?WP_Term $term ): void {
function qtranxf_slugs_show_list_term_fields( $term ): void {
global $q_config;

$flag_location = qtranxf_flag_location(); ?>
Expand Down Expand Up @@ -428,7 +428,7 @@ function qtranxf_slugs_show_add_term_fields(): void {
*
* @param WP_Term $term the term object
*/
function qtranxf_slugs_show_edit_term_fields( WP_Term $term ): void {
function qtranxf_slugs_show_edit_term_fields( $term ): void {
?>
<tr class="form-field term-slug-wrap">
<th><?php _e( 'Slugs per language', 'qtranslate' ) ?></th>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/slugs/slugs.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,13 @@ public function _get_page_link( string $link, int $id ): string {
* Filter that translates the slug parts in a term link.
*
* @param string $link the link for the page generated by Wordpress
* @param WP_Term $term
* @param WP_Term|object $term
* @param object $taxonomy
*
* @return string|WP_Error the link translated
*/
//TODO: review this function vs get_term_link(), e.g. checks and error handling may be unneeded here
public function term_link( string $link, WP_Term $term, $taxonomy ) {
public function term_link( string $link, $term, $taxonomy ) {
global $wp_rewrite;

// parse normal term names for ?tag=tagname
Expand Down
2 changes: 1 addition & 1 deletion src/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function qtranxf_useTermLib( $obj ) {
* @since 3.4.6.9
*
*/
function qtranxf_term_name_in( string $lang, WP_Term $term ): string {
function qtranxf_term_name_in( string $lang, $term ): string {
if ( isset( $term->i18n_config['name']['ts'][ $lang ] ) ) {
return $term->i18n_config['name']['ts'][ $lang ];
}
Expand Down

0 comments on commit 4332d94

Please sign in to comment.