Jump to content

Archived

This topic is now archived and is closed to further replies.

Willem-Siebe Spoelstra

Javascript and PHP for text/mediabox?

Recommended Posts

Willem-Siebe Spoelstra

Is it possible to allow Javascript and PHP for the textbox and mediabox?

 

For widgets I found this a while back and used that for adding PHP to widgets, any help on my new issue is appreciated :-), I would like to use texbox instead of widgetized sections.

 

Thanks.

/*
// ====================================================
// = ADD PHP IN TEXT WIDGET  = http://www.binaryturf.com/php-text-widget-php-wordpress-text-widget/
// ====================================================
*/	

add_filter('widget_text', 'php_text', 99);

function php_text($text) {
 if (strpos($text, '<' . '?') !== false) {
 ob_start();
 eval('?' . '>' . $text);
 $text = ob_get_contents();
 ob_end_clean();
 }
 return $text;
}

I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob

Willem,

 

That's a hook, so you can't add that code to a text widget or media area, as it will break the site.  It is neither PHP nor Javascript, so in this case, the answer is no.

 

However, if you had an actual PHP tag or javascript, they can be added to text widgets, not to media area.

 

To add the code you cited, you'd need to implement a child theme or PageLines Customize plugin, and add the code to functions.php in either of those.

 

Please see our docs at http://docs.pagelines.com.


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
beardedavenger

Willem-Siebe Spoelstra ya Rob is right on. Really only way to use widgets is with widgitizer, columnizer (or sidebar stuffed into a section area).


Something big is coming for DMS + photographers.

http://fotostheme.com

 

Nick Haskins & CO - New home for all of my PageLines Store products! 

http://nickhaskins.co

 

Better DMS - News, Tutorials, and Tips

http://betterdms.com

 

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra

Hi both, yes that is a hook I mentioned in the first post. I use that hook to allow PHP in text widgets. I will add this hook in my functions.php from my child theme and will work with widgetized areas when I need to implement PHP.


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites
Rob

Willem,  you are reinventing the wheel.  You don't need to add a hook to add PHP snippets or code to text widgets. They can accommodate properly written PHP snippets.  However, you may want to look into Shortcode Exec PHP, a free plugin that will convert your PHP code to a shortcode. You can obviously use shortcodes in text areas without question.

 

I might add in reviewing your topic heading and the opening posting, I don't see you mentioning the word "hook" anywhere.   Unfortunately, we can't support that customized code and have no idea what damage it might do. 


Former PageLines Moderator, Food Expert and Raconteur

Share this post


Link to post
Share on other sites
Willem-Siebe Spoelstra

Hi Rob, I added the 'hook' only as a reference that I got this working in text widgets and how I did that. The main question is how I can allow this in textboxes, so I don't find it neccesarry to review my topic heading and/or opening post. 

 

You perfectly answered the question that I can not use PHP/Javascript in the textbox but I have to use widgets for that. I used that hook and always did that, thanks for letting me know that it is useless because it's not needed to allow PHP in widgets :-). 


I write about internet marketing, WordPress and Pagelines on my Dutch blog spoelstra.ws

Share this post


Link to post
Share on other sites

×