Tagged: editor
- This topic has 12 replies, 2 voices, and was last updated 7 years, 2 months ago by
Jason.
-
AuthorPosts
-
-
December 3, 2014 at 11:56 am #2925
JasonKeymasterHere’s an interesting one:
piklist('field', array( 'type' => 'group', 'field' => 'test-group', 'label' => 'Test Group', 'fields' => array( array( 'type' => 'editor', 'field' => 'test', 'label' => 'Test Editor', 'options' => array( 'media_buttons' => false ) ) ) ));Pull the editor out of the group and it works just fine. But in there if you click the anchor button on some text, enter the url, and click “Add Link”, it takes you back to the editor but the anchor isn’t actually added. I also noticed the switching between Visual and Text causes issues. It seems like a javascript issue.
In case it’s important, I’m using this field on a settings page.
-
December 3, 2014 at 12:09 pm #2929
-
December 3, 2014 at 12:29 pm #2930
JasonKeymasterIt did! Perfect!
-
December 3, 2014 at 12:58 pm #2933
JasonKeymasterGreetings!
I found that if ‘quicktags’ => false then the anchor button stops working again. If true, then no problem. The strong and other buttons continue working fine in either case.
-
December 3, 2014 at 1:01 pm #2934
-
December 3, 2014 at 2:05 pm #2935
JasonKeymasterSo here’s what I did:
wp_editor('', 'test_editor', array( 'media_buttons' => false, 'teeny' => true, 'wpautop' => false, 'quicktags' => false )); piklist('field', array( 'type' => 'editor', 'field' => 'test_field', 'label' => 'Test Editor', 'options' => array( 'media_buttons' => false, 'teeny' => true, 'wpautop' => false, 'quicktags' => false ) ));I also tested using an underscore instead of hyphen in the field name, as I assumed you’re getting the editor id from the field and I read that hyphens can cause problems (which I usually use in field names).
On a side note, I can’t get ‘textarea_rows’ to work with Piklist, either, but it works just fine with the native function.
The conclusion, though, is that there’s an issue with Piklist. I had no anchor issues with the native wp_editor function.
-
December 3, 2014 at 2:46 pm #2938
JasonKeymasterAs far as the ‘textarea_rows’ issue goes, I was looking at the editor.php code and realized you’re using ‘editor_height’. I’m not exactly sure why. If I use that in the field properties instead of textarea_rows, then I’m able to adjust the height properly. I tried omitting ‘editor_height’ from the default options and using ‘textarea_rows’ instead, but for some reason that didn’t work.
-
December 3, 2014 at 3:06 pm #2939
JasonKeymasterI believe I figured out the issue, and it’s the default ‘textarea_name’ that Piklist derives from the $name and $_attributes variables. I believe it’s an illegal characters issue, as the name would then include hyphens, spaces, and equal signs.
If I include a ‘textarea_name’ in the field options, it fixes the issue.
-
December 3, 2014 at 3:32 pm #2940
JasonKeymasterOk.. so I’ve found that Piklist uses the textarea_name in order to know where to save the field. I’ll let you guys take it from here since I’m not sure how you’re using the textarea_name to save properly.
-
December 3, 2014 at 3:53 pm #2942
SteveKeymaster@jason– Appreciate you investigating the issue. It’s a bit tough to follow in your posts. Can you specify what the issue is and how to resolve?
-
December 3, 2014 at 4:45 pm #2943
JasonKeymasterHi Steve,
Sorry for the mixture of notes. 🙂
After some research, I realized that the wp_editor function relies on the ‘textarea_name’ to save to the settings. So while setting it to something simple fixes the editor issue, it breaks the editor actually saving to the database (a rather bittersweet victory).
I believe the final issue is that I’ve made a habit of using hyphens in database names. Normally this isn’t an issue, but I believe that wp_editor is attempting to build javascript variables based on the id and textarea_name, which is why hyphens cause issues.
As for a fix? I believe that’s really a wp_editor bug, so I’d just put a note in the docs to avoid using hyphens when dealing with the editor field.
-
-
December 4, 2014 at 5:50 pm #2961
-
-
AuthorPosts
- You must be logged in to reply to this topic.