Pijushgupta / avif-express

Wordpress plugin to convert jpg,png and webp to avif and render them
GNU General Public License v2.0
3 stars 2 forks source link

Body class disappear #6

Closed Troglos closed 1 month ago

Troglos commented 1 month ago

When logged in, the body class disappear.

Not logged: Logged:

Pijushgupta commented 1 month ago

When logged in, the body class disappear.

Not logged: Logged:

can you please describe little more about the issue ?

Troglos commented 1 month ago

Sorry the editor stripped the code.

The problem I was having was: When I am not logged in the body has the correct classes handled by WP: es. home page-template-default page page-id-2 When I am logged as admin the body has no classes

By the way I just found the cause, it was this function in my custom theme:

if (current_user_can('manage_options')) { add_action('wp_head', 'show_template'); function show_template() { global $template; print_r($template); } }

Pijushgupta commented 1 month ago

Sorry the editor stripped the code.

The problem I was having was: When I am not logged in the body has the correct classes handled by WP: es. home page-template-default page page-id-2 When I am logged as admin the body has no classes

By the way I just found the cause, it was this function in my custom theme:

if (current_user_can('manage_options')) { add_action('wp_head', 'show_template'); function show_template() { global $template; print_r($template); } }

how it is related to avif-express? Is this something to do with rendering html.php

Troglos commented 1 month ago

When avif-express is activated and rendering is Active, with that function uncommented I have the issue. If rendering is Inactive or if I comment that code the issue disappear. Anyway it's not a big deal, because I can easily comment that function on a live site.

Pijushgupta commented 1 month ago

So it not related to avif-express code? We are doing the rendering at the very last moment html.php on line 15 then using output buffer on line 19.

To use your custom code while plugins rendering is active try giving print_r() a second parameter with the value 'true'. By setting the second parameter to true, print_r will return the output as a string instead of printing it directly. if (current_user_can('manage_options')) { add_action('wp_head', 'show_template'); } function show_template() { global $template; print_r($template,true); }

Troglos commented 1 month ago

For styling purpose I use a div to wrap print_r($template), so your suggestion unfortunately doesn't work. I solved replacing wp_head with wp_footer. Thank you for the input