AnsPress_Syntax_Highlighter::mce_before_init( array $options )

Description #

Modify tinyMCE options so that we can add our pre tags along with language code.

Our language code is stored in a custom attribute aplang. Also whitelist contenteditable attribute so that we can prevent editing pre tag in editor.

Parameters #

  • $options
    array (Required) TinyMCE options.

Source #

File: addons/free/syntaxhighlighter.php

	public static function mce_before_init( $options ) {
		if ( ! isset( $options['extended_valid_elements'] ) ) {
			$options['extended_valid_elements'] = '';
		} else {
			$options['extended_valid_elements'] .= ',';
		}

		if ( ! isset( $options['custom_elements'] ) ) {
			$options['custom_elements'] = '';
		} else {
			$options['custom_elements'] .= ',';
		}

		$options['extended_valid_elements'] .= 'pre[aplang|contenteditable]';
		$options['custom_elements']         .= 'pre[aplang|contenteditable]';

		return $options;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment