-
Notifications
You must be signed in to change notification settings - Fork 35
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
Required code for Stripe redirect in new tab fix #2014
base: master
Are you sure you want to change the base?
Conversation
WalkthroughThe changes involve modifications to the visibility of a static variable and a method within the Changes
Possibly related PRs
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🔇 Additional comments (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
classes/controllers/FrmFormsController.php (3)
Line range hint
2742-2757
: Function visibility changed to public.The
print_open_in_new_tab_js_with_fallback_handler
function has been made public. While this change may be intentional to allow external access, it's important to consider the implications:
- Increased exposure of internal functionality.
- Potential security risks if the function is not meant to be called directly from outside the class.
- Backwards compatibility concerns if this was previously used as a private method.
Ensure that this change aligns with the intended use of the function and doesn't introduce any security vulnerabilities.
Line range hint
2742-2757
: Consider improving JavaScript handling and security.While the function achieves its purpose, there are several areas for potential improvement:
Inline JavaScript: Consider moving the JavaScript to a separate file and enqueuing it properly. This adheres to best practices and improves security.
Global variable usage: The
frmShowNewTabFallback
global variable could potentially conflict with other scripts. Consider using a namespace or a more specific variable name.No fallback for disabled JavaScript: The function doesn't handle cases where JavaScript is disabled in the browser. Consider adding a noscript fallback.
Error handling: The function could benefit from more robust error handling and user feedback mechanisms.
Example improvement:
public static function print_open_in_new_tab_js_with_fallback_handler( $success_url, $args ) { $fallback_data = array( 'formId' => intval( $args['form']->id ), 'message' => self::get_redirect_fallback_message( $success_url, $args ), ); wp_localize_script( 'frm-new-tab-handler', 'frmNewTabData', $fallback_data ); echo '<a href="' . esc_url( $success_url ) . '" target="_blank" class="frm-new-tab-link">' . esc_html__( 'Click here if not redirected', 'formidable' ) . '</a>'; echo '<noscript><meta http-equiv="refresh" content="0;url=' . esc_url( $success_url ) . '"></noscript>'; }This suggestion separates concerns, improves security, and provides a fallback for users with JavaScript disabled.
Line range hint
1-3019
: Overall file review: FrmFormsController.phpThis file contains the FrmFormsController class, which appears to be a core component of the Formidable Forms plugin. While the main change reviewed was the
print_open_in_new_tab_js_with_fallback_handler
function, it's important to note:
Code Complexity: The file is quite large and complex. Consider breaking it down into smaller, more manageable classes or modules to improve maintainability.
Deprecated Methods: There are deprecated methods at the end of the file. Consider removing these in future versions to clean up the codebase.
Security: Ensure that all user inputs are properly sanitized and validated throughout the file, especially in form submission handling.
Performance: Given the complexity of the class, it might be worth profiling to identify any performance bottlenecks, especially in form processing methods.
Documentation: While there are some inline comments, the file could benefit from more comprehensive documentation, especially for complex methods.
Testing: Ensure that unit tests cover the changed functionality, particularly the new public method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes something public.