Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@MdAsifHossainNadim
Copy link
Contributor

@MdAsifHossainNadim MdAsifHossainNadim commented Oct 16, 2025

All Submissions:

  • My code follow the WordPress' coding standards
  • My code satisfies feature requirements
  • My code is tested
  • My code passes the PHPCS tests
  • My code has proper inline documentation
  • I've included related pull request(s) (optional)
  • I've included developer documentation (optional)
  • I've added proper labels to this pull request

Changes proposed in this Pull Request:

Related Pull Request(s)

  • Full PR Link

Closes

How to test the changes in this Pull Request:

  • Steps or issue link

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:

  • Code is not following code style guidelines
  • Bad naming: make sure you would understand your code if you read it a few months from now.
  • KISS: Keep it simple, Sweetie (not stupid!).
  • DRY: Don't Repeat Yourself.
  • Code that is not readable: too many nested 'if's are a bad sign.
  • Performance issues
  • Complicated constructions that need refactoring or comments: code should almost always be self-explanatory.
  • Grammar errors.

FOR PR REVIEWER ONLY:

As a reviewer, your feedback should be focused on the idea, not the person. Seek to understand, be respectful, and focus on constructive dialog.

As a contributor, your responsibility is to learn from suggestions and iterate your pull request should it be needed based on feedback. Seek to collaborate and produce the best possible contribution to the greater whole.

  • Correct — Does the change do what it’s supposed to? ie: code 100% fulfilling the requirements?
  • Secure — Would a nefarious party find some way to exploit this change? ie: everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities?
  • Readable — Will your future self be able to understand this change months down the road?
  • Elegant — Does the change fit aesthetically within the overall style and architecture?

Summary by CodeRabbit

  • New Features
    • Added full-width dashboard layout support for seller dashboards, providing an optimized viewing experience when custom dashboard templates are available.

@MdAsifHossainNadim MdAsifHossainNadim self-assigned this Oct 16, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 16, 2025

Walkthrough

A 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 (block-dashboard.php) when conditions are met, while maintaining WordPress hook execution and content rendering.

Changes

Cohort / File(s) Summary
Dashboard Class Enhancement
includes/Shortcodes/Dashboard.php
Added public __construct() that hooks template_redirect action to trigger template rewriting. Added rewrite_vendor_dashboard_template() method that intercepts dashboard rendering for logged-in users viewing the seller dashboard, loading a custom template and exiting to prevent default theme rendering.
Full-Width Dashboard Template
templates/dashboard/block-dashboard.php
New full-width template file for Dokan dashboard with standard WordPress lifecycle (wp_head, wp_body_open, wp_footer), direct access prevention, post-loop content rendering, and noindex/nofollow robots meta tag.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

The changes introduce a new template override mechanism via template_redirect hook requiring careful review of condition logic and template lifecycle, coupled with a new template file that must be validated for proper WordPress hook execution and content rendering.

Poem

🐰 Hops forth with joy, the dashboard transforms anew,
Full-width and custom, with hooks running true,
Constructor and template dance in the theme,
Vendor dashboards now shimmer—a developer's dream!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The pull request description follows the template structure and includes all sections, but most critical content areas are either empty or contain only placeholder text. The "Changes proposed in this Pull Request" section, which should describe the modifications being made, is completely empty with no explanation of the feature implementation. Similarly, the "How to test the changes" section only contains a placeholder with no actual testing steps, and the "Changelog entry," "Before Changes," and "After Changes" sections contain only template text rather than substantive content. The only filled sections are the checklist marks and the closed issue reference (#1046). Without these key details, reviewers lack essential context to understand what changes are being introduced, their rationale, how to verify them, and what behavioral differences to expect. The author should complete the following critical sections before merging: add a detailed description under "Changes proposed in this Pull Request" explaining the full-width template support feature and the rationale behind the implementation; provide concrete testing steps under "How to test the changes"; fill in the "Changelog entry" with an actual title and description of the change; and add "Before Changes" and "After Changes" descriptions with relevant details or screenshots to illustrate the improvement. These additions will provide reviewers with the necessary context to properly evaluate the pull request.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "enhance: Full-width template support for Dokan dashboard page." is directly related to the main changes in the pull request. The changeset adds a constructor and rewrite method to the Dashboard class to implement full-width template support, along with introducing a new full-width template file (block-dashboard.php) for the dashboard. The title clearly and concisely captures this primary objective without unnecessary noise or vague phrasing, making it easy for teammates to understand the core purpose when scanning commit history.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enhance/add-custom-dokan-dashboard-full-width-layout

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
Contributor

@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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 42bb6ba and 866d4da.

📒 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, nofollow directives 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: The templates/dashboard/full-dashboard.php file is present (62 lines); no further action needed.

…proach and replace full-dashboard template with block-dashboard template
Copy link
Contributor

@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

♻️ Duplicate comments (2)
templates/dashboard/block-dashboard.php (1)

8-8: Replace the DOKAN_SINCE placeholder with the actual version number.

The @since tag 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 @since tag 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

📥 Commits

Reviewing files that changed from the base of the PR and between 186b791 and 9b1bed1.

📒 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 defensive function_exists() check for wp_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 checking have_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. The template_redirect hook with priority 1 ensures early interception before theme template selection.

@getdokan getdokan deleted a comment from coderabbitai bot Oct 21, 2025
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.

1 participant