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

AceEditor - PHP syntax highlighting without opening a PHP tag #2391

Closed
corradomatt opened this issue Jun 12, 2015 · 3 comments
Closed

AceEditor - PHP syntax highlighting without opening a PHP tag #2391

corradomatt opened this issue Jun 12, 2015 · 3 comments

Comments

@corradomatt
Copy link
Contributor

yes, I know...this is now how PHP files work in the "real world". A PHP file will always begin with a ``<?php` and anyone who knows even a tiny amount of PHP knows this. However, there are several users who just blindly copy and paste PHP code from the web for their WordPress site (I know, appalling right?). It occured to me that maybe it would be good to just include the opening PHP tags when using the ACE editor to allow users to add PHP blocks to their theme options. (I hate myself for even thinking of giving this ability to a user in theme options, but I digress).

The ace editor allows for us to give the user the option to omit the opening PHP tag and it will still provide code formating and linting. The problem is that to use it, we'd need to alter how we set the mode... session.setMode({path:"ace/mode/php", inline:true}).

I have tested this within Redux and it works great, but I'm not sure if this is something that other users would want/need and if it's worth making a pull request about. From my vantage point, I think the best implementation would be something like this....

  1. Ace Editor field mode would be set to php-inline
  2. In field_ace_editor.js around line 37 we run with this.....
if ( $( element ).attr( 'data-mode' ) == 'php-inline' ) {
    aceeditor.getSession().setMode( {path:"ace/mode/php", inline:true} );
} else {
    aceeditor.getSession().setMode( "ace/mode/" + $( element ).attr( 'data-mode' ) );
}

Ultimately, I'm not sure the best approach here or if it's even necessary for the community.

For reference, you can see my question to the ace_editor team here - ajaxorg/ace#2542 (comment)

@dovy
Copy link
Member

dovy commented Jun 13, 2015

Interesting. We could make it a feature via argument pretty easily...

@kprovance
Copy link
Member

Did you try it, Matt? Did it work? If so, do a pull request and I'll give it a spin. :)

@kprovance
Copy link
Member

Please feel free to submit a pull request. Closing issue.

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

3 participants