2015-11-20, 21:27:16
(2015-11-19, 10:26:30)Tyblitz Wrote: Hey aldebaran,
I'll try to answer your first question:
Plugin authors (ideally) define plugin hooks you can hook into in order to execute your functions at a specified time.
In I18N, there's a plugin hook calledtheme-header
(which is by the way also a default hook), which accesses the$language
var (so you can be sure to access it if you hook into it). Note that you if youecho
something, it will be outputted in the page's<head>
.
Basically, do something like this (untested):
PHP Code:<?php
function your_function() {
global $language;
// do something based on $language;
}
add_action('theme-header', 'your_function');
?>
Hi Tyblitz
Thanks for your help .. That’s pointed me in a better direction !
Yes, you can only access a variable, here $language, after it is set/ available … obviously !
As said, I am wanting to use the functions.php file to concatenate all backend pages together but only for the set language, and then output this in the normal content area of the template, ie within the <body> ..
I am doing this at the moment by simply running the code directly from within the file … But this is WRONG .. It will run at the point where the file is imported, but I do not know / it is not defined where this import occurs. So there is no guarantee about the state of any variables at this point ..
But in the GS wiki about theme creation it does say that you can define a file functions.php to put in any custom functions that you can then call from your theme. It says that functions.php is then imported before the start of template output .. so you are then free to call any function defined in the file from the template.
So that is what I will do .. over the weekend … Declare a function in functions.php to concatenate all the pages into $content, and then call it instead of the normal get_page_content() from my template at a point where the content should go as normal and where variable $language will also be available. I will then still need to call get_page_content() to apply to the new $content any actions and filters from plugins as normal
Cheers Aldebaran