0

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

1 Answer 1

0

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...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.