Plugin Directory

Changeset 1244467


Ignore:
Timestamp:
09/13/2015 11:28:03 AM (10 years ago)
Author:
C. E.
Message:

Bug fix

Location:
mathematica-toolbox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • mathematica-toolbox/tags/1.0.1/README.txt

    r1200694 r1244467  
    2222
    2323The highlighting feature can be triggered in two ways. In the editor `[wlcode]Wolfram Language code here[/wlcode]` can be used to place a code block directly into the text, however it is often desirable to put the code elsewhere and refer to it instead of putting it into the text itself. This is achieved by the shortcode `[wlcode field="name"]` where `name` refers to a custom post field that holds the code that should be inserted at that point. You may have to go to "screen options" at the top of the editor page to enable custom post fields before you can see the custom post field form.
     24
     25To write code as a part of a sentence, that is, inline, you can use the shortcode `[wlinline]code[/wlinline]`. This will wrap the code with the `<code>` tag and thus (in many themes) distinguish the code visually.
    2426
    2527**Embed Wolfram technologies**
  • mathematica-toolbox/trunk/README.txt

    r1200692 r1244467  
    1717**Syntax highlighting and formatting**
    1818
    19 * Uses the same highlighting script that is used on Mathematica.StackExchange.com and on Wolfram Community.
     19* Uses the same highlighting script that is used on [Mathematica.StackExchange.com](http://mathematica.stackexchange.com) and on [Wolfram Community](http://community.wolfram.com).
    2020* Preserves code indentation and prevents WordPress from inserting `<br>` and `<p>` into code.
    2121* Replaces Wolfram Language character codes such as `\[Alpha]`, `\[Gamma]` etc. with their corresponding characters.
    2222
    2323The highlighting feature can be triggered in two ways. In the editor `[wlcode]Wolfram Language code here[/wlcode]` can be used to place a code block directly into the text, however it is often desirable to put the code elsewhere and refer to it instead of putting it into the text itself. This is achieved by the shortcode `[wlcode field="name"]` where `name` refers to a custom post field that holds the code that should be inserted at that point. You may have to go to "screen options" at the top of the editor page to enable custom post fields before you can see the custom post field form.
     24
     25To write code as a part of a sentence, that is, inline, you can use the shortcode `[wlinline]code[/wlinline]`. This will wrap the code with the `<code>` tag and thus (in many themes) distinguish the code visually.
    2426
    2527**Embed Wolfram technologies**
     
    3032* Display a link to the documentation of a Wolfram Language function.
    3133
    32 The [official plugin](https://wordpress.org/plugins/wolfram-cdf-plugin/) from Wolfram Research that embeds CDFs [does not work](http://mathematica.stackexchange.com/q/66311/731) since WordPress 4.0.1. The shortcode in this plugin takes exactly the same arguments, so the instructions for that plugin are still valid. There is a button beneath the text editor in the post admin area that inserts a template that is straightforward to fill out. You can upload the CDF and its backup image, which you get if you use the CDF export wizard in Mathematica, via the media uploader. Remember to take note of the dimension that the export wizard tells you that the CDF has, because you will need it later.
     34The [official plugin](https://wordpress.org/plugins/wolfram-cdf-plugin/) from Wolfram Research that embeds CDFs [does not work](http://mathematica.stackexchange.com/q/66311/731) since WordPress 4.0.1. The shortcode in this plugin takes exactly the same arguments, so the instructions for that plugin are still valid and migration is painless.
    3335
    34 When you create an "instant API" in the Wolfram Cloud using `CloudDeploy` and `APIFunction` Mathematica gives you a URL. `[WolframCloudAPI id=""]` accepts the ID part of that URL as a parameter and will output the API's return value. Any other parameters will be passed on to the API. By default `[WolframCloudAPI]` assumes that the return value of the API is an image. If it is data you should add `image="false"` as a parameter.
     36The shortcode is `[WolframCDF source="" width="" height="" altimage="" altimagewidth="" altimageheight=""]`, and the parameters and the alternative image (that is shown to those that don't have the CDF player) can be retrieve from the export wizard in Mathematica. The CDF file and the image can be uploaded to WordPress' media library. `source` and `altimage` refer to the URLs of these two files.
     37
     38The Wolfram Language functions `CloudDeploy` and `APIFunction` can be used to deploy so called *instant APIs*. The url to an instant API includes an ID number that identifies that particular API. `[WolframCloudAPI id=""]` can be used to display the result of calling the API if it is an image, and `[WolframCloudAPI id="" image="false"]` if it isn't. Any extra parameters that the API needs can also be passed along There are two working examples for this feature under FAQ.
    3539
    3640The shortcode `[wldoc]function[/wldoc]` generates a link to the online documentation page of `function`.
     
    3842**Retrieve posts from Mathematica.StackExchange.com**
    3943
    40 `[mma_se_questions ids="11350;3345;3646"]` retrieves the questions with the given IDs. Note that the IDs are separated by semicolons. Answers can be retrieved similarly by `[mma_se_answers ids="25616;259"]`. The display format in each case is an unordered list.
     44The shortcode `[mma_se_questions ids="11350;3345;3646"]` retrieves the questions with the given IDs. Note that the IDs are separated by semicolons. Answers can be retrieved similarly by `[mma_se_answers ids="25616;259"]`. The display format in each case is an unordered list.
    4145
    4246**Retrieve profile information from Mathematica.StackExchange.com**
    4347
    44 `[mma_se_user user_id="731"]` displays a link to the Mathematica.StackExchange user profile of user 731. The link text is the user's name. `[mma_se_user user_id="731" link="false"]` displays the name without turning it into a link.
     48The shortcode `[mma_se_user user_id="731"]` displays a link to the Mathematica.StackExchange user profile of user 731. The link text is the user's name. `[mma_se_user user_id="731" link="false"]` displays the name without turning it into a link.
    4549
    46 `[mma_se_profile_box user_id="731"]` displays a box with basic facts about user 731. Please see the screenshots page for a better understanding of what the result is.
     50The shortcode `[mma_se_profile_box user_id="731"]` displays a box with basic facts about user 731. Please see the screenshots page for a better understanding of what the result is.
    4751
    48 `[mma_se_user_questions user_id="731"]` and `[mma_se_user_answers user_id="731"]` displays lists of questions and answers respectively written by user 731. This shortcode is a direct interface between WordPress and the Stack Exchange API: any parameter in API can be added to the shortcode. For example `[mma_se_user_questions user_id="731" pagesize="5" sort="votes"]` returns the five questions asked by user 731 that have the most votes. You can see the full set of parameters in the [documentation](http://api.stackexchange.com/docs/answers-by-ids) for the Stack Exchange API.
     52The shortcode `[mma_se_user_questions user_id="731"]` and `[mma_se_user_answers user_id="731"]` displays lists of questions and answers respectively written by user 731. This shortcode is a direct interface between WordPress and the Stack Exchange API: any parameter in the API can be added to the shortcode. For example `[mma_se_user_questions user_id="731" pagesize="5" sort="votes"]` returns the five questions asked by user 731 that have the most votes. The full set of parameters is in the [documentation](http://api.stackexchange.com/docs/answers-by-ids) for the Stack Exchange API.
    4953
    5054**Caching of results**
    51 Note that queries sent to the Stack Exchange API are cached in the background, so for example `[mma_se_user user_id="731"]` will only look that user up once a week at most, because a week is the default expiration time of the cache. It's good to let the cache expire because sometimes users change their names. However if you want you can add the `expiration` parameter to any of the `mma_se_*` calls and specify the expiration time in seconds.
     55Note that queries sent to the Stack Exchange API are cached in the background, so for example `[mma_se_user user_id="731"]` will only look that user up once a week at most, because a week is the default expiration time of the cache. It's good to let the cache expire because sometimes users change their names. All `mma_se_` shortcodes accept a parameter called `expiration` that can be used to specify the expiration time in seconds.
    5256
    5357**Credits**
  • mathematica-toolbox/trunk/public/Mathematica-WP-Toolbox-public.php

    r1200690 r1244467  
    436436          */
    437437          add_shortcode( 'WolframCloudAPI', function( $parameters, $content = '' ) {
    438              
    439               $parameters = shortcode_atts(array(
    440                 'id' => '',
    441                 'image' => true
    442               ), $parameters);
    443              
    444               $parameters['image'] = ($parameters['image'] === "false" || !$parameters['image']) ? false : true;
    445              
    446               if( $parameters['image'] ) {
    447                 return "<img src='https://www.wolframcloud.com/objects/{$parameters['id']}'>";
    448               }
    449 
    450               if( $parameters['id'] == '' ) {
    451                   return;
     438
     439              if( !isset($parameters['image']) ) {
     440                  $parameters['image'] = true;
     441              }
     442              if( $parameters['image'] === "false" || !$parameters['image'] ) {
     443                  $parameters['image'] = false;
     444              }
     445              else {
     446                  $parameters['image'] = true;
    452447              }
    453448             
    454449              $query = "https://www.wolframcloud.com/objects/{$parameters['id']}?";
     450             
     451              if( !isset($parameters['id']) || $parameters['id'] == '' ) {
     452                  return 'The ID parameters is required.';
     453              }
    455454             
    456455              foreach( $parameters as $parameter => $value ) {
    457456                 
    458                   if( $parameter == 'id' ) {
     457                  if( $parameter == 'id' || $parameter == 'image' ) {
    459458                      continue;
    460459                  }
     
    465464             
    466465              $query = trim( $query, '&' );
     466             
     467              if( $parameters['image'] ) {
     468                return "<img src='$query'>";
     469              }
    467470             
    468471              $response = wp_remote_get( $query );
Note: See TracChangeset for help on using the changeset viewer.