开发者

Allow PHP inside form

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">My Company</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; 
    ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜