# One more thing …

**URL:** https://forum.pinegrow.com/t/one-more-thing/4382
**Category:** Feature Request
**Created:** [July 24, 2020, 9:08pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382 "2020-07-24T21:08:48Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![C\_p\_H](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/c_p_h/32/4352_2.png) [@C\_p\_H](https://forum.pinegrow.com/u/C_p_H)
#### Post date: [July 24, 2020, 9:08pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382/1 "2020-07-24T21:08:48Z")

</div>

“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 😌

---

<div class="post-metadata">

### Author: ![droidgoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/droidgoo/32/2209_2.png) [@droidgoo](https://forum.pinegrow.com/u/droidgoo)
#### Post date: [July 25, 2020, 3:02am UTC](https://forum.pinegrow.com/t/one-more-thing/4382/2 "2020-07-25T03:02:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![C\_p\_H](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/c_p_h/32/4352_2.png) [@C\_p\_H](https://forum.pinegrow.com/u/C_p_H)
#### Post date: [July 25, 2020, 6:38am UTC](https://forum.pinegrow.com/t/one-more-thing/4382/3 "2020-07-25T06:38:46Z")

</div>

I was referring to adding features and functionality to your WordPress theme by using code snippets, there’s a [reference](https://pinegrow.com/tutorials/how-to-add-features-and-functionality-to-your-wordpress-theme-by-using-code-snippets/?highlight=custom.php) 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. 👍🏽

---

<div class="post-metadata">

### Author: ![droidgoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/droidgoo/32/2209_2.png) [@droidgoo](https://forum.pinegrow.com/u/droidgoo)
#### Post date: [July 25, 2020, 5:59pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382/4 "2020-07-25T17:59:06Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)
#### Post date: [July 29, 2020, 5:29am UTC](https://forum.pinegrow.com/t/one-more-thing/4382/5 "2020-07-29T05:29:32Z")

</div>

@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
}
?>
```

---

<div class="post-metadata">

### Author: ![droidgoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/droidgoo/32/2209_2.png) [@droidgoo](https://forum.pinegrow.com/u/droidgoo)
#### Post date: [July 29, 2020, 2:51pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382/6 "2020-07-29T14:51:35Z")

</div>

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 😉 …

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?

---

<div class="post-metadata">

### Author: ![jonroc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/jonroc/32/2805_2.png) [@jonroc](https://forum.pinegrow.com/u/jonroc)
#### Post date: [July 29, 2020, 10:47pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382/7 "2020-07-29T22:47:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![droidgoo](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/droidgoo/32/2209_2.png) [@droidgoo](https://forum.pinegrow.com/u/droidgoo)
#### Post date: [August 11, 2020, 8:05pm UTC](https://forum.pinegrow.com/t/one-more-thing/4382/8 "2020-08-11T20:05:20Z")

</div>

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 “?”
