You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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....
Ace Editor field mode would be set to php-inline
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.
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....
mode
would be set tophp-inline
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)
The text was updated successfully, but these errors were encountered: