Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Plugins & Atahualpa (http://forum.bytesforall.com/forumdisplay.php?f=16)
-   -   Enhanced text widgets and PHP plug-ins (http://forum.bytesforall.com/showthread.php?t=14514)

ArtG Jun 6, 2011 12:29 PM

Enhanced text widgets and PHP plug-ins
 
Just want to check a few assumptions I am making before implementing the enhanced text widget solution for 3.6.7+

1) Because such widgets have not been removed from WP's Plug-in Directory, placing PHP in these widgets resolves the following matter which prompted the removal of our being able to use PHP within theme options. from BFA homepage:

Quote:

No custom PHP code anymore: After the “Eval” function was not permitted anymore in themes, the alternative “stream wrappers” caused issues on all hosts where Suhosin was installed. The remaining option “temp. files” isn’t an option either because that requires file operations again. Atahualpa was one of few themes, if not the only one, to offer the ability to add custom PHP through theme options. This is not possible anymore in themes listed on wordpress.org. There might be workarounds or even alternative theme options in the near future, here or on the forum.

2) The removal of being able to add PHP through the theme options does not impact the ability to add PHP to a page or post when using a plug-in like Exec-PHP.


Thanks!

juggledad Jun 6, 2011 12:50 PM

you got it, plugins can use the eval() function, but themes can not...strange but true.

ArtG Jun 7, 2011 03:16 PM

Juggledad, your tips and assistance have been very helpful. Just sent something your way via PayPal to say thanks.

Seems I can't use the text widget approach since I can't add a new widget area to locations where I am using PHP: multi- and single-post kickers, bylines, and footers. So I looked around elsewhere on this forum, as well as in the codex and in Atahualpa's code, and have come up with the following idea. Any feedback, tips, or alternative ideas you might have would be most welcome.

Problem to solve: no longer able to use PHP to create custom kicker/byline/footer format and content for different types of posts.

Solution:create a child theme that contains just two files, the required style.css which simply imports Atahualpa's style.css, and a functions.php containing...

PHP Code:

function new_bylines() {
    
$single_by //code from ATO single-post byline goes here;
    
return apply_filters 'post_byline_single' $single_by );
    
$multi_by //code from ATO multi-post byline goes here;
    
return apply_filters 'post_byline_multi' $multi_by );


...which would be revised and repeated to do the same thing for the 'hooks' post_footer_single, post_footer_multi, post_kicker_single, and post_kicker_multi which are found in bfa_post_parts.php.

Would this work? If so, can I literally copy what I have in ATO fields, such as post info items which contain %, into these functions? Is there an easier way?

juggledad Jun 7, 2011 04:21 PM

can you export you theme settings and attach them to a reply ato->export/import settings

juggledad Jun 7, 2011 04:35 PM

actually I just tried creating a new widget area in the kicker and it works. Did you try it?

because the code can get parse ad it knows about the bfa_widget_area() function, it can parse that code, it just can't parse other php, like if statements etc.

ArtG Jun 8, 2011 07:42 AM

I was able to create a widget area in the kicker - but only after I actually upgraded to 3.6.7 on my test site. :o

After doing so, and making sure the standard text widget could use php through the plug in Exec-php, I was able to enter this into the text box in my kicker widget area...

PHP Code:

<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>

...and get the desired results. I then added some logic...

PHP Code:

<?php 
if ( 0) {
 Echo 
"<b>Tell your friends: </b>";
 if ( 
function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } }
else {
 Echo 
"<b>Why do I see this?</b>";
}
?>

...and was surprised to see I got exactly what I wanted. However, even though this is in the kicker, when adding a post info item into the mix...

PHP Code:

<?php 
if ( 0) {
 Echo 
"<b>Tell your friends: </b>";
 if ( 
function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } }
else {
 Echo 
"<b>Why do I see this?</b>";
}
?>
<b>You are here: </b>%category%

...I would get %category% regardless of any combination of the above that crossed my mind.

As requested I am sending a copy of my theme settings via PM. This is from the 3.6.4 version but I doubt that matters given I assume you are looking at the php I am placing in the multi- and single- kicker, byline, and footer fields. I am also including a few PDFs of the actual site pages showing the results we want using 3.6.4.

I realize now some of my php logic could be simplified by retrofitting the site with custom posts and using their ID numbers instead of content fields from the posts and I will make those changes. Just not sure how to solve the issue surrounding post info items.

ArtG Jun 8, 2011 07:58 AM

Oops. Thought I could send via PM. I'll try attaching here.

juggledad Jun 8, 2011 09:20 AM

so I think this will work. Lets take the example of what you have in the 'KICKER: Single Post Pages'
HTML Code:

<div class="breadcrumbs">
<table width="100%" >
<tbody>
<tr>
<td>
<?php
if(function_exists('bcn_display'))
{
    bcn_display(false, false);
}
?>

</td>
<td style="text-align: right;">%wp-print%</td>
</tr>
</tbody>
</table>
</div>
<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>

to implement this in 3.6.7 you will have to do this - since there are two PHP sections, you need to create two widget areas
HTML Code:

<div class="breadcrumbs">
<table width="100%" >
<tbody>
<tr>
<td>
<?php bfa_widget_area('name=Kicker_area_singlepostpage1'); ?>
</td>
<td style="text-align: right;">%wp-print%</td>
</tr>
</tbody>
</table>
</div>
<?php bfa_widget_area('name=Kicker_area_singlepostpage2'); ?>

then you add a text widget to both and in 'Kicker_area_singlepostpage1' you add
HTML Code:

<?php
if(function_exists('bcn_display'))
{
    bcn_display(false, false);
}
?>

and in 'Kicker_area_singlepostpage2' you add
HTML Code:

<?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>
HOWEVER, if you want to conditionally put in any of the theme parameters line '%wp-print%' this will not work. Unfortunately I can't think of a way to conditionally add the theme parameters. Sigh...why did you restrict the eval() Wordpress...Why?

ArtG Jun 8, 2011 03:32 PM

Thanks, Juggledad.

The theme parameter %wp-print% requires the plug-in WP-print which has the following in their documentation:

Quote:

<?php if(function_exists('wp_print')) { print_link(); } ?>


All times are GMT -6. The time now is 03:49 AM.

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