Forums / Bug Reports / Bug in custom editor logic (I think. At least typo in documentation)

Bug in custom editor logic (I think. At least typo in documentation)

Views: 521

Results 1 to 3 of 3
23 Jul 2015, 2:34 AM
#1
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Bug in custom editor logic (I think. At least typo in documentation)

I'll start with the typo.

in admin\includes\init_includes\init_html_editor.php there is the following hint/comments:

/**

  • List of potential editors apps
  • CONSTANTS are used for language-specific display names, and are defined in /YOUR_ADMIN_FOLDER/includes/languages/extra_definitions/editor_EDITORNAME.php
  • To add additional editors, add your own entries to the $editors_list array by creating a NEW FILE in /YOUR_ADMIN_FOLDER/includes/extra_functions/editor_EDITORNAME.php containing just one line of PHP:
  • <?php $editors_list['NAME_OF_EDITOR'] = array('desc' => EDITOR_CONSTANT, 'handler' => 'editorhandlerfilename.php', 'special_needs' => '');
  • NOTE: THERE SHOULD BE NO NEED TO EDIT ANYTHING BELOW THIS LINE:
    */

It would seem to me the paths of the language and function is missing a level. It should read (I think):

/**

  • List of potential editors apps
  • CONSTANTS are used for language-specific display names, and are defined in /YOUR_ADMIN_FOLDER/includes/languages/english/extra_definitions/editor_EDITORNAME.php
  • To add additional editors, add your own entries to the $editors_list array by creating a NEW FILE in /YOUR_ADMIN_FOLDER/includes/functions/extra_functions/editor_EDITORNAME.php containing just one line of PHP:
  • <?php $editors_list['NAME_OF_EDITOR'] = array('desc' => EDITOR_CONSTANT, 'handler' => 'editorhandlerfilename.php', 'special_needs' => '');
  • NOTE: THERE SHOULD BE NO NEED TO EDIT ANYTHING BELOW THIS LINE:
    */

Making that change got me somewhere, but I was still having trouble getting the friendly name of the editor to be shown in the drop-down. I think I discovered that, perhaps, the functions are being read in before the language defines, but they use the language defines so it ends up reporting the constant name as a literal instead of the string it represents. In other words, "EDITOR_CONSTANT" would be shown in the drop-down instead of "my test" (despite the constant being properly registered, as confirmed by a simply echo test in any file that loads after the languages). I can "fix" this by putting the define in the function, something like this:

<?php
define("EDITOR_TEST", "Test");
 $editors_list['TEST']  = array('desc' => EDITOR_TEST,  'handler' => 'test.php',  'special_needs' => '');
``` but clearly that's not the proper way to do it.

Did I do something wrong?  I'm fairly sure this is a bug and you'll see if you attempt to follow your own instructions, exactly and/or with my modifications, for adding an editor.
23 Jul 2015, 2:44 AM
#2
s_mack avatar

s_mack

Totally Zenned

Join Date:
Jun 2005
Location:
Kelowna, BC Canada
Posts:
1,033
Plugin Contributions:
4

Re: Bug in custom editor logic (I think. At least typo in documentation)

One solution: ignore the comments/notes (which contain incorrect paths anyway) and override the init_html_editor.php file entirely, and simply do what the comments say not to do and add the editor into the list. That way the define is properly read-in.

It works.

So I'm happy. No need to fix this for me specifically, and obviously there's not many people bothered by it so just take a look at the comments for 1.6 and make sure they are consistent with reality, and perhaps take a look at the order in which extra_defines are read in relation to extra_functions. All on the admin side (I never looked at front end for any of this)