bobbingwide / fizzie

Fizzie theme - a Full Site Editing theme using Gutenberg blocks
9 stars 1 forks source link

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

Closed bobbingwide closed 1 year ago

bobbingwide commented 3 years ago

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

bobbingwide commented 3 years ago

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

<div class="WP_DEBUG">front-page.html</div>
bobbingwide commented 1 year ago

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.