PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
← All changes | app/Shortcodes/LoginShortcode.php +26 -4 3.0.3trunk View file →
@@ -50,17 +50,26 @@
50 50 // Enqueue JavaScript
51 51 wp_enqueue_script(
52 52 'yatra-login-shortcode',
53 53 YATRA_PLUGIN_URL . 'assets/js/login-shortcode.js',
54 - ['jquery'],
54 + ['jquery', 'wp-i18n'],
55 55 YATRA_VERSION,
56 56 true
57 57 );
58 + if (function_exists('wp_set_script_translations')) {
59 + wp_set_script_translations(
60 + 'yatra-login-shortcode',
61 + 'yatra',
62 + YATRA_PLUGIN_PATH . 'i18n/languages'
63 + );
64 + }
58 65
59 66 // Localize script for AJAX with security and debugging
60 67 wp_localize_script('yatra-login-shortcode', 'yatra_ajax', [
61 68 'ajax_url' => admin_url('admin-ajax.php'),
62 69 'nonce' => wp_create_nonce('yatra_login_nonce'),
70 + 'rest_url' => esc_url_raw(rest_url('yatra/v1')),
71 + 'rest_nonce' => wp_create_nonce('wp_rest'),
63 72 'debug' => defined('WP_DEBUG') && WP_DEBUG,
64 73 'strings' => [
65 74 'login_error' => __('Login failed. Please try again.', 'yatra'),
66 75 'network_error' => __('Network error. Please check your connection.', 'yatra'),
@@ -74,12 +83,24 @@
74 83 */
75 84 protected function renderContent(array $atts): string
76 85 {
77 86 $atts = shortcode_atts($this->default_attributes, $atts, $this->tag);
78 -
87 +
79 88 // Sanitize and validate attributes
80 89 $atts = $this->sanitizeAttributes($atts);
81 -
90 +
91 + // Translate the built-in default title/subtitle at render time. The
92 + // defaults are stored as raw English in the constructor because __()
93 + // must not run that early (before init) — doing so triggers WordPress's
94 + // just-in-time textdomain notice. A custom title/subtitle set by the
95 + // operator on the shortcode passes through unchanged.
96 + if ($atts['title'] === 'Customer Login') {
97 + $atts['title'] = __('Customer Login', 'yatra');
98 + }
99 + if ($atts['subtitle'] === 'Login to access your bookings and account') {
100 + $atts['subtitle'] = __('Login to access your bookings and account', 'yatra');
101 + }
102 +
82 103 // Check if user is already logged in
83 104 if (is_user_logged_in()) {
84 105 return $this->renderLoggedInMessage($atts);
85 106 }
@@ -131,10 +152,11 @@
131 152 <?php echo yatra_svg_icon('user', 'yatra-logged-in-icon-svg'); ?>
132 153 </div>
133 154 <h3><?php esc_html_e('Already Logged In', 'yatra'); ?></h3>
134 155 <p>
135 - <?php
156 + <?php
136 157 printf(
158 + /* translators: %s: logged-in user's display name. */
137 159 esc_html__('You are logged in as %s.', 'yatra'),
138 160 '<strong>' . esc_html($user->display_name) . '</strong>'
139 161 );
140 162 ?>