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

Translation function calls must not contain PHP variables.... #416

Open
shuvo247 opened this issue Jan 21, 2022 · 1 comment
Open

Translation function calls must not contain PHP variables.... #416

shuvo247 opened this issue Jan 21, 2022 · 1 comment

Comments

@shuvo247
Copy link

shuvo247 commented Jan 21, 2022

RECOMMENDED: Possible variable $destination found in translation function in template-parts/common/category-bar.php. Translation function calls must not contain PHP variables, use placeholders instead. See Internationalization Guidelines (Opens in a new window).

Line 2: $destinations = get_terms(
Line 19: if ( ! empty( $destinations ) && is_array( $destinations ) ) {
Line 21: foreach ( $destinations as $destination ) { ?>
Line 24: $destination_info = get_term_meta( $destination->term_id, 'tourx_destinatio
Line 27: <a class='category-box' href='<?php echo esc_url( get_term_link( $destination ) ) ?>'>
Line 29: <img src='<?php echo $destination_info['destination_image']['url'] ?? ''?>' alt='<?php $destinat
Line 31: <?php if(!empty($destination->name)) : ?>
Line 32: <h5><?php echo __($destination->name) ?></h5>

How can I fix this issue?

@carolinan
Copy link
Collaborator

carolinan commented Jan 22, 2022

Hi!
The internationalization guidelines, which are linked in the message, explains why using PHP variables or dynamic content this way does not work:
https://developer.wordpress.org/apis/handbook/internationalization/internationalization-guidelines/#variables
gettext can not know what "$destination->name" is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants