Jump to content

Archived

This topic is now archived and is closed to further replies.

infogroupsmb

HTTP_HOST changing in functions.php

Recommended Posts

infogroupsmb    1
infogroupsmb

I am getting variable results from the $_SERVER['HTTP_HOST'] variable in the functions.php file of our child theme.

Let me explain our setup and then I'll explain the issue. We are running WP 3.5.2 on Nginx with PageLines 2.4 as our parent theme and a handful of plugins that I can detail if necessary. Our virtual host is set to answer to *.salesgenie.com as we have several private label subdomains that will change the branding of the site. www.salesgenie.com will be the generic domain but att.salesgenie.com is an example of a branded subdomain.

So I need to be able to detect the subdomain the client calls with which I am trying to get with $_SERVER['HTTP_HOST']. The issue is that $_SERVER['HTTP_HOST'] is accurate the first time a client comes to their domain but reverts to the $_SERVER['SERVER_NAME'] value after that either on page reload or navigation to any other page.  I have gone through disabling all plugins in our test environment and that made no difference but when I switched to the TwentyTwelve them the HTTP_HOST worked just fine.  I tried upgrading to PL 2.4.4 and it had the same problem.

To test this I've got a function logging the $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] to a cookie called CmsCookie and you can test it by going to cms.salesgenie.com (the CNAME is working) and both variables will read cms.salesgenie.com. But if you modify your host file to point att.salesgenie.com at 54.208.87.200 then you can test att.salesgenie.com and the cookie will be correct the first time you hit a page, but if you reload, both server name and host will be cms.salesgenie.com

Any ideas what in Pagelines is changing the HTTP_HOST?

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

So any ideas on what in PL is rewriting the HTTP_HOST?

Share this post


Link to post
Share on other sites
Simon    247
Simon

There is no code to rewrite HTTP_HOST anywhere in PageLines Framework.

 

$_SERVER['HTTP_HOST'] is used twice to get the current URL, but only to read it, the superglobal is never changed.

 

Maybe look into the way your using sessions/cookies. Perhaps your PHP install is setup wrong.

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

Well, as I said before, the exact same code works when I put it into the 2012 theme and turn off Pagelines.  So the code works fine, until PL is activated.  I even get the same behavior when using pl_get_uri( TRUE ).  

 

setcookie('CmsCookie', $_SERVER['SERVER_NAME'].' - '.$_SERVER['HTTP_HOST'].' - '.pl_get_uri( TRUE ) , 0, '/', 'salesgenie.com', 0);

 

On the first visit HTTP_HOST and pl_get_uri return the correct URI, the one typed into the browser, but upon reloading the page or navigating to another page they both return the SERVER_NAME.

 

HTTP_HOST works just fine when put into the functions.php of 2012 and turning off PL.  Disabling all plugins made no difference.  It breaks even when I activate the base PL theme and not our child theme and it is a fresh download of PL 2.4.4 from yesterday.  So something in PL ends up changing the HTTP_HOST.

Share this post


Link to post
Share on other sites
Simon    247
Simon

How are you changing the site_url etc? is this 2 different wordpress installs?

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

Both site and home url are set in the DB, via the admin panels > settings > general.

 

They are not set in the wp-config file

Share this post


Link to post
Share on other sites
Simon    247
Simon

no i mean your loading the same site with 2 different subdomains, either its the same site and your changing the urls dynamically, or you have one url set in the configfile and your expecting it to work with any subdomain, or its 2 different wordpress installs?

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

Same wordpress install for all subdomains.  The virtual host is set to a wildcard *.salesgenie.com directed to the test-cms.salesgenie.com directory.  So any subdomain is directed to the same wordpress installation.  The only url rewriting is being done in jQuery to change all links from the base www.salesgenie.com to whatever the calling subdomain is i.e. att.salesgenie.com

 

Our test environment is test-cms.salesgenie.com and that CNAME is currently set up.  Eventually we will point all branded subdomains to the same WP installation but for testing for now I modify my hosts file to set att.salesgenie.com to point to that same server 

 

54.208.67.170 att.salesgenie.com

Share this post


Link to post
Share on other sites
Simon    247
Simon

Is that even supported in wordpress? I thought multisite was for multiple subdomains?

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

Well it works just fine with a standard installation of WP and the default theme. 

Share this post


Link to post
Share on other sites
infogroupsmb    1
infogroupsmb

So no suggestions on what to look into or a work around?

Share this post


Link to post
Share on other sites

  • Similar Content

    • dawsonbarber
      By dawsonbarber+
      I originally asked this question over here http://forum.pagelines.com/topic/35584-voyant/ but realized I should have started a new topic.   I don't seem to be able to start one under the PageLines Store Products forum because I can't find Enrique Chavez listed there.   Anyway, my question is about the Pagelines store child themes, like Flatten and Voyant.   Where do I add custom functions? There does not appear to be a functions.php file that I can/should edit so I'm wondering where they go.   I usually use a child theme based on Danny's Skeleton child theme, which, of course, has a file for custom functions.   Please advise.   Thanks
    • ketri
      By ketri
      By trial and error I was able to create a new shortcode by editing the class.shortcodes.php. Basically I added my shortcode first to the 
      private function shortcodes_core() { And then just copy-pasting the function below. 

      How do I add it to my child theme? Can I add just the one shortcode or do I have to override them all?

      Thank you
    • bartslot
      By bartslot
      Hi there, my first post on these forums!
       
      I use pagelines framework and want to know how to change a menu based on the current localization of wordpress.
      I use a plugin (Bogo) that switches between 3 languages: Dutch, English and French.
      ( define('WPLANG', 'nl_NL') -> define('WPLANG', 'en_US'); )
       
       
      I also added 3 menu's: NLmenu, ENGmenu and FRmenu which stores the pages that links to the corresponding language page (/home/,  /en/home, /fr/home/..)
       
      How can I change the menu that's displaying in the navbar section (not fixed) when the localization changes?
       
      Here is the code I have so far in the base theme's functions.php:
      // Register Menus add_action( 'init', 'asgro_register_additional_menus', 11 ); function asgro_register_additional_menus() { register_nav_menu( 'NLmenu', _x( 'NL menu', 'navbar_brand', 'pagelines' ) ); register_nav_menu( 'ENGmenu', _x( 'ENG menu', 'navbar_brand', 'pagelines') ); register_nav_menu( 'FRmenu', _x( 'FR menu', 'navbar_brand', 'pagelines') ); } add_filter( 'wp_nav_menu_args', 'asgro_nav_menu_args' ); function asgro_nav_menu_args( $args ) { $locale = get_locale(); if ( 'nl_NL' == $locale ) $args['theme_location'] = 'NLmenu'; if ( 'en_US' == $locale ) $args['theme_location'] = 'ENGmenu'; if ( 'fr_FR' == $locale ) $args['theme_location'] = 'FRmenu'; return $args; } // END Register Menus Thanks in advance
       
    • davemoppert
      By davemoppert
      I am wondering if there is any way for me to get a facebook like button to show up AFTER the site title/logo in the header?  I am close -- was able to add one above the title/logo, but cannot get it to align to the right of it.  I accomplished this by adding a hook into the functions.php: 
       
      add_action('pagelines_site_logo', 'fblike'); function fblike(){ ?> <div class="addthis_toolbox addthis_default_style "> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> </div> <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-50a1c3640c621b4b"></script> <?php }  
      You can see the site here: http://updated-kid2kid.com/test/ (it is a subsite)
       
      I tried to change the hook function to 'pagelines_after_site_logo' and 'after_pagelines_site_logo' without any luck.  Any idea what I can do to accomplish this the way I would like?
       
    • Oxford_Guy
      By Oxford_Guy
      Hi - custom taxonomies are important to me, but I can't seem to get them to work in PageLines Lite. I've installed and activated the Pagelines Customize plugin and have added this code to the functions.php file in the pagelines-customize folder:


      /** * Custom taxonomy for recipe ingredients * Following guidelines in Dig into Wordpress 3.3 p.35 * Also references code from: http://codex.wordpress.org/Taxonomies * */ function ingredients_init() { // create a new taxonomy register_taxonomy( 'ingredients', 'post', array( 'hierarchical' => false, 'label' => __( 'Ingredients'), 'query_var' => true, 'rewrite' => array( 'slug' => 'ingredient'), ) ); } add_action( 'init', 'ingredients_init' );

      Normally when I use this code, when I open up the "Posts" menu item in the WP admin side bar I will get an additional menu item for each taxonomy I create under "Tags", so when using the above example I should get a menu item for "Ingredients" where are can add new terms, assign them to posts etc. Also any posts tagged with a term from one of these taxonomies (e.g. "eggs") should be listed when I use a url of the form: http://myblog/ingredient/eggs but I'm getting a 404 error instead.

      Are custom taxonomies not supported in Pagelines or do I need to set these up in a different way? If custom taxonomies are not supported, I'm not sure that Pagelines is going to work for me :-(
×