Commit 85290e43 authored by lucha's avatar lucha

[auto] plugin: mathjax-latex 1.3.8

parent e44fcafb
......@@ -21,34 +21,34 @@
class MathJax_Latex_Admin {
static $admin_tags = array(
'input' => array(
'type' => array(),
'name' => array(),
'id' => array(),
public static $admin_tags = array(
'input' => array(
'type' => array(),
'name' => array(),
'id' => array(),
'disabled' => array(),
'value' => array(),
'checked' => array(),
'value' => array(),
'checked' => array(),
),
'select' => array(
'name' => array(),
'id' => array(),
'id' => array(),
),
'option' => array(
'value' => array(),
'value' => array(),
'selected' => array(),
),
);
function __construct() {
public function __construct() {
add_action( 'admin_menu', array( $this, 'admin_page_init' ) );
}
function admin_page_init() {
public function admin_page_init() {
add_options_page( 'MathJax-LaTeX', 'MathJax-LaTeX', 'manage_options', 'kblog-mathjax-latex', array( $this, 'plugin_options_menu' ) );
}
function plugin_options_menu() {
public function plugin_options_menu() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); //xss ok
}
......@@ -69,7 +69,8 @@ class MathJax_Latex_Admin {
$checked_force_load = 'checked="true"';
}
$this->admin_table_row( 'Force Load',
$this->admin_table_row(
'Force Load',
'Force the MathJax JavaScript to be loaded on every post. This removes the need to use the [mathjax] shortcode.',
"<input type='checkbox' name='kblog_mathjax_force_load' id='kblog_mathjax_force_load' value='1' $checked_force_load />",
''
......@@ -85,7 +86,8 @@ class MathJax_Latex_Admin {
</select>
EOT;
$this->admin_table_row( 'Default [latex] syntax attribute.',
$this->admin_table_row(
'Default [latex] syntax attribute.',
"By default, the [latex] shortcode renders equations using the MathJax 'inline' syntax.",
$syntax_input,
'kblog_mathjax_latex_inline'
......@@ -96,7 +98,8 @@ EOT;
$use_wp_latex_syntax = get_option( 'kblog_mathjax_use_wplatex_syntax', false ) ? "checked='true'" : '';
$this->admin_table_row( 'Use wp-latex syntax?',
$this->admin_table_row(
'Use wp-latex syntax?',
"Allows use of the \$latex$ syntax, but conflicts with wp-latex. $wp_latex_disabled_warning",
"<input type='checkbox' name='kblog_mathjax_use_wplatex_syntax' id='kblog_mathjax_use_wplatex_syntax' $wp_latex_disabled $use_wp_latex_syntax value='1'/>",
'kblog_mathjax_use_wplatex_syntax'
......@@ -104,7 +107,8 @@ EOT;
$use_cdn = get_option( 'kblog_mathjax_use_cdn', true ) ? 'checked="true"' : '';
$this->admin_table_row( 'Use MathJax CDN Service?',
$this->admin_table_row(
'Use MathJax CDN Service?',
'Allows use of the MathJax hosted content delivery network. By using this, you are agreeing to the <a href="http://www.mathjax.org/download/mathjax-cdn-terms-of-service/">MathJax CDN Terms of Service</a>.',
"<input type='checkbox' name='kblog_mathjax_use_cdn' id='use_cdn' value='1' $use_cdn/>",
'use_cdn'
......@@ -113,7 +117,8 @@ EOT;
$custom_location_disabled = get_option( 'kblog_mathjax_use_cdn', true ) ? 'disabled="disabled"' : '';
$custom_location = "value='" . esc_attr( get_option( 'kblog_mathjax_custom_location', '' ) ) . "'";
$this->admin_table_row( 'Custom MathJax location?',
$this->admin_table_row(
'Custom MathJax location?',
'If you are not using the MathJax CDN enter the location of your MathJax script.',
"<input type='textbox' name='kblog_mathjax_custom_location' id='kblog_mathjax_custom_location' $custom_location $custom_location_disabled>",
'kblog_mathjax_custom_location'
......@@ -124,13 +129,14 @@ EOT;
$select_string = "<select name='kblog_mathjax_config' id='kblog_mathjax_config'>\n";
foreach ( $options as $i ) {
$selected = get_option( 'kblog_mathjax_config', 'default' ) === $i ? "selected='true'" : '';
$selected = get_option( 'kblog_mathjax_config', 'default' ) === $i ? "selected='true'" : '';
$select_string .= "<option value='$i' " . esc_attr( $selected ) . ">$i</option>\n";
}
$select_string .= '</select>';
$this->admin_table_row( 'MathJax Configuration',
$this->admin_table_row(
'MathJax Configuration',
"See the <a href='http://docs.mathjax.org/en/v1.1-latest/configuration.html#loading'>MathJax documentation</a> for more details.",
$select_string,
'kblog_mathjax_config'
......@@ -139,7 +145,7 @@ EOT;
$this->table_foot();
}
function config_options() {
public function config_options() {
$options = array(
'default',
'Accessible',
......@@ -150,7 +156,7 @@ EOT;
return $options;
}
function admin_save() {
public function admin_save() {
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
check_ajax_referer( 'kblog_mathjax_latex_save_field', 'security' );
}
......@@ -178,7 +184,7 @@ EOT;
}
}
function table_head() {
public function table_head() {
?>
<div class='wrap' id='mathjax-latex-options'>
<h2>Mathjax-Latex by Kblog</h2>
......@@ -189,7 +195,7 @@ EOT;
<?php
}
function table_foot() {
public function table_foot() {
?>
</table>
......@@ -215,7 +221,7 @@ EOT;
<?php
}
function admin_table_row( $head, $comment, $input, $input_id ) {
public function admin_table_row( $head, $comment, $input, $input_id ) {
?>
<tr valign="top">
<th scope="row">
......
<?php
/*
Plugin Name: MathJax-LaTeX
Description: Transform latex equations in JavaScript using mathjax
Version: 1.3.6
Author: Phillip Lord, Simon Cockell, Paul Schreiber
Author URI: http://knowledgeblog.org
Copyright 2010. Phillip Lord (phillip.lord@newcastle.ac.uk)
Simon Cockell (s.j.cockell@newcastle.ac.uk)
Newcastle University.
Paul Schreiber (paulschreiber@gmail.com)
/**
* Plugin Name: MathJax-LaTeX
* Description: Transform latex equations in JavaScript using mathjax
* Version: 1.3.8
* Author: Phillip Lord, Simon Cockell, Paul Schreiber
* Author URI: http://knowledgeblog.org
*
* Copyright 2010. Phillip Lord (phillip.lord@newcastle.ac.uk)
* Simon Cockell (s.j.cockell@newcastle.ac.uk)
* Newcastle University.
* Paul Schreiber (paulschreiber@gmail.com)
*/
/*
......@@ -32,14 +32,14 @@
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
define( 'MATHJAX_VERSION', '1.3.6' );
define( 'MATHJAX_VERSION', '1.3.8' );
require_once( dirname( __FILE__ ) . '/mathjax-latex-admin.php' );
require_once dirname( __FILE__ ) . '/mathjax-latex-admin.php';
class MathJax {
static $add_script;
static $block_script;
static $mathml_tags = array(
public static $add_script;
public static $block_script;
public static $mathml_tags = array(
'math' => array( 'class', 'id', 'style', 'dir', 'href', 'mathbackground', 'mathcolor', 'display', 'overflow', 'xmlns' ),
'maction' => array( 'actiontype', 'class', 'id', 'style', 'href', 'mathbackground', 'mathcolor', 'selection' ),
'maligngroup' => array(),
......@@ -107,7 +107,7 @@ class MathJax {
add_filter( 'the_content', array( __CLASS__, 'filter_br_tags_on_math' ) );
add_action( 'init', array( __CLASS__, 'allow_mathml_tags' ) );
add_filter( 'tiny_mce_before_init', array( __CLASS__, 'allow_mathml_tags_in_tinymce' ) );
add_filter( 'tiny_mce_before_init', array( __CLASS__, 'allow_mathml_tags_in_tinymce' ) );
}
// registers default options
......@@ -141,7 +141,11 @@ class MathJax {
self::$add_script = true;
// this gives us an optional "syntax" attribute, which defaults to "inline", but can also be "display"
$shortcode_atts = shortcode_atts( array( 'syntax' => get_option( 'kblog_mathjax_latex_inline' ) ), $atts );
$shortcode_atts = shortcode_atts(
array(
'syntax' => get_option( 'kblog_mathjax_latex_inline' ),
), $atts
);
if ( 'inline' === $shortcode_atts['syntax'] ) {
return '\(' . $content . '\)';
......@@ -161,7 +165,7 @@ class MathJax {
// initialise option for existing MathJax-LaTeX users
if ( get_option( 'kblog_mathjax_use_cdn' ) || ! get_option( 'kblog_mathjax_custom_location' ) ) {
$mathjax_location = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js';
$mathjax_location = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js';
} else {
$mathjax_location = get_option( 'kblog_mathjax_custom_location' );
}
......@@ -246,7 +250,7 @@ class MathJax {
return preg_replace_callback(
'/(<math.*>.*<\/math>)/isU',
function( $matches ) {
return str_replace( array( '<br/>', '<br />', '<br>' ) , '' , $matches[0] );
return str_replace( array( '<br/>', '<br />', '<br>' ), '', $matches[0] );
},
$content
);
......@@ -279,7 +283,7 @@ class MathJax {
foreach ( self::$mathml_tags as $tag => $attributes ) {
if ( ! empty( $attributes ) ) {
$tag = $tag . '[' . implode( '|' , $attributes ) . ']';
$tag = $tag . '[' . implode( '|', $attributes ) . ']';
}
$extended_tags[] = $tag;
......@@ -289,8 +293,8 @@ class MathJax {
$options['extended_valid_elements'] = '';
}
$options['extended_valid_elements'] .= ',' . implode( ',' , $extended_tags );
$options['extended_valid_elements'] = trim( $options['extended_valid_elements'] , ',' );
$options['extended_valid_elements'] .= ',' . implode( ',', $extended_tags );
$options['extended_valid_elements'] = trim( $options['extended_valid_elements'], ',' );
return $options;
}
......
......@@ -3,63 +3,45 @@
Contributors: philliplord, sjcockell, knowledgeblog, d_swan, paulschreiber, jwenerd
Tags: mathematics, math, latex, mathml, mathjax, science, res-comms, scholar, academic
Requires at least: 3.0
Tested up to: 4.7.3
Stable tag: 1.3.6
License: GPLv3
Tested up to: 4.9.1
Stable tag: 1.3.8
Requires PHP: 5.4.0
License: GPLv2
This plugin enables mathjax (http://www.mathjax.org) functionality for
WordPress (http://www.wordpress.org).
== Description ==
Mathjax enables enables rendering of embedded latex or mathml in HTML pages.
This plugin adds this functionality to wordpress. The mathjax javascript is
inject on-demand only to those pages which require it. This ensures that
mathjax is not loaded for all pages, which will otherwise slow loading down.
The MathJax javascript can be delivered from your own server, or you can
utilise the [MathJax Content Distribution Network (CDN)]
(http://www.mathjax.org/docs/latest/start.html#mathjax-cdn), which is the preferred
mechanism as it offers increased speed and stability over hosting the Javascript
and configuring the library yourself. Use of the CDN is governed by these
[Terms of Service](http://www.mathjax.org/download/mathjax-cdn-terms-of-service/).
You may embed latex using a variety of different syntaxes. The shortcode
(http://codex.wordpress.org/Shortcode_API) syntax is preferred. So
[latex]E=mc^2[/latex] will work out of the box. This also forces loading of
mathjax.
Additionally, you can use native mathjax syntax -- $$E=mc^2$$ or \(E=mc^2\).
However, if this is the only syntax used, the plugin must be explicitly told
to load mathjax for the current page. This can be achieved by adding a
[mathjax] shortcode anywhere in the post. For posts with both [latex]x[/latex]
and $$x$$ syntaxes this is unnecessary.
You can use wp-latex syntax, $latex E=mc^2$. Parameters can be
specified as with wp-latex but will be ignored. This means that mathjax-latex
should be a drop in replacement for wp-latex. Because this conflicts with
wp-latex, this behaviour is blocked when wp-latex is present, and must be
explicitly enabled in the settings.
You can also specify [nomathjax] -- this will block mathjax on the
current page, regardless of other tags.
MathJax-LaTeX is developed on
[Github](https://github.com/phillord/mathjax-latex).
Mathjax enables enables rendering of embedded latex or mathml in HTML pages. This plugin adds this functionality to wordpress. The mathjax javascript is inject on-demand only to those pages which require it. This ensures that mathjax is not loaded for all pages, which will otherwise slow loading down.
The MathJax javascript can be delivered from your own server, or you can use the [CloudFlare Content Distribution Network (CDN)] (https://www.mathjax.org/cdn-shutting-down/), which is the preferred mechanism as it offers increased speed and stability over hosting the Javascript and configuring the library yourself.
You may embed latex using a variety of different syntaxes. The shortcode (http://codex.wordpress.org/Shortcode_API) syntax is preferred. So [latex]E=mc^2[/latex] will work out of the box. This also forces loading of mathjax.
Additionally, you can use native mathjax syntax -- $$E=mc^2$$ or \(E=mc^2\). However, if this is the only syntax used, the plugin must be explicitly told to load mathjax for the current page. This can be achieved by adding a [mathjax] shortcode anywhere in the post. For posts with both [latex]x[/latex] and $$x$$ syntaxes this is unnecessary.
You can use wp-latex syntax, $latex E=mc^2$. Parameters can be specified as with wp-latex but will be ignored. This means that mathjax-latex should be a drop in replacement for wp-latex. Because this conflicts with wp-latex, this behaviour is blocked when wp-latex is present, and must be explicitly enabled in the settings.
You can also specify [nomathjax] -- this will block mathjax on the current page, regardless of other tags.
MathJax-LaTeX is developed on [GitHub](https://github.com/phillord/mathjax-latex).
== Installation ==
1. Unzip the downloaded .zip archive to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. This uses the mathjax
CDN(<http://www.mathjax.org/docs/1.1/start.html#mathjax-cdn>). Alternatively:
1. Download the MathJax Javascript library (http://www.mathjax.org /download/)
1. Place the Javascript library in the mathjax-latex directory (`/wp-content/plugins/mathjax-latex/MathJax`)
1. You can configure the plugin to load MathJax from a different URL to the default. See the options page.
== Changelog ==
= 1.3.8 =
1. Code style changes, per PHPCS 3.1.1 and WPCS 0.14
= 1.3.7 =
1. Update MathJax to 2.7.2
= 1.3.6 =
1. Update location of MathJax CDN
......@@ -148,5 +130,4 @@ CDN for javascript delivery. Upgrading is strongly recommended.
== Copyright ==
This plugin is copyright Phillip Lord, Newcastle University and is licensed
under GPLv2.
This plugin is copyright Phillip Lord, Newcastle University and is licensed under GPLv2.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment