Syntax_Highlighter::scripts()

Description #

Register scripts and styles.

Source #

File: addons/syntaxhighlighter/syntaxhighlighter.php

	public function scripts() {
		$js_url  = ANSPRESS_URL . '/addons/syntaxhighlighter/syntaxhighlighter/scripts/';
		$css_url = ANSPRESS_URL . '/addons/syntaxhighlighter/syntaxhighlighter/styles/';

		echo '<script type="text/javascript">AP_Brushes = ' . wp_json_encode( $this->brushes ) . ';</script>';
		wp_enqueue_script( 'syntaxhighlighter-core', $js_url . 'shCore.js', array( 'jquery', 'anspress-common' ), AP_VERSION, true );
		wp_enqueue_script( 'syntaxhighlighter-autoloader', $js_url . 'shAutoloader.js', array( 'syntaxhighlighter-core' ), AP_VERSION, true );
		wp_enqueue_script( 'syntaxhighlighter', ANSPRESS_URL . 'addons/syntaxhighlighter/script.js', array( 'syntaxhighlighter-core' ), AP_VERSION, true );

		// Register theme stylesheets.
		wp_enqueue_style( 'syntaxhighlighter-core', $css_url . 'shCore.css', array(), AP_VERSION );
		wp_enqueue_style( 'syntaxhighlighter-theme-default', $css_url . 'shThemeDefault.css', array( 'syntaxhighlighter-core' ), AP_VERSION );

		ob_start();
		?>
			aplang = aplang||{};
			aplang.shLanguage = '<?php esc_attr_e( 'Language', 'anspress-question-answer' ); ?>';
			aplang.shInline = '<?php esc_attr_e( 'Is inline?', 'anspress-question-answer' ); ?>';
			aplang.shTxtPlholder = '<?php esc_attr_e( 'Insert code snippet here ...', 'anspress-question-answer' ); ?>';
			aplang.shButton = '<?php esc_attr_e( 'Insert to editor', 'anspress-question-answer' ); ?>';
			aplang.shTitle = '<?php esc_attr_e( 'Insert code', 'anspress-question-answer' ); ?>';

			window.apBrushPath = "<?php echo esc_url( ANSPRESS_URL . '/addons/syntaxhighlighter/syntaxhighlighter/scripts/' ); ?>";
		<?php
		$script = ob_get_clean();
		wp_add_inline_script( 'syntaxhighlighter', $script, 'before' );
	}

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