Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

How to use PHP in Atahualpa 3.6.7


  #1  
Old May 20, 2011, 02:45 AM
sudipto's Avatar
sudipto
 
15 posts · Feb 2011
LetusBuzz.com Powered by Wordpress and Atahualpa
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

Last edited by sudipto; May 20, 2011 at 02:50 AM.
  #2  
Old May 20, 2011, 05:55 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
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.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old May 20, 2011, 06:23 AM
sudipto's Avatar
sudipto
 
15 posts · Feb 2011
LetusBuzz.com Powered by Wordpress and Atahualpa
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.
  #4  
Old May 28, 2011, 10:01 AM
PainFreeComputing
 
20 posts · Dec 2009
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
  #5  
Old May 31, 2011, 03:59 AM
GarethP
 
64 posts · Jun 2010
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...
  #6  
Old May 31, 2011, 10:14 AM
lmilesw's Avatar
lmilesw
 
10,176 posts · Jul 2009
Central New York State USA
While not exactly what you are looking for you might want to check out this plugin.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #7  
Old Jun 5, 2011, 06:22 PM
johnh44's Avatar
johnh44
 
34 posts · Nov 2010
Portland, Oregon
Send a message via Skype™ to johnh44
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.
__________________
John Hamlin, Nozzl.Com Founder & VP Operations.
Also, retired Newsroom Technology Director, The Oregonian, Portland, Oregon, USA.
  #8  
Old Jun 7, 2011, 05:16 AM
LANtait's Avatar
LANtait
 
56 posts · Jan 2011
Cebu Island, Philippines ~ I live on a tropical island!
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

Last edited by juggledad; Jun 7, 2011 at 05:33 AM.
  #9  
Old Jun 14, 2011, 06:33 AM
cfibanez
 
55 posts · Apr 2010
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!
  #10  
Old Jun 14, 2011, 06:38 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
exec-php will NOT work for php in the theme options
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Atahualpa 3.6.4 and PHP 5.3.5 --> Stream bfa:// cannot be opened (PHP 5.2.17 works) Jan New Versions, & Updating 0 May 3, 2011 08:15 AM
Atahualpa child theme function php kdawes01 Atahualpa 3 Wordpress theme 1 Sep 23, 2010 04:58 AM
[SOLVED] Stand alone php page on Atahualpa theme catherinehbbh Forum How-To 2 Apr 7, 2010 08:34 PM
PHP Catchable fatal error: themes/atahualpa/functions/bfa_meta_tags.php on line 169 Shamisen Plugins & Atahualpa 0 Apr 6, 2010 11:43 PM
How to edit single.php in atahualpa? Chloe Plugins & Atahualpa 8 Jan 29, 2010 03:58 PM


All times are GMT -6. The time now is 05:28 PM.


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