I want to use a class from WordPress WYSIJA plugin in my php page. How do I need to init a plugin to be able to access it’s classes?
What I’m trying to do:
<?php
require_once(dirname(__FILE__).'/wp-blog-header.php');
require_once(dirname(__FILE__).'/wp-content/plugins/wysija-newsletters/core/base.php');
function display()
{
$myEmailVariable=$_POST['usremail'];
$myListId1='3';
echo($myEmailVariable);
$userData=array( 'email'=>$myEmailVariable, 'firstname'=>'', 'lastname'=>'');
$data=array( 'user'=>$userData, 'user_list'=>array('list_ids'=>array($myListId1)) );
$userHelper=&WYSIJA::get('user','helper');
print_r($data);
$userHelper->addSubscriber($data);
}
add_action('init','display');
And I’m getting an error: Fatal error: Class ‘WYSIJA’ not found in
Edit:
Now I moved the function that processes the form to the functions.php and edited the code:
<?php
require_once(dirname(__FILE__).'/wp-blog-header.php');
if (isset($_POST['usremail'])) {
add_subscriber_wys();
}
else {
//show form
?>
<body>
<div class="box_email">
<p>СекÑндÑ, Ð¼Ñ Ð¿ÐµÑенапÑавлÑем ÐÐ°Ñ Ð½Ð° ÑÑÑаниÑÑ Ð±Ð°Ð½ÐºÐ°</p>
<div class='email_frame'>
<form method="post" action="<?php echo($_SERVER['PHP_SELF']) ?>">
<span class="email_label">ÐведиÑе e-mail</span>
<input type="email" name="usremail" size="35" onfocus="stoptimer()" style="line-height: 60px;" >
<br>
<span>ÑÑÐ¾Ð±Ñ Ð¿Ð¾Ð»ÑÑаÑÑ Ð»ÑÑÑие пÑÐµÐ´Ð»Ð¾Ð¶ÐµÐ½Ð¸Ñ Ð¾Ñ Ð±Ð°Ð½ÐºÐ¾Ð²-паÑÑнеÑов</span>
</div>
<div>
<img src="http://moscow-kredit.ru/wp-content/themes/arthemia-premium/images/banki.png"></img>
</div>
<div class="or">
или пÑоÑÑо нажмиÑе
</div >
<div class='button'><input type="image" src="http://moscow-kredit.ru/wp-content/themes/arthemia-premium/images/knopka.png" alt="Ðалее" name='submit' /></div>
</form>
<?php
}
?>
</div>
<script>
var foo;
function redirectme(){
var refarray = new Array();
refarray['homenal'] = "http://test1.ru";
refarray['genal'] = "http://test2.ru";
refarray['domain3.com'] = "http://test3.ru";
for (var i in refarray) {
if (window.location.href.indexOf(i) != -1) window.location.replace(refarray[i]);
}
}
function stoptimer(){
clearTimeout(window.foo);
}
foo=setTimeout("redirectme();", 5000);
</script>
</body>
</html>
but it still is not even showing the form and no error is shown.
Try something like this:
Prefix or suffix your function names so there’s no risk of conflict with other functions.