I'm trying to use an instance or option from the widget backend settings outside the class but can't seem to get it to work.
I've omitted some of the code to simplify what I mean:
<?php
##trying to use variable here!
echo $instance['variableiwant'];
class my_class extends WP_Widget {
## get variable from the backend form settings of widget
function form($instance) {
$title = ! empty( $instance['variableiwant'] ) ? $instance['title'] : __( 'variableiwant' );
}
##update save of widget
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['variableiwant'] = strip_tags($new_instance[ 'variableiwant']);
return $instance;
}
function widget($args, $instance) {
}
I can use the variable perfectly fine inside the class and its functions but is there special API I need to use to pull the variable outside the class as the code:
echo $instance['variableiwant'];
Just returns 0 or zero