芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/mathjax-latex/class-mathjax-latex-admin.php
. */ /** * Adium UI class. */ class MathJax_Latex_Admin { /** * Allow HTML tags (for use with KSES). * * @var array */ public static $admin_tags = [ 'input' => [ 'type' => [], 'name' => [], 'id' => [], 'disabled' => [], 'value' => [], 'checked' => [], ], 'select' => [ 'name' => [], 'id' => [], ], 'option' => [ 'value' => [], 'selected' => [], ], ]; /** * Hook for the menu item function. */ public function __construct() { add_action( 'admin_menu', [ $this, 'admin_page_init' ] ); } /** * Add the MathJax-LaTeX menu item to the Settings menu. */ public function admin_page_init() { add_options_page( 'MathJax-LaTeX', 'MathJax-LaTeX', 'manage_options', 'kblog-mathjax-latex', [ $this, 'plugin_options_menu' ] ); } /** * Render the settings page. */ public function plugin_options_menu() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } $this->table_head(); // Save options if this is a valid post. if ( isset( $_POST['kblog_mathjax_latex_save_field'] ) && // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_save_field'] ) ), 'kblog_mathjax_latex_save_action' ) // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected ) { echo "
Settings saved.
\n"; $this->admin_save(); } $checked_force_load = ''; if ( get_option( 'kblog_mathjax_force_load' ) ) { $checked_force_load = 'checked="true"'; } $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.', "
", '' ); $selected_inline = get_option( 'kblog_mathjax_latex_inline' ) === 'inline' ? 'selected="true"' : ''; $selected_display = get_option( 'kblog_mathjax_latex_inline' ) === 'display' ? 'selected="true"' : ''; $syntax_input = <<
Inline
Display
EOT; $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' ); $wp_latex_disabled = method_exists( 'WP_LaTeX', 'init' ) ? "disabled='disable'" : ''; $wp_latex_disabled_warning = method_exists( 'WP_LaTeX', 'init' ) ? 'Disable wp-latex to use this syntax.' : ''; $use_wp_latex_syntax = get_option( 'kblog_mathjax_use_wplatex_syntax', false ) ? "checked='true'" : ''; $this->admin_table_row( 'Use wp-latex syntax?', "Allows use of the \$latex$ syntax, but conflicts with wp-latex. $wp_latex_disabled_warning", "
", 'kblog_mathjax_use_wplatex_syntax' ); $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
MathJax CDN Terms of Service
.', "
", 'use_cdn' ); $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?', 'If you are not using the MathJax CDN enter the location of your MathJax script.', "
", 'kblog_mathjax_custom_location' ); $options = $this->config_options(); $select_string = "
\n"; foreach ( $options as $i ) { $selected = get_option( 'kblog_mathjax_config', 'default' ) === $i ? "selected='true'" : ''; $select_string .= "
$i
\n"; } $select_string .= '
'; $this->admin_table_row( 'MathJax Configuration', "See the
MathJax documentation
for more details.", $select_string, 'kblog_mathjax_config' ); $this->table_foot(); } /** * List of MathJax configuration options. */ public function config_options() { $options = [ 'default', 'Accessible', 'TeX-AMS_HTML', 'TeX-AMS-MML_HTMLorMML', ]; return $options; } /** * Save configuration changes to the database. */ public function admin_save() { if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { check_ajax_referer( 'kblog_mathjax_latex_save_field', 'security' ); } update_option( 'kblog_mathjax_force_load', array_key_exists( 'kblog_mathjax_force_load', $_POST ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected if ( array_key_exists( 'kblog_mathjax_latex_inline', $_POST ) && isset( $_POST['kblog_mathjax_latex_inline'] ) && // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected in_array( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_inline'] ) ), [ 'inline', 'display' ], true ) // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected ) { update_option( 'kblog_mathjax_latex_inline', sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_latex_inline'] ) ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected } update_option( 'kblog_mathjax_use_wplatex_syntax', array_key_exists( 'kblog_mathjax_use_wplatex_syntax', $_POST ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected update_option( 'kblog_mathjax_use_cdn', array_key_exists( 'kblog_mathjax_use_cdn', $_POST ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected if ( array_key_exists( 'kblog_mathjax_custom_location', $_POST ) && isset( $_POST['kblog_mathjax_custom_location'] ) ) { // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected update_option( 'kblog_mathjax_custom_location', esc_url_raw( wp_unslash( $_POST['kblog_mathjax_custom_location'] ) ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected } if ( array_key_exists( 'kblog_mathjax_config', $_POST ) && isset( $_POST['kblog_mathjax_config'] ) && // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected in_array( sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_config'] ) ), $this->config_options(), true ) // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected ) { update_option( 'kblog_mathjax_config', sanitize_text_field( wp_unslash( $_POST['kblog_mathjax_config'] ) ) ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected } } /** * Render configuration page header. */ public function table_head() { ?>
Mathjax-Latex
The following lists configuration options for the MathJax-LaTeX plugin.