Hello,
Pinegrow WP works well even on complex custom theme development projects, and lets you add custom PHP (PHP that’s not available as built-in actions) to templates multiple ways. For example, this guide suggests to use the ‘Function’ global smart action (either by adding simple custom code, or by calling a named function that lives in ‘/inc/custom.php’): Adding custom PHP code | Pinegrow Web Editor
My problem is, that sometimes I need to add multi-line custom PHP to templates (e.g. for declaring variables), and I can’t / don’t want to use named functions. In this cases, the ‘Function’ global smart action’s PHP editor window is very limited, and the code neither is optimal to write in VSCode (because of PG WP project files being html by default). I send you a screenshot to illustrate my current workflow as an example (adding a <div>
, and putting a ‘Function’ on it with custom PHP code to replace the element):
I can work around the issue by e.g. using PHP include / require statements for larger PHP code blocks like the one above (and only write the include statement within PG), but that requires a lot of extra steps. Regarding this, I’ve a couple of questions:
- Can’t I just enable Server-side scripts within Pinegrow on WP projects, and set PG WP project files’ extensions to PHP instead of HTML, so that I can use simple PHP blocks with all the advantages?
- The latter I tried, but didn’t seemed to work well (as Page settings options seemed to break / change).
- I’m very interested in what you suggest me to do in orther to be able to use PG WP up to its full potential, while still being able to write PHP code with syntax highlighting and indenting (in VSCode) when needed? Maybe there’s already a better way, which I don’t know.
(I remember there was an old tutorial on your website on using ACF Flexible content which used native PHP blocks within a template as I recall, but I’m not sure that’s possible with current versions of Pinegrow.)
Thank you for your suggestions and tips in advance!
Best,
Márton Lente