Skip to content

Conversation

@DAnn2012
Copy link
Contributor

@DAnn2012 DAnn2012 commented Sep 23, 2025

Added echo in pos.php

Summary by CodeRabbit

  • Bug Fixes
    • Fixed the page title so the translated "Point of Sale" and the site name reliably appear and are properly escaped. This prevents missing or malformed titles in browser tabs, bookmarks, and search results, improving readability, branding, and SEO without affecting layout or performance.

@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Changed title rendering in templates/pos.php: swapped esc_attr_e for esc_html_e and replaced esc_html( bloginfo('name') ) with echo esc_html( bloginfo('name') ) to correctly escape and output the site name.

Changes

Cohort / File(s) Summary of Changes
Template Title Output
templates/pos.php
Title rendering fixed: use esc_html_e() for the translated literal and explicitly echo esc_html( bloginfo('name') ) to correctly escape and output the site name (avoids using bloginfo() inside esc_html()).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A nibble of code beneath moon's glow,
Titles now clean, no stray echo.
Escaped and echoed, tidy and bright,
My paws applaud this little fix tonight. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "Added echo in pos.php" concisely and accurately captures a real, central change in the diff (an explicit echo was added in templates/pos.php along with related escaping adjustments). It is specific to the affected file, not vague or noisy, and would be understandable to a teammate scanning PR history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efafbea and 2c5f647.

📒 Files selected for processing (1)
  • templates/pos.php (1 hunks)
🔇 Additional comments (1)
templates/pos.php (1)

14-14: Fix escaping: replace bloginfo() with get_bloginfo(); current code outputs the site name unescaped.

bloginfo() echoes before escaping, so the site title is printed unescaped and echo esc_html( bloginfo(...) ) then echoes an empty string. Use get_bloginfo() and escape its return value.

Apply this fix (Option A – minimal change):

-    <title><?php esc_html_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
+    <title><?php esc_html_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( get_bloginfo( 'name' ) ); ?></title>

Optional (Option B – better i18n with reorderable string):

-    <title><?php esc_html_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
+    <title><?php printf( esc_html__( 'Point of Sale - %s', 'woocommerce-pos' ), esc_html( get_bloginfo( 'name' ) ) ); ?></title>

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
templates/pos.php (1)

14-14: i18n: Allow translators to reorder title parts.

Use a translatable pattern with placeholders.

-	<title><?php esc_attr_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
+	<title><?php printf( esc_html__( '%1$s - %2$s', 'woocommerce-pos' ), esc_html__( 'Point of Sale', 'woocommerce-pos' ), esc_html( get_bloginfo( 'name' ) ) ); ?></title>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30c0481 and efafbea.

📒 Files selected for processing (1)
  • templates/pos.php (1 hunks)

<html>
<head>
<title><?php esc_attr_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php esc_html( bloginfo( 'name' ) ); ?></title>
<title><?php esc_attr_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix escaping: bloginfo() echoes before escaping; use get_bloginfo(). Also use esc_html_e() (not esc_attr_e()) in text nodes.

Current code prints the site name unescaped and echoes an empty string. Replace with the safe, correct variant below.

-	<title><?php esc_attr_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
+	<title><?php esc_html_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( get_bloginfo( 'name' ) ); ?></title>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<title><?php esc_attr_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( bloginfo( 'name' ) ); ?></title>
<title><?php esc_html_e( 'Point of Sale', 'woocommerce-pos' ); ?> - <?php echo esc_html( get_bloginfo( 'name' ) ); ?></title>
🤖 Prompt for AI Agents
In templates/pos.php around line 14, the title tag misuses escaping: it calls
esc_attr_e (meant for attributes) and uses bloginfo() which echoes before
escaping. Replace esc_attr_e with esc_html_e for the visible text and replace
bloginfo() with get_bloginfo() wrapped in esc_html() so the site name is
retrieved then safely escaped (i.e., output esc_html_e('Point of
Sale','woocommerce-pos') followed by ' - ' . esc_html( get_bloginfo('name') )).

@kilbot kilbot merged commit 2d2858d into wcpos:main Sep 24, 2025
1 check passed
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.

2 participants