humanmade / Custom-Meta-Boxes

Lets you easily create metaboxes with custom fields that will blow your mind.
522 stars 124 forks source link

CMBData is output repeatedly #411

Closed rmccue closed 7 years ago

rmccue commented 7 years ago
screenshot 2017-02-22 11 10 01
mikeselander commented 7 years ago

Hey @rmccue or @tareiking I can't replicate this locally, could you give me some more context on the fieldset and/or amount of data causing this? Like, is it a ton of individual or repeated WYSIWYG fields making this?

Ignore the above, I just figured it out :)

mikeselander commented 7 years ago

As an update, this is looking like a core issue to me. Core allows you to re-register the same localize variable over and over again without any checks whether it's already been registered already. I see no easy way to see if we've already registered this script as localized but will keep digging over time.

barryceelen commented 7 years ago

A workaround might be to check if cmb-scripts is already enqueued with wp_script_is() before adding the action in the CMB_Meta_Box construct method or inside enqueue_scripts() method.

if ( ! wp_script_is( 'cmb-scripts' ) ) {
    // Enqueue and/or localize 'cmb-scripts'.
}