One more thing …

“With the very next version of Pinegrow coming shortly, both the inc folder and the custom.php file will be automatically created by Pinegrow, so you will just have to focus on adding awesome functions to your theme.”

Just wanted to extend an enormous THANK YOU!! to the Pinegrow Pro WP Team for taking the time to add UX features such as this. Your attention to small details within the app is certainly appreciated :relieved:

3 Likes

does this mean if i have php at the tippy top of one of my website pages (above the <head> section) that PG will stop updating this code away every time i make a change to the master page?

it’s getting to be pretty annoying re-pasting it back in every time.

I was referring to adding features and functionality to your WordPress theme by using code snippets, there’s a reference in regards to creating custom.php separately as an include for functions.php that’ll prevent custom code lost upon export and updates, but soon Pinegrow will integrate this feature to automate the workflow process that’ll save us a boat load of time and frustration having to recall it from memory or other themes/templates. :+1:t4:

i might be talking about the same thing, it’s hard for me to tell as i’m not a wp user and only newly accomplished php coder.

my website uses the Post Redirect Get (PRG) architecture which (as far as i can tell) requires my Post and Redirect code to be above all other html in the page, then upon the Get pass it falls thru all that code and digs into the html where the Get is handled.

my problem is all that code before the <!DOCTYPE html> gets deleted because it’s not on the master page definition, and there is no way to set up an editable area above the document.

unless i’m missing something, which is totally possible.

@droidgoo you could add the code to the master page and then conditionally include appropriate php file to handle individual pages, for example:

<?php require_once "my_code.php"; ?>
<!DOCTYPE html>...

and then in my_code.php:

<?php
$page = ... //figure out the page from request info
switch($page) {
    case 'index.php':
       require_once "a.php";
       break;
//and so on
}
?>
2 Likes

much appreciated.

thanks for the tip, i’ll have to try that.

just so i’m correctly following the bouncing ball… this approach would require a single line of php,

<?php require_once "my_code.php"; ?>

to be on every page that uses the master page.

whenever one of those pages is requested, the host would first fetch the my_code.php file to test if it is the case of the_PRG_page.html being served up, or not (you call it index.php in your example)

if NOT, then break; and continue serving the requested page,

if IS, then run a.php which is where i would keep the POST part of the PRG. This is the part that normally sits above the html on my child page, and is regularly erased whenever i update the master page.

at the end of a.php, the server would then “fall thru” to serve up the_PRG_page.html just as if the block of a.php code had been part of the page the whole time…

if true, that seems like it would work and save me from having to manually paste the code back above the <!DOCTYPE html> every time i update the master page.

i can probably figure this out on my own, but since you are feeling generous :wink:

how would i figure out the page file name from the request info?

do i need to parse $_SERVER[‘HTTP_HOST’] to find the string?

or is there a better way?

I assume this is not going to overwrite an existing custom.php which I’ve been using in the inc folder for a long time now.

JOY!

it works like a charm and now my php code won’t get erased every time i update the master page.

for anyone interested, i found that using

$callingPG = substr($_SERVER['PHP_SELF'], 1) ;

to figure out the page name works as it throws out the leading “/” character

and if there is a query attached,

$callingQS = $_SERVER['QUERY_STRING'] ;

nets you everything after the “?”