Firefox and Wordpress PHP widgets

Today I've tested a Wordpress site in Firefox and I found out that a PHP widget on the sidebar didn't work. More precisely, Firefox showed the raw PHP code instead of the normal HTML generated by PHP. The theme used on this site is Mystique, but I don't think it's caused by the theme, because it worked just fine in all other browsers. I tested it with Firefox for Mac. I don't understand how this is possible, because the page's loading was complete.

To fix the problem, I've used the jQuery's load() method and inserted the HTML via AJAX. So I've created a page with the following code:

header('Content-Type: text/html');
$page = file_get_contents('');
preg_match_all('#<a href="\d+/\d+/\d+/.+/" title="URL permanente di questo post">.+</a>#', $page, $matches);
$links = array_slice($matches[0], 0, 5);
$html = '<ul>' . "\n";
foreach($links as $link) {
  $html .= '<li>' . $link . '</li>' . "\n";

$html .= '</ul>' . "\n";
echo $html;

Then I've added the following jQuery code to the JavaScript loader of the theme:


Hope that helps. smile

One thought on “Firefox and Wordpress PHP widgets”

Leave a Reply

Note: Only a member of this blog may post a comment.