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.
You are not logged in.
Hi Everyone,
A few days ago I had asked a question about using one phplugins file for all three of my website. However, I soon realized that it wasn't necessary for what I wanted to do, so I took my post down. A little while later I received an email from Rod saying that he had an idea for how I could implement this. It seemed like a fun project, so I took him up on his offer. He gave me some code that he thought would work, but hadn't tested. I took that code and played with it for a while to get everything to work.
This code makes it so that you can control the phplugins for many sites with one phplugins.php file. In case anyone wants to do this, I have put the code that Rod and I came up with below. The first section of code is to implement wordpress menus for multiple sites, and the second is to use different custom css files for each site. If you use the custom css code, then you will need to create a new .css file in /public_html/phplugins/css/ for each of your sites. You will have to fill in some information for your sites into the code and update the path to the phplugins file in your sub sites. This code assumes that you have your phplugins folder in the root of your site and that site1 is the main site on your hosting service. Also, my example if for three sites, but you can add more if you need to.
Wordpress Code:
// GET FUNCTIONS FROM WORDPRESS SITE 1
if ($_SERVER[SERVER_NAME] == 'SITE1.COM') {
define('__ROOT__', 'SET/PATH/TO/WORDPRESS/FOR/SITE1'); // SET PATH TO WORDPRESS
require_once(__ROOT__.'/wp-includes/version.php'); global $wp_version;
require_once(__ROOT__.'/wp-load.php');
// SITE-WIDE NAVIGATION FROM WORDPRESS
function ttg_header_navigation( $style, $path ) {
if (G_STYLE != 'CE4-WORDPRESS') {
echo '
<div id="navigation-container" class="navigation-container clearfix">
<div id="navigation" class="block-id navigation clearfix">
<div class="mantle clearfix">
<div class="core clearfix">
<div id="navigation-background">
<div id="r2d2-menu" class="clearfix">
<ul id="pull">
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li id="open-nav"><a href="#r2d2-menu"><i class="fa fa-reorder"></i></a></li>
<li id="close-nav"><a href="#"><i class="fa fa-times"></i></a></li>
</ul>
';
wp_nav_menu(array( 'theme_location' => 'site-navigation', 'container' => false, 'menu_id' => 'nav', 'menu_class' => '', 'fallback_cb' => false, 'walker' => new My_Walker_Nav_Menu() ));
echo '
</div><!-- #r2d2-menu -->
</div><!-- #navigation-background -->
</div>
</div>
</div> <!-- #navigation -->
</div> <!-- #navigation-container -->
';
return false; // Replaces normal menu for non-WordPress pages
}
return true; // WordPress returns normal menu
} // END
// GET FUNCTIONS FROM WORDPRESS SITE 2
} else if ($_SERVER[SERVER_NAME] == 'SITE2.COM') {
define('__ROOT__', 'SET/PATH/TO/WORDPRESS/FOR/SITE2'); // SET PATH TO WORDPRESS
require_once(__ROOT__.'/wp-includes/version.php'); global $wp_version;
require_once(__ROOT__.'/wp-load.php');
// SITE-WIDE NAVIGATION FROM WORDPRESS
function ttg_header_navigation( $style, $path ) {
if (G_STYLE != 'CE4-WORDPRESS') {
echo '
<div id="navigation-container" class="navigation-container clearfix">
<div id="navigation" class="block-id navigation clearfix">
<div class="mantle clearfix">
<div class="core clearfix">
<div id="navigation-background">
<div id="r2d2-menu" class="clearfix">
<ul id="pull">
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li id="open-nav"><a href="#r2d2-menu"><i class="fa fa-reorder"></i></a></li>
<li id="close-nav"><a href="#"><i class="fa fa-times"></i></a></li>
</ul>
';
wp_nav_menu(array( 'theme_location' => 'site-navigation', 'container' => false, 'menu_id' => 'nav', 'menu_class' => '', 'fallback_cb' => false, 'walker' => new My_Walker_Nav_Menu() ));
echo '
</div><!-- #r2d2-menu -->
</div><!-- #navigation-background -->
</div>
</div>
</div> <!-- #navigation -->
</div> <!-- #navigation-container -->
';
return false; // Replaces normal menu for non-WordPress pages
}
return true; // WordPress returns normal menu
} // END
// GET FUNCTIONS FROM WORDPRESS SITE 3
} else {
define('__ROOT__', 'SET/PATH/TO/WORDPRESS/FOR/SITE3'); // SET PATH TO WORDPRESS
require_once(__ROOT__.'/wp-includes/version.php'); global $wp_version;
require_once(__ROOT__.'/wp-load.php');
// SITE-WIDE NAVIGATION FROM WORDPRESS
function ttg_header_navigation( $style, $path ) {
if (G_STYLE != 'CE4-WORDPRESS') {
echo '
<div id="navigation-container" class="navigation-container clearfix">
<div id="navigation" class="block-id navigation clearfix">
<div class="mantle clearfix">
<div class="core clearfix">
<div id="navigation-background">
<div id="r2d2-menu" class="clearfix">
<ul id="pull">
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li><span> </span></li>
<li id="open-nav"><a href="#r2d2-menu"><i class="fa fa-reorder"></i></a></li>
<li id="close-nav"><a href="#"><i class="fa fa-times"></i></a></li>
</ul>
';
wp_nav_menu(array( 'theme_location' => 'site-navigation', 'container' => false, 'menu_id' => 'nav', 'menu_class' => '', 'fallback_cb' => false, 'walker' => new My_Walker_Nav_Menu() ));
echo '
</div><!-- #r2d2-menu -->
</div><!-- #navigation-background -->
</div>
</div>
</div> <!-- #navigation -->
</div> <!-- #navigation-container -->
';
return false; // Replaces normal menu for non-WordPress pages
}
return true; // WordPress returns normal menu
} // END
}
Conditionally apply custom css:
// CUSTOM STYLESHEET FOR ALL SITES
function ttg_head_end( $style, $path ) {
if ($_SERVER[SERVER_NAME] == 'SITE1.COM') {
echo '
<link rel="stylesheet" href="/phplugins/css/custom.css" />
';
} else if ($_SERVER[SERVER_NAME] == 'SITE2.COM') {
echo '
<link rel="stylesheet" href="http://SITE2/phplugins/css/SITE2.css" />
';
} else {
echo '
<link rel="stylesheet" href="http://SITE3/phplugins/css/SITE3.css" />
';
}
}
Hope this helps someone, and let us know if it works for you.
Graceson
Last edited by gaufde (2015-01-18 10:16:04)
Graceson Aufderheide
gracesonaufderheide.com
Offline
I'd like to try this. I have a main Home page that links to French and English sites. I'd like to implement your method of having specific CSS for each of the three sites : main, french and english.
But I'm not sure what is the Server Name?
Offline
SERVER_NAME will yield everything after http:// or http://www. depending on your site address.
my site is at http://rodbarbee.com. So the SERVER_NAME will be rodbarbee.com
so, for example, your main site should need:
if ($_SERVER[SERVER_NAME] == 'lucnadeau.ca') {
echo ' ---path to custom css --- ';
Rod
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site
Offline