Add WooCommerce My Account Customizations#1
Add WooCommerce My Account Customizations#1krugazul wants to merge 1 commit intosetup/initial-configfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
Note
|
Summary of ChangesHello @krugazul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the WooCommerce My Account experience by introducing a dedicated class for comprehensive customization. It renames key navigation items, removes irrelevant sections, and integrates new custom pages, providing a more tailored and streamlined user interface for account management. The changes are designed to be easily extensible, allowing for future content integration via action hooks. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces customizations for the WooCommerce My Account page by adding a new My_Account class. The changes include renaming, disabling, and adding new menu endpoints. The implementation is mostly solid, but there is a critical issue with how rewrite rules are flushed on plugin activation. The current approach uses the activated_plugin hook incorrectly, which can lead to performance problems on the site. My review includes a detailed explanation of the issue and a recommendation for the correct implementation using register_activation_hook.
| // Flush rewrite rules on plugin activation (use WordPress activation hooks). | ||
| add_action( 'activated_plugin', array( $this, 'flush_rewrite_rules' ) ); |
There was a problem hiding this comment.
Using the activated_plugin hook to flush rewrite rules is incorrect and can cause site-wide performance issues. This hook fires when any plugin is activated, not just yours, leading to frequent and unnecessary calls to the expensive flush_rewrite_rules() function.
The standard WordPress approach is to use register_activation_hook() in your main plugin file (ma-plugin.php). This hook should be removed from this class and the logic moved to the main plugin file.
| public function flush_rewrite_rules() { | ||
| $this->register_custom_endpoints(); | ||
| flush_rewrite_rules(); | ||
| } |
There was a problem hiding this comment.
This method is related to the incorrect activated_plugin hook and should be removed from this class. The logic for flushing rewrite rules should be moved to an activation hook in the main plugin file, as mentioned in the other comment. This will ensure that rewrite rules are flushed only when your plugin is activated.
Overview
This PR adds a new
My_Accountclass to customize WooCommerce My Account endpoints.Changes Made
New Files
Modified Files
Features Implemented
✅ Renamed Endpoints
✅ Disabled Endpoints
✅ New Custom Endpoints
Implementation Details
The
My_Accountclass:woocommerce_account_menu_itemsfilter to customize menu itemsPost-Merge Steps
After merging and activating the plugin:
ma_plugin_cpd_points_contentandma_plugin_multi_page_report_contentaction hooks to add custom contentTesting