Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   How to use PHP in Atahualpa 3.6.7 (http://forum.bytesforall.com/showthread.php?t=14243)

sudipto May 20, 2011 01:45 AM

How to use PHP in Atahualpa 3.6.7
 
This the easiest way to again use PHP in Atahualpa 3.6.7 and later versions.
We will have to edit functions.php file.

Add this below code functions.php file. (Code has been take from Atahualpa 3.5.3)

PHP Code:

function bfa_html_inserts($custom_code) {
    global $bfa_ata; 
    if($custom_code != '') {
        if ( strpos($custom_code,'<?php ') !== FALSE ) {
            ob_start(); 
                eval('
?>'.$custom_code); 
                $custom_code = ob_get_contents(); 
            ob_end_clean();
        }
    } 
    return $custom_code; 
}


Edit function bfa_parse_widget_areas($content)

PHP Code:

function bfa_parse_widget_areas($content) {
                
    if ( strpos($content,'<?php bfa_widget_area') !== FALSE ) {
        $content = preg_replace_callback("|<\?php bfa_widget_area(.*)\((.*)'
(.*?)'(.*)\)(.*)\?>|","bfa_parse_widget_areas_callback",$content);
    }
       $content=bfa_html_inserts($content); /******** ADD THIS LINE *************/
    return $content; 
}


Logic behind the changes
The extra added function evaluates PHP using the eval function.
I have added a call to that function from function bfa_parse_widget_areas because bfa_parse_widget_areas is used to create custom widget areas. So if you can create a custom widget area at a particular place then you will also be able to use PHP in that section.
Still you wont be able to use php in CSS Insert. But now you know how it is done so you can easily figure out how to even use PHP in CSS Insert. You are just require to call bfa_html_inserts function before returning the result

juggledad May 20, 2011 04:55 AM

Remember, the eval() was taken out because of WordPress requirements. However as the user of the theme, you can make what ever modifications you want.

That said, you will have to continue to put this mod in each time the theme is upgraded and if you do this for a customer and they do an upgrade, it will be lost and you will have one unhappy customer.

So if you want to do it for your self, I say go ahead. If , however, you are doing this for another, I would recommend against making this mode and find a different work around.

sudipto May 20, 2011 05:23 AM

You are right JD. Even i don't recommend to use this mod. And for those who can't live without the PHP then I recommend they they should still stick to version 3.6.4 till some alternatives is found by Flynn.

PainFreeComputing May 28, 2011 09:01 AM

It seems that all the "fixes" are ugly hacks. I hate to think of editing functions.php, only to have it overwritten at the next upgrade. Speaking of ugly hacks, I suppose you COULD put your own custom functions somewhere else, and have Apache append that file (using the ReadmeName directive) to the bottom of functions.php whenever it's served up. That would solve the problem of upgrades overwriting your custom functions. Yes, that's so ugly, even I'm ashamed.

Jack

GarethP May 31, 2011 02:59 AM

Would it be possible for Atahualpa to look for 'user PHP functions' in a separate file? e.g. user_function.php. This would, by default, be empty.

Users could add all their bespoke functions in this one file and then use a 'placeholder' in the theme options to call them?

i.e. %user_function(function name, parameter1, parameter2,...)%

Just a thought...

lmilesw May 31, 2011 09:14 AM

While not exactly what you are looking for you might want to check out this plugin.

johnh44 Jun 5, 2011 05:22 PM

Suggestion: Someone like me still with 3.6.4 because of this issue perhaps could turn those PHP codes into WP short codes if there were a way for using short codes in the theme options. Flynn?

BTW, the plugin Shortcode Exec PHP might be an excellent partner in this endeavor. :)

LANtait Jun 7, 2011 04:16 AM

I don't know if this will help, but I use...

Exec-PHP Version 4.9

Executes <?php ?> code in your posts, pages and text widgets.

http://wordpress.org/extend/plugins/exec-php/

I am using:
WordPress 3.1.3
Atahualpa 3.6.7
Atahualpa Easy Header Mod 3.6.7 (to protect my header, logo and favicon images)
Exec-PHP 4.9

cfibanez Jun 14, 2011 05:33 AM

Hi LANtait,

1) Two quick questions: where do I find Atahualpa Easy Header Mod 3.6.7?

2) Will Exec-PHP 4.9 work for php code entered in Atahaulpa's theme options (say, edit post/page info items)?

Thanks!

juggledad Jun 14, 2011 05:38 AM

exec-php will NOT work for php in the theme options


All times are GMT -6. The time now is 02:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.