-
Notifications
You must be signed in to change notification settings - Fork 216
enhance: Full-width template support for Dokan dashboard page. #2938
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
base: develop
Are you sure you want to change the base?
enhance: Full-width template support for Dokan dashboard page. #2938
Conversation
WalkthroughA constructor and template interception mechanism are added to the Dashboard shortcode class, enabling it to override vendor dashboard rendering with a custom full-width template ( Changes
Sequence DiagramsequenceDiagram
participant WP as WordPress
participant DPC as Dashboard Plugin<br/>Constructor
participant DR as template_redirect<br/>Hook
participant RVD as rewrite_vendor_<br/>dashboard_template()
participant TPL as Template
rect rgba(240, 248, 255, 0.3)
Note over WP,TPL: Old Flow (without changes)
WP->>WP: Load theme template
WP->>TPL: Render standard template
end
rect rgba(144, 238, 144, 0.3)
Note over WP,TPL: New Flow (with changes)
WP->>DPC: Instantiate Dashboard
DPC->>DR: Register template_redirect hook
WP->>DR: Trigger template_redirect action
DR->>RVD: Execute rewrite_vendor_dashboard_template()
alt User logged in AND viewing seller dashboard
RVD->>TPL: Load block-dashboard.php
TPL->>WP: Render full-width template with hooks
RVD->>WP: Exit (prevent default rendering)
else Conditions not met
RVD->>WP: Continue normal flow
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes The changes introduce a new template override mechanism via Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 5
🧹 Nitpick comments (1)
includes/Shortcodes/Dashboard.php (1)
32-47: Add a filter to allow template path customization.The template path is hardcoded, limiting extensibility. Consider adding a filter to allow developers to customize or override the template path.
public function load_fullwidth_template( $template ) { // Check if we should load the fullwidth template if ( ! dokan_is_seller_dashboard() ) { return $template; } // Path to custom template $custom_template = DOKAN_DIR . '/templates/dashboard/full-dashboard.php'; + + // Allow developers to customize the template path + $custom_template = apply_filters( 'dokan_fullwidth_dashboard_template', $custom_template ); // Check if custom template exists if ( file_exists( $custom_template ) ) { return $custom_template; } return $template; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
includes/Shortcodes/Dashboard.php(1 hunks)templates/dashboard/full-dashboard.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
includes/Shortcodes/Dashboard.php (2)
includes/Rewrites.php (1)
__construct(18-33)includes/functions.php (1)
dokan_is_seller_dashboard(148-166)
🪛 GitHub Actions: Inspections
templates/dashboard/full-dashboard.php
[error] 1-1: PHPCS: Doc comment short description must start with a capital letter. (vendor/bin/phpcs ...)
includes/Shortcodes/Dashboard.php
[error] 1-1: PHPCS: Doc comment short description must start with a capital letter. (vendor/bin/phpcs ...)
🪛 GitHub Check: Run PHPCS inspection
templates/dashboard/full-dashboard.php
[failure] 55-55:
Doc comment short description must start with a capital letter
[failure] 37-37:
Doc comment short description must start with a capital letter
[failure] 27-27:
Doc comment short description must start with a capital letter
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: api tests (1, 1)
- GitHub Check: e2e tests (2, 3)
- GitHub Check: e2e tests (3, 3)
- GitHub Check: e2e tests (1, 3)
🔇 Additional comments (4)
templates/dashboard/full-dashboard.php (2)
24-24: Review the noindex/nofollow meta tag.The
noindex, nofollowdirectives prevent search engines from indexing the dashboard page, which is appropriate for a seller dashboard. However, verify this aligns with your SEO requirements.
44-52: LGTM! Content rendering preserves WordPress loop.The implementation correctly wraps
the_content()within the WordPress loop, ensuring proper post context and content filters are applied.includes/Shortcodes/Dashboard.php (2)
34-36: LGTM! Proper context check using existing function.The use of
dokan_is_seller_dashboard()ensures the fullwidth template is only loaded in the appropriate context, preventing interference with other pages.
38-44: Confirm template file presence: Thetemplates/dashboard/full-dashboard.phpfile is present (62 lines); no further action needed.
…mplate hooks documentation
…proach and replace full-dashboard template with block-dashboard template
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: 1
♻️ Duplicate comments (2)
templates/dashboard/block-dashboard.php (1)
8-8: Replace the DOKAN_SINCE placeholder with the actual version number.The
@sincetag contains a placeholder that should be replaced with the actual version number when this feature is released.includes/Shortcodes/Dashboard.php (1)
30-30: Replace the DOKAN_SINCE placeholder with the actual version number.The
@sincetag contains a placeholder that should be replaced with the actual version number when this feature is released.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
includes/Shortcodes/Dashboard.php(1 hunks)templates/dashboard/block-dashboard.php(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
includes/Shortcodes/Dashboard.php (1)
includes/functions.php (1)
dokan_is_seller_dashboard(148-166)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: e2e tests (3, 3)
- GitHub Check: e2e tests (2, 3)
- GitHub Check: e2e tests (1, 3)
- GitHub Check: api tests (1, 1)
🔇 Additional comments (5)
templates/dashboard/block-dashboard.php (4)
19-36: LGTM!The HTML head structure is correct, with proper meta tags, and the
wp_head()hook is correctly positioned to ensure all enqueued scripts and styles load.
37-50: LGTM!The body tag setup is correct, with proper use of
body_class()for styling hooks and a defensivefunction_exists()check forwp_body_open()to ensure compatibility with older WordPress versions.
54-57: Verify the loop is ready before rendering.The template assumes the WordPress loop has posts and hasn't been consumed. If the loop was already iterated elsewhere before this template loads, or if the query wasn't set up properly, this will render nothing silently.
Consider adding
rewind_posts()before the loop or checkinghave_posts()with an else clause:<?php // Render the page content (which contains the shortcode) + if ( have_posts() ) { + rewind_posts(); // Ensure loop is reset - while ( have_posts() ) : - the_post(); - the_content(); - endwhile; + while ( have_posts() ) : + the_post(); + the_content(); + endwhile; + } else { + echo '<p>' . esc_html__( 'No content found.', 'dokan-lite' ) . '</p>'; + } ?>
60-72: LGTM!The footer structure is correct with
wp_footer()properly positioned before the closing body tag to ensure all footer scripts load.includes/Shortcodes/Dashboard.php (1)
11-22: LGTM!The constructor correctly implements an opt-out filter (
dokan_vendor_dashboard_enable_full_width_page) as suggested in previous review comments, allowing developers to disable the full-width template feature. Thetemplate_redirecthook with priority 1 ensures early interception before theme template selection.
All Submissions:
Changes proposed in this Pull Request:
Related Pull Request(s)
Closes
How to test the changes in this Pull Request:
Changelog entry
Title
Detailed Description of the pull request. What was previous behaviour
and what will be changed in this PR.
Before Changes
Describe the issue before changes with screenshots(s).
After Changes
Describe the issue after changes with screenshot(s).
Feature Video (optional)
Link of detailed video if this PR is for a feature.
PR Self Review Checklist:
FOR PR REVIEWER ONLY:
Summary by CodeRabbit