roppard
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Php in Text Widget@catacaustic
Thank you for another reply! I am trying to do it without a plugin because:- I am trying to use as little plugins as possible. I just dont generally like the idea of having a lot of plugins for every single seemingly simple thing…
- The code in tutorials seems good enough for me so I am hoping to make it work.
- I am still quite new to WordPress, but I like to code and experiment.
- Therefore yes – I would love to try it by myself :).
… But back to the problem. I tried some basic php echoes even before, pretty much just like you proposed – at the start and end of the function. On the site it shows:
Debugging 1: ‘<?php show_ad(1); ?>’
Debugging 2: ‘<?php show_ad(1); ?>’
<?php show_ad(1); ?>So the function obviously receives the input html string, but fails to process it. I tried to dig deeper:
function php_execute( $html ){ // Debugging... echo "<p>Debugging 1: '".$html."'</p>"; // There seems to be a problem here... echo "<p>Debugging 2: '".strpos( $html, "<"."?php" )."'</p>"; if( strpos( $html, "<"."?php" ) !== false ) { echo "<p>Debugging 3: Condition Entered. </p>"; ob_start (); eval( "?".">".$html ); $html = ob_get_contents (); ob_end_clean (); } // if () // Debugging... echo "<p>Debugging 4: '".$html."'</p>"; return $html; } // php_execute () add_filter('widget_text','php_execute',100);
On site:
Debugging 1: ‘<?php show_ad(1); ?>’
Debugging 2: ”
Debugging 4: ‘<?php show_ad(1); ?>’
<?php show_ad(1); ?As you can see, the Debugging 3 line is missing, therefore the function does not enter the condition… Thats why I echoed the result of the strpos() before the condition in “Debuggin 2” and it returns an empty string… So it seems that function is not working as expected and is probably interpreted as false. I am not that skilled in php, but I know some programming languages tend to do this…
Any ideas? Thanks again for help.
Forum: Fixing WordPress
In reply to: Php in Text Widget@catacaustic Thanks for reply! But… read my submit again. Plugin you posted is mentioned there, I know it works, but I am looking for a way to do it without a plugin. I am sure I am not the only one, since those tutorials I posted are exactly trying to do that too. But for some reason they dont work and I want to figure out why…