Title: Plugin variables question
Last modified: August 20, 2016

---

# Plugin variables question

 *  [noggster](https://wordpress.org/support/users/noggster/)
 * (@noggster)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-variables-question/)
 * Hey again WP forums!
 * Been scratching my head for a while now, and I bet someone here could cure my
   of my headache with ease.
 * I’ve made a plugin of my own, which is working as it should. However I wanted
   to add an option window for my plugin, and since this plugin is intended to be
   placed inside a widget I wanted to have my options right there in the widgets
   tab of WP. And since I didn’t want to clump up to much customization inside the
   little box where you drag your widget I decided a nice solution would be to have
   a options button that opens a modal-popup, where I would’ve all the option customization
   space I ever wanted.
 * For the modal I tried with Lightbox and more recently Fancybox, they both work
   great for drawing the modal, but when it comes to handling the php variables 
   from my plugin I’m stumped.
    The modal opens in a inline div, which is placed
   in my admin.php (the file controls what the widget when in the WP control panel
   will show). Inside the widget itself (not the modal) I simply use `<?php echo
   $instance['my_variabel']; ?>` This echos out the selected variable, $instance
   is an array containing all the variables, and is used for updating the variabel
   when they are saved.
 * When I try the same code inside the modal it echos out nothing, a var_dump on
   $instance shows the array, but all the values are empty. It is as it loads the
   modal with this php-code before their values have been set by my plugin.
 * Inside my plugin I use a function to generate the admin form with all the keys
   and their values, these are all set to ”, if I change the value from ” to anything
   else, that will show up when I echo it on my modal, but not the updated value.
   
   Here’s the code for clearification:
 *     ```
       function form($instance) {
   
       		$instance = wp_parse_args(
       			(array)$instance,
       			array(
       				'my_variabel' => '',
       			)
       		);
           $my_variabel = strip_tags(stripslashes($new_instance['my_variabel']));
   
           include(WP_PLUGIN_DIR . '/' . PLUGIN_SLUG . '/views/admin.php');
       }
       ```
   
 * How can I bypass this? I initializes fancybox on the element with:
 *     ```
       jQuery(document).ready(function($) {
       	$("a#inline").fancybox();
       });
       ```
   
 * this snippet is from my plugins .js file that is used when the user is admin,
   it’s called admin.js and is enqueued after I set the values of my $instance variables
   in my plugin.
    I also tried initializing fancybox on my element in admin.php,
   which loads in my plugin once again after I’ve set all values.
 * Would appriciate any help here, been slamming my head against the desk all morning
   over this. I hope I made my problem clear, I’m very bad at explaining things,
   specially in another language then my own. If anyone needs something cleared 
   up, just ask.
 * Best Regards

The topic ‘Plugin variables question’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [noggster](https://wordpress.org/support/users/noggster/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-variables-question/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
