Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Last active August 29, 2015 14:13
Show Gist options
  • Save designbuildtest/2e29b7dcb9a5583ee7ab to your computer and use it in GitHub Desktop.
Save designbuildtest/2e29b7dcb9a5583ee7ab to your computer and use it in GitHub Desktop.
$button_slug = 'fetch';
$js_button_data = array(
'qt_button_text' => __( 'iframe' ),
'button_tooltip' => __( 'iframe' ),
'icon' => 'dashicons-admin-appearance',
'l10ncancel' => __( 'Cancel' ),
'l10ninsert' => __( 'Insert' ),
'modalHeight' => '400',
//'width' => 500,
);
$additional_args = array(
'cmb_metabox_config' => 'shortcode_button_cmb_config',
);
$button = new _Shortcode_Button_( $button_slug, $js_button_data, $additional_args );
function shortcode_button_cmb_config( $button_data ) {
return array(
'id' => 'myplugin_shortcode_'. $button_data['slug'],
'fields' => array(
array(
'name' => __( 'URL/link' ),
'id' => 'url',
'type' => 'text_url',
'protocols' => array( 'http', 'https' ),
),
array(
'name' => __( 'Scrolling' ),
'id' => 'scrolling',
'type' => 'select',
'options' => array( 'no' => __( 'No' ), 'yes' => __( 'Yes' ), ),
),
),
'show_on' => array( 'key' => 'options-page', 'value' => $button_data['slug'] ),
);
}
function iframe_shortcode( $atts ) {
extract( shortcode_atts( array(
'url' => '',
'scrolling' => 'no',
'width' => '100%',
'height' => '500px',
'class' => '',
), $atts ) );
if ( empty( $url ) ) {
return false;
} else {
return '<iframe class="' . $class . '" src="' . $url . '" width="' . $width . '" height="' . $height . '" scrolling="' . $scrolling . '" frameborder="0" marginheight="0"></iframe>';
}
}
add_shortcode( 'fetch', 'iframe_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment