Skip to main content

bugs - Wolfram CDF Player not working anymore in WordPress v.4.0.1


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

Popular posts from this blog

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

How to thread a list

I have data in format data = {{a1, a2}, {b1, b2}, {c1, c2}, {d1, d2}} Tableform: I want to thread it to : tdata = {{{a1, b1}, {a2, b2}}, {{a1, c1}, {a2, c2}}, {{a1, d1}, {a2, d2}}} Tableform: And I would like to do better then pseudofunction[n_] := Transpose[{data2[[1]], data2[[n]]}]; SetAttributes[pseudofunction, Listable]; Range[2, 4] // pseudofunction Here is my benchmark data, where data3 is normal sample of real data. data3 = Drop[ExcelWorkBook[[Column1 ;; Column4]], None, 1]; data2 = {a #, b #, c #, d #} & /@ Range[1, 10^5]; data = RandomReal[{0, 1}, {10^6, 4}]; Here is my benchmark code kptnw[list_] := Transpose[{Table[First@#, {Length@# - 1}], Rest@#}, {3, 1, 2}] &@list kptnw2[list_] := Transpose[{ConstantArray[First@#, Length@# - 1], Rest@#}, {3, 1, 2}] &@list OleksandrR[list_] := Flatten[Outer[List, List@First[list], Rest[list], 1], {{2}, {1, 4}}] paradox2[list_] := Partition[Riffle[list[[1]], #], 2] & /@ Drop[list, 1] RM[list_] := FoldList[Transpose[{First@li...

front end - keyboard shortcut to invoke Insert new matrix

I frequently need to type in some matrices, and the menu command Insert > Table/Matrix > New... allows matrices with lines drawn between columns and rows, which is very helpful. I would like to make a keyboard shortcut for it, but cannot find the relevant frontend token command (4209405) for it. Since the FullForm[] and InputForm[] of matrices with lines drawn between rows and columns is the same as those without lines, it's hard to do this via 3rd party system-wide text expanders (e.g. autohotkey or atext on mac). How does one assign a keyboard shortcut for the menu item Insert > Table/Matrix > New... , preferably using only mathematica? Thanks! Answer In the MenuSetup.tr (for linux located in the $InstallationDirectory/SystemFiles/FrontEnd/TextResources/X/ directory), I changed the line MenuItem["&New...", "CreateGridBoxDialog"] to read MenuItem["&New...", "CreateGridBoxDialog", MenuKey["m", Modifiers-...