Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: twitchtv.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Twitch.tv shortcode
[2] Fix | Delete
*
[3] Fix | Delete
* Examples:
[4] Fix | Delete
* [twitchtv url='https://www.twitch.tv/paperbat' height='378' width='620' autoplay='false']
[5] Fix | Delete
* [twitchtv url='https://www.twitch.tv/paperbat/b/323486192' height='378' width='620' autoplay='false']
[6] Fix | Delete
*
[7] Fix | Delete
* @package automattic/jetpack
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[11] Fix | Delete
exit( 0 );
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* (Live URL) https://www.twitch.tv/paperbat
[16] Fix | Delete
*
[17] Fix | Delete
* <iframe src="https://player.twitch.tv/?autoplay=false&#038;muted=false&#038;channel=paperbat" width="620" height="378" frameborder="0" scrolling="no" allowfullscreen></iframe>
[18] Fix | Delete
*
[19] Fix | Delete
* (Archive URL) https://www.twitch.tv/paperbat/v/323486192
[20] Fix | Delete
*
[21] Fix | Delete
* <iframe src="https://player.twitch.tv/?autoplay=false&#038;muted=false&#038;video=v323486192" width="620" height="378" frameborder="0" scrolling="no" allowfullscreen></iframe>
[22] Fix | Delete
*
[23] Fix | Delete
* @param array $atts User supplied shortcode arguments.
[24] Fix | Delete
*
[25] Fix | Delete
* @return string HTML output of the shortcode.
[26] Fix | Delete
*/
[27] Fix | Delete
function wpcom_twitchtv_shortcode( $atts ) {
[28] Fix | Delete
$attr = shortcode_atts(
[29] Fix | Delete
array(
[30] Fix | Delete
'height' => 378,
[31] Fix | Delete
'width' => 620,
[32] Fix | Delete
'url' => '',
[33] Fix | Delete
'autoplay' => 'false',
[34] Fix | Delete
'muted' => 'false',
[35] Fix | Delete
'time' => null,
[36] Fix | Delete
),
[37] Fix | Delete
$atts
[38] Fix | Delete
);
[39] Fix | Delete
[40] Fix | Delete
if ( empty( $attr['url'] ) ) {
[41] Fix | Delete
return '<!-- Invalid twitchtv URL -->';
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
preg_match( '|^https?://www.twitch.tv/([^/?]+)(/v/(\d+))?|i', $attr['url'], $match );
[45] Fix | Delete
[46] Fix | Delete
$url_args = array(
[47] Fix | Delete
'autoplay' => ( false !== $attr['autoplay'] && 'false' !== $attr['autoplay'] ) ? 'true' : 'false',
[48] Fix | Delete
'muted' => ( false !== $attr['muted'] && 'false' !== $attr['muted'] ) ? 'true' : 'false',
[49] Fix | Delete
'time' => $attr['time'],
[50] Fix | Delete
);
[51] Fix | Delete
[52] Fix | Delete
$width = (int) $attr['width'];
[53] Fix | Delete
$height = (int) $attr['height'];
[54] Fix | Delete
[55] Fix | Delete
$user_id = $match[1];
[56] Fix | Delete
$video_id = 0;
[57] Fix | Delete
if ( ! empty( $match[3] ) ) {
[58] Fix | Delete
$video_id = (int) $match[3];
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
do_action( 'jetpack_bump_stats_extras', 'twitchtv', 'shortcode' );
[62] Fix | Delete
[63] Fix | Delete
if ( $video_id > 0 ) {
[64] Fix | Delete
$url_args['video'] = 'v' . $video_id;
[65] Fix | Delete
} else {
[66] Fix | Delete
$url_args['channel'] = $user_id;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
// See https://discuss.dev.twitch.tv/t/twitch-embedded-player-updates-in-2020/23956.
[70] Fix | Delete
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[71] Fix | Delete
$url_args['parent'] = isset( $_SERVER['HTTP_HOST'] )
[72] Fix | Delete
? rawurlencode( wp_unslash( $_SERVER['HTTP_HOST'] ) ) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
[73] Fix | Delete
: '';
[74] Fix | Delete
[75] Fix | Delete
$url = add_query_arg( $url_args, 'https://player.twitch.tv/' );
[76] Fix | Delete
[77] Fix | Delete
return sprintf(
[78] Fix | Delete
'<iframe src="%s" width="%d" height="%d" frameborder="0" scrolling="no" allowfullscreen sandbox="allow-popups allow-scripts allow-same-origin allow-presentation"></iframe>',
[79] Fix | Delete
esc_url( $url ),
[80] Fix | Delete
esc_attr( $width ),
[81] Fix | Delete
esc_attr( $height )
[82] Fix | Delete
);
[83] Fix | Delete
}
[84] Fix | Delete
add_shortcode( 'twitch', 'wpcom_twitchtv_shortcode' );
[85] Fix | Delete
add_shortcode( 'twitchtv', 'wpcom_twitchtv_shortcode' );
[86] Fix | Delete
[87] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function