[wp-trac] [WordPress Trac] #42618: wp.mce.views API not using registered shortcode functions

WordPress Trac noreply at wordpress.org
Tue Jan 16 18:47:08 UTC 2018


#42618: wp.mce.views API not using registered shortcode functions
---------------------------+-----------------------
 Reporter:  netsurfer2705  |       Owner:
     Type:  defect (bug)   |      Status:  reopened
 Priority:  normal         |   Milestone:
Component:  TinyMCE        |     Version:
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+-----------------------
Changes (by netsurfer2705):

 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 Replying to [comment:5 azaozz]:
 >  I do not agree. There should be no need to change any JS (functions) if
 one correctly registered a valid and functioning shortcode!
 >  BTW: Even if I am willing to do so, the affected functions are spread
 all over the core, none of them intended to be overwritten. And there is
 also nearly no documentation, although the "basic system" was already
 introduced with version 3.5!
 >
 > I'm not exactly sure what you're saying here. You seem to be changing
 core's functionality (how galleries look/work)

 No, I changed the [gallery] shortcode function (functionality) ...

 > but don't want to change the functions that implement that
 functionality?

 Sure, I will. I deregistered the core function and registered my own new
 one (for the shortcode). So far no problem. But as you may know, there are
 a lot of other (mainly JS) functions/ functionalities that belong to the
 gallery shortcode.

 >
 > Editor "views" have nothing to do with shortcodes. They can be used to
 show a preview of a rendered shortcode inside the editor, that's all.

 Sorry, I do not understand the logic behind your statement!?
 As the shortcode itself keeps the same (unchanged), but the functions
 /functionality) is changed, the editor "views" either
 - needs to be replaced by another one (self scripted), or
 - should use the correctly registered shortcode function(s).

 Unfortunately none of the two options are possible. At least I did not
 find an option (without changing core files, which is to avoid under all
 circumstances).

 This is one of my problems I currently faced with - couldn't even find a
 way to "deregister/ unload" the MCE view. I have already sripted my own
 gallery preview(s) in a meta box. And I also managed to replace the
 shortcode in the content with a "placeholder text". But user can still
 click on the gallery (for inline editing) which "messes up" everything.

 > If you want to change how gallery previews work, you will have to write
 the code for the previews yourself :)

 Yes, I am willing to do so. ;-)
 But how to replace/ get ride of the existing view? Tips and help would be
 very much appreciated!



 >
 > Swissspidy pointed you at the proper direction already, there are
 plugins that do the things you want to do, have a look at their code,
 that's how open source works (assuming your plugin will be open source
 too).

 Sorry, but if I am not totally mistaken, Swissspidy's tip is helpful if
 one would "add a new feature". But not if one wants to chnage an existing
 feature (like the gallery shortcode).

 I am working on this for months now. The "problem" is, that the whole
 gallery thing, including the shortcode) is not scripted in a way, that it
 could properly be replaced/ overwritten! There are lots of functions
 without any hooks, some parts of the database statements are hardcoded and
 the AJAX request for getting the image IDs for a gallery is lecking an
 info about the gallery number (in case there is more than one gallery).
 And these are just some of the "problems" you are confronted with when
 trying to change the gallery shortcode functionality.

 I was able to "solve/ circumvent" most of these problems. But with the
 editor I got stuck. So I would be very thankful if you could help me, or
 give me some advice/ tipps, how to "handle" the view/ preview thing in the
 editor. :-)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/42618#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list