views:

106

answers:

1

I want to allow people to use PHP inside of a textarea of a Wordpress Admin Panel

<textarea cols="70" rows="5" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" />
    <?php echo stripslashes(get_settings($value['id'])); ?>
</textarea>

Will allow HTML usage, however not PHP...

UPDATE: Let me clarify. I can enter PHP in the form but it wont print on the front-end

 <p><?php echo stripslashes($tt_vanity_box); ?></p>

Well it's for the footer on a wordpress theme...called "vanity". Where the user can enter copyright info etc. Example:

&copy; <?php echo date('Y'); ?> <a href="http://mysite.com"&gt;My Company</a>
+1  A: 

I figured it out. After the options panel is saved (with PHP in the textarea) the front-end needs to be buffered (http://php.net/manual/en/function.ob-start.php)

 <?php $val = stripslashes($tt_vanity_box);
  ob_start();
  eval("?>$val<?php ");
  $val = ob_get_contents();
  ob_end_clean();
  echo $val; 
 ?>
Greg
Double check the permission, pale, becose if a normal user will ever have a chance to use this function, he will be able to do whatever he want with the database and php files.
DaNieL