Skip to content
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

Extend Gutenberg server rendering of templates and template parts for problem determination #41

Closed
3 tasks done
bobbingwide opened this issue Nov 21, 2020 · 2 comments
Closed
3 tasks done
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented Nov 21, 2020

While analysing the problems I came across with Gutenberg 9.4.0 I developed an extension to template-part.php which added debug information visible in the front end.
It sandwiched the output for each template part in some debug <div class="WP_DEBUG"> tags
which contained the name of the template part.

I then wrote some naff CSS to enable the information to be viewed on the front end.

image

Requirements

  • Formalise this solution for template parts
  • Find a method to automatically produce front end information regarding the template file that's been selected
  • Consider ways to easily turn the debug information on and off. e.g. Additional constant ( FSE_DEBUG), logged in admin user.
@bobbingwide bobbingwide added the enhancement New feature or request label Nov 21, 2020
@bobbingwide bobbingwide self-assigned this Nov 21, 2020
@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 22, 2020

Formalise solution for template parts

In Fizzie's template-part.php I changed the code to:

/**
  * Produce some visual aid to the theme developer, showing where the template starts and ends.
  *
  */
   if ( defined( 'FSE_DEBUG') && FSE_DEBUG ) {
       if (defined('WP_DEBUG') && WP_DEBUG) {
           $wrapped = "<div class=\"WP_DEBUG\">template part start: $slug</div>";
           $wrapped .= $content;
           $wrapped .= "<div class=\"WP_DEBUG END\">template part end: $slug</div>";
           $content = $wrapped;
           global $_wp_current_template_content;
           bw_trace2($_wp_current_template_content, "current template content", false, BW_TRACE_DEBUG);
       }
   }

Consider ways to easily turn the debug information on and off

I didn't bother to check if the user was logged in, nor if they had theme editing capability
just a check on FSE_DEBUG and WP_DEBUG.

Find a method to produce information for the template file

  • I couldn't see any easy way to extend Gutenberg code.
  • It'll have to be changed to fix issue Template hierarchy test cases #39 - Gutenberg issue 27177
  • So I'll just do something else for the time being.
<div class="WP_DEBUG">front-page.html</div>
  • Put a <div> with class="WP_DEBUG" into each template file.
  • Style the div on the front end with CSS.
  • Caveat: The Site editor can't handle classic blocks. But I'm not using the Site editor.

bobbingwide added a commit that referenced this issue Nov 25, 2020
…emplate part to home.html. Add some styling
@bobbingwide
Copy link
Owner Author

Since I started creating the SB-debug-block plugin, where I encountered a couple of problems, and since I've not done much work on the internationalization (i18n) of templates and template parts I haven't really put much thought into the debuggability of templates and template parts.

So I may as well close this issue. The last commit was delivered in v0.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant