Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2017-12-06 03:58:04

rsamco
Member
From: Bend, Oregon
Registered: 2012-12-20
Posts: 177
Website

Custom BL PHP for WordPress?

Can BL's custom backlight.php be used for customizing WordPress pages when using a BL generated theme? Specifically, I'd like to use  the ttg_head hook to insert something into a particular WP page's <head>. TIA!

Last edited by rsamco (2017-12-06 04:01:30)


Rick

Offline

#2 2017-12-06 04:05:17

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 359
Website

Re: Custom BL PHP for WordPress?

I was playing with ttg_head the other day and it can, in fact, insert things in the <head> of a wordpress page but you need to use conditional logic to make sure the page you're on is in fact a wordpress one.

Offline

#3 2017-12-06 05:05:20

rsamco
Member
From: Bend, Oregon
Registered: 2012-12-20
Posts: 177
Website

Re: Custom BL PHP for WordPress?

thanks ... will do!


Rick

Offline

#4 2017-12-06 05:40:59

rsamco
Member
From: Bend, Oregon
Registered: 2012-12-20
Posts: 177
Website

Re: Custom BL PHP for WordPress?

Charlie, how did you test for a particular  WP  page? is_page() is apparently not available. I suppose one could parse and test the hook's $path parameter. But I suspect that there is an easier way, but haven't found it yet.


Rick

Offline

#5 2017-12-06 05:49:13

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 359
Website

Re: Custom BL PHP for WordPress?

What I do is look at the URL  ( $_SERVER[REQUEST_URI] ) as you mentioned. There may be a better way but I don't know it either.

Offline

#6 2017-12-06 06:44:38

Daniel Leu
Moderator
Registered: 2012-10-11
Posts: 1,624
Website

Re: Custom BL PHP for WordPress?

charlie.choc wrote:

What I do is look at the URL  ( $_SERVER[REQUEST_URI] ) as you mentioned. There may be a better way but I don't know it either.

I have a function that is based on the same technique:

function page_match($gallery) {
   if (substr($_SERVER["REQUEST_URI"], 0, strlen($gallery)) == $gallery) {
      return 1;
   }  else {
      return 0;
   }
}

This function returns 1 for subpage matches too, eg, page_match('/blog'). This works well for my purpose.


Daniel Leu | Photography   
DanielLeu.com
My digital playground (eg, Backlight tips&tricks): lab.DanielLeu.com

Offline

#7 2017-12-06 06:57:00

charlie.choc
Member
From: Marietta, GA
Registered: 2014-01-09
Posts: 359
Website

Re: Custom BL PHP for WordPress?

Nice, I thought about doing something similar with switch / case to return different values for my various pages but never got around to it.

Offline

#8 2017-12-06 09:27:31

rsamco
Member
From: Bend, Oregon
Registered: 2012-12-20
Posts: 177
Website

Re: Custom BL PHP for WordPress?

Here's what I ended up with:

function ttg_head( $style, $path ) { 
	// refresh WordPress page <wp_page> every 5 minutes
	if (substr($_SERVER["REQUEST_URI"], -strlen('/<wp_page>/')) == '/<wp_page>/') {
		echo '<meta http-equiv="refresh" content="300">' ;
	}
	return false;
} 

Last edited by rsamco (2017-12-06 09:28:39)


Rick

Offline

Board footer

Powered by FluxBB