I'm currently having some issues trying to incorporate 2 Class Libraries (1. Form Builder & 2. Custom Emailer) into a Wordpress plugin.
Background:
Form Builder (based of a modified version of PFBC http://www.imavex.com/pfbc3.x-php5/index.php) - Using to Generate Forms for Rapid Web Development.
Custom Emailer - In-house library that provides an API to another system we've developed.
The complexity seems to be outputting the javascript in the footer for page speed optimisation, using wordpress hooks to output in the footer.
My question is, how do layout my code so I can access Classes from other functions.
eg. echo $email->formid();
function wpplugin_blah_forms_init_form()
{
$email = new DealerSolutionsEmailGateway();
$email->formid = 'blah'; // ID of the <form>
}
function wpplugin_blah_forms_show($atts)
{
// Get Shortcode parameter "form"
$forms = shortcode_atts( array('form' => '', 'view' => 'SideBySide'), $atts );
// Init EmailProcessor
wpplugin_blah_forms_init_form();
echo $email->formid();
$form = new Form("General");
//$form->configure($form_config);
$form->addElement(new Element\HTML($theme));
$form->addElement(new Element\HTML('<h2>General Enquiry</h2>'));
$form->addElement(new Element\Hidden("form", "General"));
$form->addElement(new Element\HTML('<legend>Personal Details</legend>'));
$form->addElement(new Element\Button("Submit My Enquiry"));
return $form->render(); // display form
}
add_shortcode('show_form', 'wpplugin_blah_forms_show');
The above example is a cut down version of what im doing, im just not sure how to access $email when it was initiated in another function.