Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live previews don't work for oEmbed fields within a repeatable group #1157

Closed
johnbillion opened this issue Aug 1, 2018 · 1 comment
Closed

Comments

@johnbillion
Copy link
Contributor

Expected Behavior:

When an oembed field type is present within a repeatable group, it should function as normal.

Actual Behavior:

The live Ajax-powered embed preview does not function, because the call to cmb2_ajax() never triggers, and thus its Ajax handlers are never registered. Ref:

CMB2/includes/CMB2.php

Lines 1444 to 1449 in 393388b

case 'oembed':
// Initiate oembed Ajax hooks.
cmb2_ajax();
break;

Steps to reproduce (I have confirmed I can reproduce this issue on the trunk branch):

  1. Register a repeatable group and place an oembed field type in it.
  2. Paste an embed URL into the oEmbed URL input field.
  3. Observe that the live preview doesn't function. The Ajax call responds with 0 because there's no registered Ajax handler for the oEmbed preview.

CMB2 Field Registration Code:

add_action( 'cmb2_init', function() {
	// Meta box
	$cmb_main_box = new_cmb2_box( [
		'id'           => 'main_box',
		'title'        => 'Main Content',
		'object_types' => [
			'post',
		],
	] );

	// Repeatable embed group
	$cmb_embed_group = $cmb_main_box->add_field( [
		'id'         => 'embeds',
		'repeatable' => true,
		'type'       => 'group',
	] );

	// Repeatable field: embed
	$cmb_main_box->add_group_field( $cmb_embed_group, [
		'id'      => 'url',
		'name'    => 'Embed URL',
		'type'    => 'oembed',
	] );
} );
@johnbillion johnbillion changed the title Previews don't work for oEmbed fields within a repeatable group Live previews don't work for oEmbed fields within a repeatable group Aug 1, 2018
@Fiorinol
Copy link

Fiorinol commented Sep 2, 2019

I'm having this issue as well and I've noticed nobody commented on it in more than a year. Is there a way to register an ajax handler for this?

lipemat added a commit to lipemat/CMB2 that referenced this issue Apr 28, 2020
* upstream/develop: (93 commits)
  Ensure to enqueue wp-color-picker
  Add props for CMB2#1331
  Update "develop" bootstrap classname
  Proposal of CODE OF CONDUCT File
  Update version/copyright in scripts/stylesheets
  Fix issues with some tests to get them all passing
  `CMB2::is_box_type()` now also checks for taxonomies if box is registered to "term" object type.
  Prepare for 2.7.0 release
  Add all missing props/udpates to changelog
  bump tested-to value
  Rename CMB2_hookup to CMB2_Hookup Fixes CMB2#1328
  Validate composer.json
  Tested Up To confirmations.
  Update issue templates
  Add license file to meet Community standards
  Add changelog for the register_rest_field_cb param
  Abstract some aspects of the getting/setting of box rest fields to make custom handling easier
  Add ability to short-circuit the register_rest_field with a callback. Allows registering callback with a different rest slug
  Oops, send the fallback value to the box_types method
  Add props for CMB2#1238
  Fixes CMB2#1238 by merging with changes, and add CMB2::is_box_type method for checking. Fixes CMB2#1158
  Add props for CMB2#1314
  minify
  minify
  Re-add padding to textareas for readability
  Fix alpha color picker sample color styling
  clarify coment
  limit to 5.3 branch
  update block editor radio fix
  initial 5.3 prep work
  Add new "cmb2_display_class_{$fieldtype}" filter and field "display_class" parameter to allow specifying the class to use to display the field (in admin columns, etc)
  Fix another place where taxonomy_select_hierarchical was missed
  Add props for CMB2#1296 & CMB2#1297
  Add props for CMB2#1300
  Add props for CMB2#1307
  Update npm dependencis. Fixes CMB2#1308
  Remove grunt-contrib-compress and grunt-combine-media-queries to cut down on npm dependencies
  taxonomy_select_hierarchical is added in order to save correctly in to database
  Fix tests broke by introduction of character counter field property
  Fix issue introduced in 7cb3e00 where field was updated not not returned, breaking things
  If field has supporting data (e.g. file), add supporting data to field data (i.e supporting field id/value)
  Add changelog and props for CMB2#1300
  Update .min file for CMB2#1300
  Add comments to document changes in CMB2#1300
  Include .CodeMirror class in sortable exclusions
  Run the field-specific actions for all fields (including fields in groups). Fixes CMB2#1157
  Escaping Improvements to File Base
  Escaping improvements to File Fields
  Add changelog and props for CMB2#1276
  Refactor character-counter integration
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants