Skip to content

Commit

Permalink
Merge pull request #10 from paulschreiber/phpcs-fixes
Browse files Browse the repository at this point in the history
PHPCS fixes
  • Loading branch information
paulschreiber committed Sep 11, 2015
2 parents a1f612d + 02a72f0 commit 0b8993d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
21 changes: 9 additions & 12 deletions mathjax-latex-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function plugin_options_menu() {

// save options if this is a valid post
if ( isset( $_POST['kblog_mathjax_latex_save_field'] ) && // input var okay
wp_verify_nonce( sanitize_text_field( $_POST['kblog_mathjax_latex_save_field'] ), 'kblog_mathjax_latex_save_action' ) // input var okay
wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_save_field'] ) ), 'kblog_mathjax_latex_save_action' ) // input var okay
) {
echo "<div class='updated settings-error' id='etting-error-settings_updated'><p><strong>Settings saved.</strong></p></div>\n";
$this->admin_save();
Expand All @@ -75,8 +75,8 @@ function plugin_options_menu() {
''
);

$selected_inline = get_option( 'kblog_mathjax_latex_inline' ) == 'inline' ? 'selected="true"' : '';
$selected_display = get_option( 'kblog_mathjax_latex_inline' ) == 'display' ? 'selected="true"' : '';
$selected_inline = get_option( 'kblog_mathjax_latex_inline' ) === 'inline' ? 'selected="true"' : '';
$selected_display = get_option( 'kblog_mathjax_latex_inline' ) === 'display' ? 'selected="true"' : '';

$syntax_input = <<<EOT
<select name="kblog_mathjax_latex_inline" id="kblog_mathjax_latex_inline">
Expand Down Expand Up @@ -105,9 +105,7 @@ function plugin_options_menu() {
$use_cdn = get_option( 'kblog_mathjax_use_cdn', true ) ? 'checked="true"' : '';

$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>.',
'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'
);
Expand Down Expand Up @@ -156,23 +154,23 @@ function admin_save() {
update_option( 'kblog_mathjax_force_load', array_key_exists( 'kblog_mathjax_force_load', $_POST ) ); // input var okay

if ( array_key_exists( 'kblog_mathjax_latex_inline', $_POST ) && isset( $_POST['kblog_mathjax_latex_inline'] ) && // input var okay
in_array( sanitize_text_field( $_POST['kblog_mathjax_latex_inline'] ), array( 'inline', 'display' ) ) // input var okay
in_array( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_inline'] ) ), array( 'inline', 'display' ), true ) // input var okay
) {
update_option( 'kblog_mathjax_latex_inline', sanitize_text_field( $_POST['kblog_mathjax_latex_inline'] ) ); // input var okay
update_option( 'kblog_mathjax_latex_inline', sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_inline'] ) ) ); // input var okay
}

update_option( 'kblog_mathjax_use_wplatex_syntax', array_key_exists( 'kblog_mathjax_use_wplatex_syntax', $_POST ) ); // input var okay

update_option( 'kblog_mathjax_use_cdn', array_key_exists( 'kblog_mathjax_use_cdn', $_POST ) ); // input var okay

if ( array_key_exists( 'kblog_mathjax_custom_location', $_POST ) && isset( $_POST['kblog_mathjax_custom_location'] ) ) { // input var okay
update_option( 'kblog_mathjax_custom_location', esc_url_raw( $_POST['kblog_mathjax_custom_location'] ) ); // input var okay
update_option( 'kblog_mathjax_custom_location', esc_url_raw( wp_unslash( $_POST['kblog_mathjax_custom_location'] ) ) ); // input var okay
}

if ( array_key_exists( 'kblog_mathjax_config', $_POST ) && isset( $_POST['kblog_mathjax_config'] ) && // input var okay
in_array( sanitize_text_field( $_POST['kblog_mathjax_config'] ), $this->config_options() ) // input var okay
in_array( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_config'] ) ), $this->config_options(), true ) // input var okay
) {
update_option( 'kblog_mathjax_config', sanitize_text_field( $_POST['kblog_mathjax_config'] ) ); // input var okay
update_option( 'kblog_mathjax_config', sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_config'] ) ) ); // input var okay
}
}

Expand Down Expand Up @@ -226,7 +224,6 @@ function admin_table_row( $head, $comment, $input, $input_id ) {
</tr>
<?php
}

} // class

function mathjax_latex_admin_init() {
Expand Down
4 changes: 2 additions & 2 deletions mathjax-latex.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static function add_script() {

// initialise option for existing MathJax-LaTeX users
if ( get_option( 'kblog_mathjax_use_cdn' ) || ! get_option( 'kblog_mathjax_custom_location' ) ) {
$mathjax_location = '//cdn.mathjax.org/mathjax/latest/MathJax.js';
$mathjax_location = 'https://cdn.mathjax.org/mathjax/latest/MathJax.js';
} else {
$mathjax_location = get_option( 'kblog_mathjax_custom_location' );
}
Expand Down Expand Up @@ -232,7 +232,7 @@ public static function mathjax_settings_link( $links, $file ) {
public static function filter_br_tags_on_math( $content ) {
return preg_replace_callback(
'/(<math.*>.*<\/math>)/isU',
function ( $matches ) {
function( $matches ) {
return str_replace( array( '<br/>', '<br />', '<br>' ) , '' , $matches[0] );
},
$content
Expand Down
10 changes: 8 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
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.0.0
Stable tag: 1.3.3
Tested up to: 4.3
Stable tag: 1.3.4
License: GPLv3

This plugin enables mathjax (http://www.mathjax.org) functionality for
Expand Down Expand Up @@ -60,6 +60,12 @@ MathJax-LaTeX is developed on

== Changelog ==

= 1.3.4 =

1. PHP code cleanup
1. Always use https URL for MathJax library
1. Updated "tested up to" to 4.3

= 1.3.3 =

1. Fixed inconsistent version numbers between readme and php file
Expand Down

0 comments on commit 0b8993d

Please sign in to comment.