Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: descript.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Descript.com embed
[2] Fix | Delete
*
[3] Fix | Delete
* Example URL: https://share.descript.com/view/jUxUmel6GyN
[4] Fix | Delete
* Example embed code: <iframe src="https://share.descript.com/embed/jUxUmel6GyN" width="640" height="360" frameborder="0" allowfullscreen></iframe>
[5] Fix | Delete
*
[6] Fix | Delete
* @package automattic/jetpack
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[10] Fix | Delete
exit( 0 );
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
[14] Fix | Delete
add_action( 'init', 'jetpack_descript_enable_embeds' );
[15] Fix | Delete
} else {
[16] Fix | Delete
jetpack_descript_enable_embeds();
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Register descript as oembed provider. Add filter to reverse iframes to shortcode. Register [descript] shortcode.
[21] Fix | Delete
*
[22] Fix | Delete
* @since 10.4
[23] Fix | Delete
*/
[24] Fix | Delete
function jetpack_descript_enable_embeds() {
[25] Fix | Delete
// Support their oEmbed Endpoint.
[26] Fix | Delete
wp_oembed_add_provider( '#https?://share.descript.com/(?:view|embed)/\w+#i', 'https://api.descript.com/v2/oembed', true );
[27] Fix | Delete
[28] Fix | Delete
if ( jetpack_shortcodes_should_hook_pre_kses() ) {
[29] Fix | Delete
// Allow script to be filtered to short code (so direct copy+paste can be done).
[30] Fix | Delete
add_filter( 'pre_kses', 'jetpack_shortcodereverse_descript' );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
// Actually display the descript Embed.
[34] Fix | Delete
add_shortcode( 'descript', 'jetpack_descript_shortcode' );
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Compose shortcode based on Descript iframes.
[39] Fix | Delete
*
[40] Fix | Delete
* @since 10.4
[41] Fix | Delete
*
[42] Fix | Delete
* @param string $content Post content.
[43] Fix | Delete
*
[44] Fix | Delete
* @return mixed
[45] Fix | Delete
*/
[46] Fix | Delete
function jetpack_shortcodereverse_descript( $content ) {
[47] Fix | Delete
if ( ! is_string( $content ) || false === stripos( $content, 'share.descript.com' ) ) {
[48] Fix | Delete
return $content;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
$regexp = '/<iframe (?:loading="lazy" )?src="https:\/\/share.descript.com\/embed\/(\w+)" width="(\d+)" height="(\d+)" frameborder="0" allowfullscreen(?:="")?><\/iframe>/i';
[52] Fix | Delete
[53] Fix | Delete
if ( preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
[54] Fix | Delete
foreach ( $matches as $match ) {
[55] Fix | Delete
// We need at least a id.
[56] Fix | Delete
if ( isset( $match[1] ) ) {
[57] Fix | Delete
$shortcode = sprintf(
[58] Fix | Delete
'[descript id="%1$s" width="%2$s" height="%3$s"]',
[59] Fix | Delete
esc_attr( $match[1] ),
[60] Fix | Delete
esc_attr( $match[2] ),
[61] Fix | Delete
esc_attr( $match[3] )
[62] Fix | Delete
);
[63] Fix | Delete
$content = str_replace( $match[0], $shortcode, $content );
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/** This action is documented in modules/widgets/social-media-icons.php */
[69] Fix | Delete
do_action( 'jetpack_bump_stats_extras', 'html_to_shortcode', 'descript' );
[70] Fix | Delete
[71] Fix | Delete
return $content;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
/**
[75] Fix | Delete
* Parse shortcode arguments and render its output.
[76] Fix | Delete
*
[77] Fix | Delete
* @since 10.4
[78] Fix | Delete
*
[79] Fix | Delete
* @param array $atts Shortcode parameters.
[80] Fix | Delete
*
[81] Fix | Delete
* @return string
[82] Fix | Delete
*/
[83] Fix | Delete
function jetpack_descript_shortcode( $atts ) {
[84] Fix | Delete
if ( ! empty( $atts['id'] ) ) {
[85] Fix | Delete
$id = $atts['id'];
[86] Fix | Delete
} else {
[87] Fix | Delete
return '<!-- Missing descript id -->';
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
if ( ! empty( $atts['width'] ) ) {
[91] Fix | Delete
$width = $atts['width'];
[92] Fix | Delete
} else {
[93] Fix | Delete
$width = '640';
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
if ( ! empty( $atts['height'] ) ) {
[97] Fix | Delete
$height = $atts['height'];
[98] Fix | Delete
} else {
[99] Fix | Delete
$height = '480';
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
$params = array(
[103] Fix | Delete
'id' => esc_attr( $id ),
[104] Fix | Delete
'width' => (int) $width,
[105] Fix | Delete
'height' => (int) $height,
[106] Fix | Delete
);
[107] Fix | Delete
[108] Fix | Delete
$embed_url = sprintf(
[109] Fix | Delete
'https://share.descript.com/view/%1$s',
[110] Fix | Delete
esc_attr( $id )
[111] Fix | Delete
);
[112] Fix | Delete
[113] Fix | Delete
$embed_code = wp_oembed_get( $embed_url, array_filter( $params ) );
[114] Fix | Delete
[115] Fix | Delete
// wrap the embed with wp-block-embed__wrapper, otherwise it would be aligned to the very left of the viewport.
[116] Fix | Delete
return sprintf(
[117] Fix | Delete
'<div class="wp-block-embed__wrapper">%1$s</div>',
[118] Fix | Delete
$embed_code
[119] Fix | Delete
);
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function