1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
<?php
class CMB2_Type_Oembed extends CMB2_Type_Text {
public function render( $args = array() ) {
$field = $this->field;
$meta_value = trim( $field->escaped_value() );
$oembed = ! empty( $meta_value )
? cmb2_ajax()->get_oembed( array(
'url' => $field->escaped_value(),
'object_id' => $field->object_id,
'object_type' => $field->object_type,
'oembed_args' => array(
'width' => '640',
),
'field_id' => $this->_id( '', false ),
) )
: '';
return parent::render( array(
'class' => 'cmb2-oembed regular-text',
'data-objectid' => $field->object_id,
'data-objecttype' => $field->object_type,
) )
. '<p class="cmb-spinner spinner"></p>'
. '<div id="' . $this->_id( '-status' ) . '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>';
}
}