Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add new language #4

Closed
hotsun opened this issue Nov 2, 2018 · 2 comments
Closed

Unable to add new language #4

hotsun opened this issue Nov 2, 2018 · 2 comments

Comments

@hotsun
Copy link

hotsun commented Nov 2, 2018

I am trying to add new languages for yaml and bash

	public function get_languages(): array {
		$languages = [
			'yaml'		  => [
				'name'       => esc_html__( 'yaml', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'matchBrackets'     => true,
					'matchTags'         => [
						'bothTags' => true,
					]
				],				
			],
			'bash'        => [
				'name'       => esc_html__( 'bash', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'matchBrackets'     => true,
					'matchTags'         => [
						'bothTags' => true,
					]
				],
			],
			'css'        => [
				'name'       => esc_html__( 'CSS', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'matchBrackets'     => true,
				],
			],
			'html'       => [
				'name'       => esc_html__( 'HTML', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'autoCloseTags'     => true,
					'matchTags'         => [
						'bothTags' => true,
					],
					'mode'              => 'htmlmixed',
				],
			],
			'javascript' => [
				'name'       => esc_html__( 'JavaScript', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'matchBrackets'     => true,
				],
			],
			'json'       => [
				'name'       => esc_html__( 'JSON', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'matchBrackets'     => true,
					'mode'              => [
						'name' => 'javascript',
						'json' => true,
					],
				],
			],
			'php'        => [
				'name'       => esc_html__( 'PHP', 'shiny-code' ),
				'codemirror' => [
					'autoCloseBrackets' => true,
					'autoCloseTags'     => true,
					'matchBrackets'     => true,
					'matchTags'         => [
						'bothTags' => true,
					],
				],
			],
		];

		return apply_filters( 'shiny_code_languages', $languages );
	}

But I can only see the code is highlighted in backend edit mode, not in frontend post. Any reference document will be appreciated.

@hotsun
Copy link
Author

hotsun commented Nov 3, 2018

@bradyvercher
Copy link
Member

Glad to hear you were able to get things working, @hotsun. Rather than modifying files in the plugin folder, I would recommend creating an add-on for your customizations or incorporate them in a child theme. This comment shows how you can load individual language files using that approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants