Closed ajtruckle closed 4 years ago
you should really read the docs :stuck_out_tongue:
you should really read the docs 😛 https://github.com/EnlighterJS/documentation/blob/master/wordpress/FilterHooks.md#filterenlighter_languages
You are right! I suppose I am not used to looking through GitHub to find the documentation. I get frustrated too when I get questions answers in the help system that I have provided. :)
I have been successful with this and I wanted to go over a few things with you if I may.
Observation 1
When I started writing my code snippet to remove the languages (using your sample to start from) my editor was raising syntax errors. It did not like lines of code like unset $langs['Java'];
. What I had to do was insert braces, so my final code looked like this:
function mm_ejs_languages($langs){
unset ($langs['Java']);
unset ($langs['Javascript']);
unset ($langs['JSON']);
unset ($langs['Python']);
unset ($langs['Ruby']);
unset ($langs['C']);
unset ($langs['RUST']);
unset ($langs['LUA']);
unset ($langs['Matlab']);
unset ($langs['NSIS']);
unset ($langs['Diff']);
unset ($langs['VHDL']);
unset ($langs['Avr Assembly']);
unset ($langs['Generic Assembly']);
unset ($langs['Kotlin']);
unset ($langs['Squirrel']);
return $langs;
}
// add a custom filter to modify the language list
add_filter('enlighter_languages', 'mm_ejs_languages');
Observation 2 When I create the snippet (using my snippets plugin) it offers where to run the snippet:
I assumed the first option Run snippet everywhere.
Observation 3 This might be more appropriate in a distinct issue. In your language drop-down list you have:
The first entry is Default (Global settings). This description is fine from the perspective of the website author as he knows about the plugin EnlighterJS and (if he has a good memory) knows what his global settings choice was. But this will not mean anything to a standard user of my support forum who may want to insert code. Therefore, my suggestion is to rephrase that as (for example):
Default (Generic)
print_r
to display the full list3. you can also override the whole language list/entries - it is an associative array which contains the language identifier as key and the display name as value. for debugging use
print_r
to display the full list
I understand. I had not thought of doing things that way and I can see the merits of that.
According to the enlighter plugin in Wordpress it says these are the available language ids:
Does that cover all of them? I have a side question though based on your suggestion. How can I build the new text string "Default (xxxx)" where xxxx is the global setting description?, and what would the id counter be, default
?
again...please read the docs, especially the filter hooks - then just try+error and no, it doesn't cover all of them - you can use print_r within the filter hook to get a full list or take look into the contextual help on the settings page - it includes a dynamic list
look into the contextual help on the settings page - it includes a dynamic list
Yes, that is where I got the list from:
the list is much longer by default, but in case you've already modified the list via the filter hooks the contextual help will also change
Doh! Gotcha.
Although, that dynamic list does not include "default". I will investigate with print_r
.
the list only includes the specific language shortcodes, not all languages
According to print_r
:
Array
(
[Generic Highlighting] => generic
[CSS (Cascading Style Sheets)] => css
[HTML (Hypertext Markup Language)] => html
[Java] => java
[Javascript] => js
[JSON] => json
[Markdown] => md
[PHP] => php
[Python] => python
[Ruby] => ruby
[Batch MS-DOS] => msdos
[Shell Script] => shell
[SQL] => sql
[XML] => xml
[C] => c
[C++] => cpp
[C#] => csharp
[RUST] => rust
[LUA] => lua
[Matlab] => matlab
[NSIS] => nsis
[Diff] => diff
[VHDL] => vhdl
[Avr Assembly] => avrasm
[Generic Assembly] => asm
[Kotlin] => kotlin
[Squirrel] => squirrel
[Ini/Conf Syntax] => ini
[RAW Code] => raw
[No Highlighting] => no-highlight
)
This list does not include the Default (Global Settings) entry to which my discussion was about.
ok sry, then it's currently not possible to change this
OK. No worries. have to live with it for now. :)
Is it possible to reduce the list of languages displayed in the drop-down list?
Just curious.