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

Fix: Only variables should be passed by reference #369

Merged
merged 6 commits into from
Feb 16, 2024
Merged

Fix: Only variables should be passed by reference #369

merged 6 commits into from
Feb 16, 2024

Conversation

MARQAS
Copy link
Contributor

@MARQAS MARQAS commented Jan 26, 2024

Description of the Change

This PR fixes an issue where the plugin throws a warning in the label field while editing a label

Closes #357

How to test the Change

  1. Go to the Labels page
  2. Click on Edit label
  3. It should display the label value

Changelog Entry

Fixed - PHP warning while editing a label

Credits

Props @MARQAS , @felipeelia

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@@ -52,7 +52,7 @@ public function render_edit_label_page() {
<tr class="form-field form-required term-name-wrap">
<th scope="row"><label for="name">Label</label></th>
<td>
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( end( array_filter( explode( '/', $_GET['update_label'] ) ) ) ); ?>" size="40" aria-required="true"> <?php // phpcs:ignore WordPress.Security.NonceVerification ?>
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( basename( trim( $_GET['update_label'], '/' ) ) ); ?>" size="40" aria-required="true"> <?php // phpcs:ignore WordPress.Security.NonceVerification ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to assign its value to a variable anyway, @MARQAS? What if $_GET['update_label'] is not set?

<td>
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( end( array_filter( explode( '/', $_GET['update_label'] ) ) ) ); ?>" size="40" aria-required="true"> <?php // phpcs:ignore WordPress.Security.NonceVerification ?>
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( basename( trim( $label_name, '/' ) ) ); ?>" size="40" aria-required="true"> <?php // phpcs:ignore WordPress.Security.NonceVerification ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( basename( trim( $label_name, '/' ) ) ); ?>" size="40" aria-required="true"> <?php // phpcs:ignore WordPress.Security.NonceVerification ?>
<input name="label-update" id="name" type="text" value="<?php echo esc_attr( basename( trim( $label_name, '/' ) ) ); ?>" size="40" aria-required="true">

@MARQAS MARQAS merged commit 2dc8879 into develop Feb 16, 2024
11 checks passed
@MARQAS MARQAS deleted the fix/357 branch February 16, 2024 10:00
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

Successfully merging this pull request may close these issues.

Notice: Only variables should be passed by reference
2 participants