content-cards icon indicating copy to clipboard operation
content-cards copied to clipboard

CPT support + custom TinyMCE locations

Open khromov opened this issue 10 years ago • 6 comments

As per: https://wordpress.org/support/topic/script-not-loading-with-acf-wysiwyg-editor?replies=1#post-7454794

  • [ ] Make sure Content Cards work with custom post types.
  • [ ] See if we can support the most common use cases of TinyMCE outside the post editor:
    • [ ] In ACF (on posts)
    • [ ] In ACF (on settings pages)
    • [ ] In the Black Studio TinyMCE Widget plugin

khromov avatar Sep 22 '15 09:09 khromov

yeah, I am looking into that, too.

As for CPT, Content Cards should already work in all of them. The problem is when wp_editor is loaded in unusual places (settings, tools, etc.) as now we load most of javascript only on post pages in WP Admin, due to this check:

    if ( ! isset( get_current_screen()->id ) || get_current_screen()->base != 'post' ) {
        return;
    }

We need a better check if wp_editor() is being loaded.

ideag avatar Sep 22 '15 09:09 ideag

I think I have a solution for this. Instead of using admin_enqueue_scripts hook, we should use wp_enqueue_editor hook to enqueue content-cards.js.This way it would be loaded every time wp_editor is loaded, even on front end. I'll implement and test it out later today.

ideag avatar Sep 22 '15 10:09 ideag

Sounds awesome :+1:

khromov avatar Sep 22 '15 10:09 khromov

But I see a different problem - if we use this not in a post context, there is no post_id to use for data cache'ing

ideag avatar Sep 22 '15 12:09 ideag

@ideag Options table for storage perhaps? Wouldn't that also make it possible to share cache if multiple pages embed the same URL?

khromov avatar Sep 22 '15 14:09 khromov

@khromov hmm, I discarded idea of storage in optionsearly on, and chose postmeta because postmeta has internal gabage collection (gets deleted when the post gets deleted). And because of possibility that the same url is used on several posts, gabage collection would be tricky in options table.

ideag avatar Sep 22 '15 17:09 ideag