Plugin Directory

Changeset 342553


Ignore:
Timestamp:
02/08/2011 05:25:50 PM (15 years ago)
Author:
knowledgeblog
Message:

Updating mathjax-latex with configurable Javascript location

Location:
mathjax-latex/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mathjax-latex/trunk/mathjax-latex.php

    r302211 r342553  
    22  /*
    33   Plugin Name: Mathjax Latex
    4    Plugin URI: http://knowledgeblog.org/mathjax-latex-wordpress-plugin/
    5    Description: Transform latex equations in javascript using MathJax
    6    Version: 0.1
     4   Description: Transform latex equations in javascript using mathjax
     5   Version: 0.2
    76   Author: Phillip Lord
    87   Author URI: http://knowledgeblog.org
    9    License: GPL2
    10 
     8   
    119   Copyright 2010. Phillip Lord (phillip.lord@newcastle.ac.uk)
    1210   Newcastle University.
    13  
    14    This program is free software; you can redistribute it and/or modify
    15    it under the terms of the GNU General Public License, version 2, as
    16    published by the Free Software Foundation.
    17 
    18    This program is distributed in the hope that it will be useful,
    19    but WITHOUT ANY WARRANTY; without even the implied warranty of
    20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21    GNU General Public License for more details.
    22 
    23    You should have received a copy of the GNU General Public License
    24    along with this program; if not, write to the Free Software
    25    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     11   
    2612  */
    2713
     
    7258    add_option('force_load', FALSE);
    7359    add_option('latex_syntax', 'inline');
     60    add_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__));
    7461    //test for wp-latex here
    7562    if (method_exists('WP_LaTeX', 'init')) {
     
    119106  }
    120107
    121   function add_script(){
     108function add_script(){
    122109    if( !self::$add_script )
    123110      return;
     
    125112    if( self::$block_script )
    126113      return;
     114   
     115    $mathjax_location = get_option('mathjax_location');
    127116
    128117    wp_register_script( 'mathjax',
    129                         plugins_url('MathJax/MathJax.js',__FILE__),
     118                        $mathjax_location,
    130119                        false, null, true );
    131120
     
    185174      if (!current_user_can('manage_options'))  {
    186175        wp_die( __('You do not have sufficient permissions to access this page.') );
     176      }
     177      //initialise option for existing MathJax-LaTeX users
     178      if (!get_option('mathjax_location')) {
     179        add_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__));
    187180      }
    188181      echo '<div class="wrap" id="mathjax-latex-options">
     
    206199            update_option('latex_syntax', $_POST['latex_syntax']);
    207200        }
     201        if ($_POST['default_disabled']) {
     202            update_option('default_disabled', true);
     203            if ($_POST['mathjax_location'] != get_option('mathjax_location')) {
     204                update_option('mathjax_location', $_POST['mathjax_location']);
     205            }
     206        }
     207        else {
     208            update_option('default_disabled', false);
     209            update_option('mathjax_location', plugins_url("MathJax/MathJax.js",__FILE__));
     210         }
     211            //$url = plugins_url($_POST['mathjax_location']."/MathJax.js",__FILE__);
     212            //$handle = @fopen($url,'r');
     213            //if($handle !== false){
     214                //update_option('mathjax_location', $_POST['mathjax_location']);
     215                //$exists = true;
     216            //}
     217            //else{
     218                //$exists = false;
     219            //}
     220        //}
     221        //else {
     222            //$exists = true;
     223        //}
    208224        echo '<p><i>Options updated</i></p>';   
    209225    }
    210226?>   
    211       <form id="mathjax-latex" name="mathjax-latex" action="" method='POST'>
     227      <form id="mathjaxlatex" name="mathjaxlatex" action="" method='POST'>
    212228      <input type="hidden" name="mathjax_hidden" value="Y">
    213229      <table class="form-table">
     
    249265      </td>
    250266      </tr>
     267      <tr>
     268        <th>Override default MathJax location?</th>
     269        <td><input type="checkbox" name="default_disabled" value="1"<?php
     270            if (get_option('default_disabled')) {
     271                echo 'CHECKED';
     272            }
     273      ?>/>
     274      </td>
     275      </tr>
     276      <tr>
     277        <th scope="row">MathJax Javascript location<br/><font size="-2">Changes will be ignored unless above is checked.</font></th>
     278        <td><input type='textbox' name='mathjax_location' class='regular-text code' value='<?php echo get_option('mathjax_location'); ?>'/></td>
     279      </tr>
    251280      </table>
    252281      <p class="submit">
  • mathjax-latex/trunk/readme.txt

    r302643 r342553  
    11=== MathJax-LaTeX ===
    22
    3 Contributors: knowledgeblog, sjcockell, philliplord, d_swan
    4 Tags: mathematics, math, latex, mathml, mathjax
     3Contributors: philliplord, sjcockell, knowledgeblog, d_swan
     4Tags: mathematics, math, latex, mathml, mathjax, science
    55Requires at least: 3.0
    6 Tested up to: 3.0.1
    7 Stable tag: 0.1
     6Tested up to: 3.0.5
     7Stable tag: 0.2
    88
    99This plugin enables mathjax (http://www.mathjax.org) functionality for WordPress (http://www.wordpress.org).
     
    3232
    3333You can also specify [nomathjax] -- this will block mathjax on the
    34 current page, regardless of other tags.
     34current page, regardless of other tags.
     35
     36The MathJax library is included in the plugin zip.
    3537
    3638== Installation ==
    3739
    38401. Unzip the downloaded .zip archive to the `/wp-content/plugins/` directory
    39 1. Download the MathJax Javascript library (http://www.mathjax.org/download/)
    40 1. Place the Javascript library in the mathjax-latex directory (`/wp-content/plugins/mathjax-latex/**MathJax**`)
    41411. Activate the plugin through the 'Plugins' menu in WordPress
     421. You can configure the plugin to load MathJax from a different URL to the default. See the options page.
     43
     44== Changelog ==
     45
     461. MathJax.js can be loaded form a configurable URL. Defaults to $PLUGIN/MathJax/MathJax.js
     471. MathJax is now included in the plugin distribution.
    4248
    4349== Copyright ==
Note: See TracChangeset for help on using the changeset viewer.