I am attempting to then add functionality from the wordpress plugin I've converted into a Wordpress theme however i am getting little pleasure. The documentation does not help much me solve the issue so possibly someone here might help.
I've got a wordpress plugin in Wordpress that's triggered and dealing fine. The category with this wordpress plugin includes a function known as generateHtml which I must access from the Wordpress Theme. But whatever I attempt, I am unable to appear to gain access to my plugin's code.
May either produce a listing of what I have to do to obtain a theme being able to access code from the wordpress plugin and/or point available I'm going wrong during my code:
<?php /** Usual comments here **/ if (!class_is available("ImageRotator")) amplifier$this, 'generateHtml')) // Various functions for wordpress plugin function generateHtml() /** * Create demonstration of image rotator */ $imageRotator = new ImageRotator() /** * Create actions &lifier filters for Wordpress */ if (isset($imageRotator)) amplifier$imageRotator, 'createMenu')) add_action('admin_init', array(&lifier$imageRotator, 'registerSettings')) add_action('imagerotator_show', array(&lifier$imageRotator, 'generateHtml'))
Portion from theme header page:
<?php if (isset($imageRotator)) else if (isset($ImageRotator)) else if (function_is available("imagerotator_show")) else ?>
Presently all I ever see is "Not a chance" and "Function NOT found". Thank you for any input.
To begin with, "imagerotator_show" isn't a function it is the title of a kind of action. If you use the add_action() function, Wordpress just adds your approach to their email list of functions/techniques to call whenever a particular action is triggered. Thus your next test will invariably respond with 'Function NOT found'.
Probably the most likely reason for the very first issue is neglecting to declare the technique you need to call like a public method. You are also making the code harder than it must be.
The very best practice I have seen for proclaiming techniques and signing up hooks from the class looks something similar to this:
if ( ! class_is available( 'Foo' ) ): class Foo amplifier$this, 'my_hook_implementation' ) ) function my_hook_implementation() public function my_special_method() if ( class_is available( 'Foo' ) ): $MyFoo = new Foo()
This enables your class to help keep all its implementation particulars private. If you want to call my_special_method(), you're doing so the following: