I usually instert my CDF demonstrations in my WordPress site with the WolframCDF plugin v.2.1.
It worked fine till a couple of days ago.
But, after the recent (automatic) upgrade of WordPress from 4.0.0 to 4.0.1 that doesn't work anymore. The CDF is no more shown in the page, just the html code calling it.
Is anyone else experiencing this problem?
I'm afraid I'll have to downgrade to WordPress 4.0.0 (not so easy) or wait for the developer of the WolframCDF plugin to adjust it to the new version of WP.
At the moment my website (www.lucamoroni.it) heavily based on CDF simulations is totally useless!
But maybe there could be some workaround (i.e. modify manually some configuration file) to fix things (at least temporarily).
Any help? (any dirty trick?)
Answer
Update
The new plugin Mathematica Toolbox can embed CDFs and do many other things. The official plugin is still not working.
The problem is that whoever wrote the Wordpress plugin didn't use the official API to parse the CDF shortcode. The CDF plugin is essentially saying "right before the content is presented, modify it using function parseContent" (add_filter('the_content', array($wolframCDF, 'parseContent'));
). The function parseContent
uses regular expressions to find the shortcode, parse its attributes and replace it with the CDF code. It does not work in Wordpress 4.01 because the shortcode is modified (prettified for presentation) before it reaches parseContent
, and so is not recognized by the regular expression.
In order to make it work WRI needs to update the plugin and use the official shortcode API, i.e. parse the shortcode attributes by writing
function parseContent( $atts ) {
// Do stuff with the given attributes
}
add_shortcode('WolframCDF', 'parseContent');
which is both simpler and future proof.
In the meantime there is a fix that tells Wordpress not to touch the shortcode, which means it will still match the regular expressions. This is to go into text mode and wrap the shortcode with a code tag, i.e.
[WolframCDF attributes]
Note that you have to do it in text mode, you cannot use the visual mode. Using the tag should also work.
Another way (which I can not test, because I don't have Wordpress installed on this computer) is to go to wp-content/themes/your_theme/
and open functions.php
. Add the following line to the top of this file:
apply_filters('run_wptexturize', false);
This should disable wp_texturize
and thus make the CDF shortcode work again. Note that wp_texturize
does many good things, so it's better to fix the plugin instead of turning off wp_texturize
. But if you have many posts with the CDF shortcode in them, then updating each one may take some time and this could be a more attractive option.
Comments
Post a Comment