accessibility of an object created in a plugin, from the header

I have a simple OOP plugin with a class $MyClass in it. I create the instance MyObject of this class in my theme 'functions.php' file. Thanks to this, I can use any method MyObject->MyMethod from my page.php page, for example. This is OK.

BUT, strangely, when I am in page.php, this method call works before and after the get_header('menu'); but not inside ! (header-menu.php is my header file). So it seems I've lost the visibility of my object MyObject in the header inclusion and I need to use these methods in my header...

Would you have an idea of what I could do to access this instance from my header? Thank's a lot...Pierre


I don't know if this is the right way but by reading here , I have tried the following : added a global $MyObject in functions.php just before I create the object, and then put a global $MyObject in the header-menu.php file. This works : the object is now visible. Unless someone knows a drawback doing this, this could be the answer...

Category: plugins Time: 2016-07-31 Views: 2

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.168 (s). 12 q(s)