Syntax_Highlighter::shortcode( array $atts, string $content = '' )

Description #

Render shortcode [apcode].

Parameters #

  • $atts
    array (Required) Attributes.
  • $content
    string (Optional) Content. Default value: ''

Source #

File: addons/syntaxhighlighter/syntaxhighlighter.php

	public function shortcode( $atts, $content = '' ) {
		$atts = wp_parse_args(
			$atts,
			array(
				'language' => 'plain',
				'inline'   => false,
			)
		);

		$tag     = $atts['inline'] ? 'code' : 'pre';
		$content = preg_replace( '/<br(\s+)?\/?>/i', '', $content );
		$klass   = 'class="brush: ' . esc_attr( $atts['language'] ) . '"';
		$content = str_replace( array( '<pre', '<code' ), array( '<pre ' . $klass, '<code ' . $klass ), $content );

		return $content;
	}

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