Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: vine.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Vine shortcode
[2] Fix | Delete
* The service is now archived, but existing embeds are still accessible.
[3] Fix | Delete
*
[4] Fix | Delete
* Examples:
[5] Fix | Delete
* Vine embed code:
[6] Fix | Delete
* <iframe class="vine-embed" src="https://vine.co/v/bjHh0zHdgZT" width="600" height="600" frameborder="0"></iframe>
[7] Fix | Delete
* <script async src="//platform.vine.co/static/scripts/embed.js" charset="utf-8"></script>
[8] Fix | Delete
*
[9] Fix | Delete
* URL example:
[10] Fix | Delete
* https://vine.co/v/bjHh0zHdgZT/
[11] Fix | Delete
*
[12] Fix | Delete
* Embed shortcode examples:
[13] Fix | Delete
* [embed]https://vine.co/v/bjHh0zHdgZT[/embed]
[14] Fix | Delete
* [embed width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
[15] Fix | Delete
* [embed type="postcard" width="300"]https://vine.co/v/bjHh0zHdgZT[/embed]
[16] Fix | Delete
*
[17] Fix | Delete
* @package automattic/jetpack
[18] Fix | Delete
*/
[19] Fix | Delete
[20] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[21] Fix | Delete
exit( 0 );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Handle Vine embeds.
[26] Fix | Delete
*
[27] Fix | Delete
* @param array $matches Results after parsing the URL using the regex in wp_embed_register_handler().
[28] Fix | Delete
* @param array $attr Embed attributes.
[29] Fix | Delete
* @param string $url The original URL that was matched by the regex.
[30] Fix | Delete
* @param array $rawattr The original unmodified attributes.
[31] Fix | Delete
* @return string The embed HTML.
[32] Fix | Delete
*/
[33] Fix | Delete
function vine_embed_video( $matches, $attr, $url, $rawattr ) {
[34] Fix | Delete
$max_height = 300;
[35] Fix | Delete
$type = 'simple';
[36] Fix | Delete
[37] Fix | Delete
// Only allow 'postcard' or 'simple' types.
[38] Fix | Delete
if (
[39] Fix | Delete
isset( $rawattr['type'] )
[40] Fix | Delete
&& 'postcard' === $rawattr['type']
[41] Fix | Delete
) {
[42] Fix | Delete
$type = 'postcard';
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
$vine_size = Jetpack::get_content_width();
[46] Fix | Delete
[47] Fix | Delete
// If the user enters a value for width or height, we ignore the Jetpack::get_content_width().
[48] Fix | Delete
if ( isset( $rawattr['width'] ) || isset( $rawattr['height'] ) ) {
[49] Fix | Delete
// 300 is the minimum size that Vine provides for embeds. Lower than that, the postcard embeds looks weird.
[50] Fix | Delete
$vine_size = max( $max_height, min( $attr['width'], $attr['height'] ) );
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
if ( empty( $vine_size ) ) {
[54] Fix | Delete
$vine_size = $max_height;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
$url = 'https://vine.co/v/' . $matches[1] . '/embed/' . $type;
[58] Fix | Delete
$vine_html = sprintf(
[59] Fix | Delete
'<span class="embed-vine" style="display: block;"><iframe class="vine-embed" src="%1$s" width="%2$d" height="%3$d" frameborder="0"></iframe></span>',
[60] Fix | Delete
esc_url( $url ),
[61] Fix | Delete
(int) $vine_size,
[62] Fix | Delete
(int) $vine_size
[63] Fix | Delete
);
[64] Fix | Delete
[65] Fix | Delete
wp_enqueue_script(
[66] Fix | Delete
'vine-embed',
[67] Fix | Delete
'https://platform.vine.co/static/scripts/embed.js',
[68] Fix | Delete
array(),
[69] Fix | Delete
JETPACK__VERSION,
[70] Fix | Delete
true
[71] Fix | Delete
);
[72] Fix | Delete
[73] Fix | Delete
return $vine_html;
[74] Fix | Delete
}
[75] Fix | Delete
wp_embed_register_handler( 'jetpack_vine', '#https?://vine.co/v/([a-z0-9]+).*#i', 'vine_embed_video' );
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Display the Vine shortcode.
[79] Fix | Delete
*
[80] Fix | Delete
* @param array $atts Shortcode attributes.
[81] Fix | Delete
*/
[82] Fix | Delete
function vine_shortcode( $atts ) {
[83] Fix | Delete
global $wp_embed;
[84] Fix | Delete
[85] Fix | Delete
if ( empty( $atts['url'] ) ) {
[86] Fix | Delete
return '';
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if ( ! preg_match( '#https?://vine.co/v/([a-z0-9]+).*#i', $atts['url'] ) ) {
[90] Fix | Delete
return '';
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
return $wp_embed->shortcode( $atts, $atts['url'] );
[94] Fix | Delete
}
[95] Fix | Delete
add_shortcode( 'vine', 'vine_shortcode' );
[96] Fix | Delete
[97] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function