Changeset 369123
- Timestamp:
- 04/05/2011 03:15:05 PM (15 years ago)
- Location:
- mathjax-latex/trunk
- Files:
-
- 2 edited
-
mathjax-latex.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mathjax-latex/trunk/mathjax-latex.php
r343164 r369123 3 3 Plugin Name: Mathjax Latex 4 4 Description: Transform latex equations in javascript using mathjax 5 Version: 0.26 Author: Phillip Lord 5 Version: 1.0 6 Author: Phillip Lord, Simon Cockell 7 7 Author URI: http://knowledgeblog.org 8 8 9 9 Copyright 2010. Phillip Lord (phillip.lord@newcastle.ac.uk) 10 Simon Cockell (s.j.cockell@newcastle.ac.uk) 10 11 Newcastle University. 11 12 … … 19 20 function init(){ 20 21 register_activation_hook(__FILE__, array(__CLASS__, 'mathjax_install')); 21 22 register_deactivation_hook(__FILE__, array(__CLASS__, 'mathjax_uninstall')); 22 23 if (get_option('force_load')) { 23 24 24 self::$add_script = true; 25 26 } 27 25 } 28 26 else { 29 30 27 add_shortcode('mathjax', 31 28 array(__CLASS__, 'mathjax_shortcode' )); 32 33 } 34 29 } 35 30 add_shortcode('nomathjax', 36 31 array(__CLASS__, 'nomathjax_shortcode' )); 37 38 32 add_shortcode('latex', 39 33 array(__CLASS__, 'latex_shortcode' )); 40 41 34 add_action('wp_footer', 42 35 array(__CLASS__, 'add_script')); 43 44 36 add_action('wp_footer', 45 37 array(__CLASS__, 'unconditional')); 46 47 38 if (get_option('wp_latex_enabled')) { 48 39 add_filter( 'the_content', array(__CLASS__, 'inline_to_shortcode' ) ); 49 40 } 50 51 41 add_action('admin_menu', array(__CLASS__, 'mathjax_menu')); 52 53 42 add_filter('plugin_action_links', array(__CLASS__, 'mathjax_settings_link'), 9, 2 ); 43 add_action('admin_print_scripts-settings_page_mathjax-latex', array(__CLASS__, 'mathjax_admin_js')); 44 add_action('admin_notices', array(__CLASS__, 'mathjax_warning')); 54 45 } 55 46 … … 66 57 add_option('wp_latex_enabled', TRUE); 67 58 } 59 add_option('mathjax_config', 'default'); 60 add_option('use_cdn', false); 61 } 62 63 function mathjax_uninstall() { 64 delete_option('force_load'); 65 delete_option('latex_syntax'); 66 delete_option('mathjax_location'); 67 delete_option('wp_latex_enabled'); 68 delete_option('mathjax_config'); 69 delete_option('use_cdn'); 68 70 } 69 71 … … 114 116 115 117 //initialise option for existing MathJax-LaTeX users 116 if (!get_option('mathjax_location')) { 117 add_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__)); 118 } 119 $mathjax_location = get_option('mathjax_location'); 120 118 if (get_option('use_cdn')) { 119 $mathjax_location = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; 120 } 121 else { 122 if (!get_option('mathjax_location')) { 123 add_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__)); 124 } 125 if (!get_option('mathjax_config')) { 126 add_option('mathjax_config', 'default'); 127 } 128 $config_file = get_option('mathjax_location'); 129 $config_file = str_replace('MathJax.js', 'config/'.get_option('mathjax_config').'.js', $config_file); 130 if (fopen($config_file, 'r')) { 131 $mathjax_location = get_option('mathjax_location')."?config=".get_option('mathjax_config'); 132 133 } 134 else { 135 $mathjax_location = get_option('mathjax_location'); 136 } 137 138 } 121 139 wp_register_script( 'mathjax', 122 140 $mathjax_location, … … 203 221 update_option('latex_syntax', $_POST['latex_syntax']); 204 222 } 205 if ($_POST['default_disabled']) { 206 update_option('default_disabled', true); 207 if ($_POST['mathjax_location'] != get_option('mathjax_location')) { 208 update_option('mathjax_location', $_POST['mathjax_location']); 209 } 223 if ($_POST['use_cdn']) { 224 update_option('use_cdn', true); 210 225 } 211 226 else { 212 update_option('default_disabled', false); 213 update_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__)); 214 } 227 update_option('use_cdn', false); 228 if ($_POST['default_disabled']) { 229 update_option('default_disabled', true); 230 if ($_POST['mathjax_location'] != get_option('mathjax_location')) { 231 update_option('mathjax_location', $_POST['mathjax_location']); 232 } 233 } 234 else { 235 update_option('default_disabled', false); 236 update_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__)); 237 } 238 update_option('mathjax_config', $_POST['mathjax_config']); 239 } 215 240 //$url = plugins_url($_POST['mathjax_location']."/MathJax.js",__FILE__); 216 241 //$handle = @fopen($url,'r'); … … 270 295 </tr> 271 296 <tr> 297 <th>Use MathJax CDN Service?<br/><font size="-2">Allows use of the MathJax hosted content distribution network Javascript. By using this, you are agreeing to these <a href='http://www.mathjax.org/download/mathjax-cdn-terms-of-service/'>Terms of Service</a>.<br/>Ignore all following options.</font></th> 298 <td><input type="checkbox" name="use_cdn" id="use_cdn" value="1" onchange="change_state()" <?php 299 if (get_option('use_cdn')) { 300 echo 'CHECKED'; 301 } 302 ?>/> 303 </tr> 304 <tr> 272 305 <th>Override default MathJax location?</th> 273 306 <td><input type="checkbox" name="default_disabled" value="1"<?php … … 275 308 echo 'CHECKED'; 276 309 } 310 if (get_option('use_cdn')) { 311 echo ' DISABLED'; 312 } 277 313 ?>/> 278 314 </td> … … 280 316 <tr> 281 317 <th scope="row">MathJax Javascript location<br/><font size="-2">Changes will be ignored unless above is checked.</font></th> 282 <td><input type='textbox' name='mathjax_location' class='regular-text code' value='<?php echo get_option('mathjax_location'); ?>'/></td> 283 </tr> 318 <td><input type='textbox' name='mathjax_location' class='regular-text code' value='<?php echo get_option('mathjax_location'); ?>' 319 <?php 320 if (get_option('use_cdn')) { 321 echo ' DISABLED'; 322 } 323 ?> 324 /></td> 325 </tr> 326 <tr> 327 <th>Config<br/><font size='-2'>Select the config you want MathJax to use. An explaination is available in the <a href='http://www.mathjax.org/docs/1.1/options/index.html'>MathJax docs</a>.</font></th> 328 <td> 329 <select name='mathjax_config' <?php if (get_option('use_cdn')) echo 'DISABLED';?>> 330 <option value='default' 331 <?php if (get_option('mathjax_config') == 'default') echo 'SELECTED'?> 332 >default</option> 333 <option value='Accessible' 334 <?php if (get_option('mathjax_config') == 'Accessible') echo 'SELECTED'?> 335 >Accessible</option> 336 <option value='TeX-AMS_HTML' 337 <?php if (get_option('mathjax_config') == 'TeX-AMS_HTML') echo 'SELECTED'?> 338 >TeX-AMS_HTML</option> 339 <option value='TeX-AMS-MML_HTMLorMML' 340 <?php if (get_option('mathjax_config') == 'TeX-AMS-MML_HTMLorMML') echo 'SELECTED'?> 341 >TeX-AMS-MML_HTMLorMML</option> 342 </select> 343 </td> 344 </tr> 345 284 346 </table> 285 347 <p class="submit"> … … 290 352 <?php 291 353 } 354 function mathjax_admin_js() { 355 wp_enqueue_script('pluginscript', plugins_url('js/admin.js', __FILE__)); 356 } 357 function mathjax_warning() { 358 $config_file = get_option('mathjax_location'); 359 $config_file = str_replace('MathJax.js', 'config/'.get_option('mathjax_config').'.js', $config_file); 360 if (!get_option('use_cdn')) { 361 if (!fopen($config_file, 'r')) { 362 echo "<div id='message' class='error'><p>It appears you are running MathJax v1.0.1, you should consider <a href='http://www.mathjax.org/download/'>upgrading to v1.1</a>, or using the <a href='http://www.mathjax.org/docs/1.1/start.html#mathjax-cdn'>MathJax Content Distribution Network</a>. See the <a href='options-general.php?page=mathjax-latex'>plugin options page</a>.</p></div>"; 363 } 364 } 365 } 292 366 293 367 } -
mathjax-latex/trunk/readme.txt
r343020 r369123 4 4 Tags: mathematics, math, latex, mathml, mathjax, science, res-comms, scholar, academic 5 5 Requires at least: 3.0 6 Tested up to: 3. 0.57 Stable tag: 0.26 Tested up to: 3.1 7 Stable tag: 1.0 8 8 9 This plugin enables mathjax (http://www.mathjax.org) functionality for WordPress (http://www.wordpress.org). 9 This plugin enables mathjax (http://www.mathjax.org) functionality for WordPress (http://www.wordpress.org). Version 1.0 is compatible with MathJax 1.1 and the CDN. 10 10 11 11 == Description == … … 14 14 This plugin adds this functionality to wordpress. The mathjax javascript is 15 15 inject on-demand only to those pages which require it. This ensures that 16 mathjax is not loaded for all pages, which will otherwise slow loading down. 16 mathjax is not loaded for all pages, which will otherwise slow loading down. 17 18 The MathJax javascript can be delivered from your own server, or you can 19 utilise the [MathJax Content Distribution Network (CDN)] 20 (http://www.mathjax.org/docs/1.1/start.html#mathjax-cdn), which is the preferred 21 mechanism as it offers increased speed and stability over hosting the Javascript 22 and configuring the library yourself. Use of the CDN is governed by these 23 [Terms of Service](http://www.mathjax.org/download/mathjax-cdn-terms-of-service/). 17 24 18 25 You may embed latex using a variety of different syntaxes. The shortcode … … 41 48 1. Activate the plugin through the 'Plugins' menu in WordPress 42 49 1. You can configure the plugin to load MathJax from a different URL to the default. See the options page. 50 1. Alternatively you can use the MathJax Content Distribution Network (<http://www.mathjax.org/docs/1.1/start.html#mathjax-cdn>) to deliver the Javascript, just tick the relevant box on the options page. 43 51 44 52 == Changelog == 45 53 54 = 1.0 = 55 1. Compatibility with MathJax 1.1. Load a default configuration from the MathJax distribution. 56 1. Use the MathJax Content Distribution Network to deliver the javascript library. Offers improved performance and stability. 57 58 = 0.2 = 46 59 1. MathJax.js can be loaded form a configurable URL. Defaults to $PLUGIN/MathJax/MathJax.js 60 61 == Upgrade Notice == 62 63 = 1.0 = 64 The 1.0 release offers compatibility with MathJax 1.1, and enables use of the CDN for javascript delivery. Upgrading is strongly recommended. 47 65 48 66 == Copyright ==
Note: See TracChangeset
for help on using the changeset viewer.