Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: kickstarter.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Kickstarter shortcode
[2] Fix | Delete
*
[3] Fix | Delete
* Usage:
[4] Fix | Delete
* [kickstarter url="https://www.kickstarter.com/projects/peaktoplateau/yak-wool-baselayers-from-tibet-to-the-world" width="480" height=""]
[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
add_shortcode( 'kickstarter', 'jetpack_kickstarter_shortcode' );
[14] Fix | Delete
if ( jetpack_shortcodes_should_hook_pre_kses() ) {
[15] Fix | Delete
add_filter( 'pre_kses', 'jetpack_kickstarter_embed_to_shortcode' );
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Parse shortcode arguments and render its output.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 4.5.0
[22] Fix | Delete
*
[23] Fix | Delete
* @param array $atts Shortcode parameters.
[24] Fix | Delete
*
[25] Fix | Delete
* @return string
[26] Fix | Delete
*/
[27] Fix | Delete
function jetpack_kickstarter_shortcode( $atts ) {
[28] Fix | Delete
if ( empty( $atts['url'] ) ) {
[29] Fix | Delete
return '';
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
$url = esc_url_raw( $atts['url'] );
[33] Fix | Delete
if ( ! preg_match( '#^(www\.)?kickstarter\.com$#i', wp_parse_url( $url, PHP_URL_HOST ) ) ) {
[34] Fix | Delete
return '<!-- Invalid Kickstarter URL -->';
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
global $wp_embed;
[38] Fix | Delete
return $wp_embed->shortcode( $atts, $url );
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Converts Kickstarter iframe embeds to a shortcode.
[43] Fix | Delete
*
[44] Fix | Delete
* EG: <iframe width="480" height="360" src="http://www.kickstarter.com/projects/deweymac/dewey-mac-kid-detective-book-make-diy-and-stem-spy/widget/video.html" frameborder="0" scrolling="no"> </iframe>
[45] Fix | Delete
*
[46] Fix | Delete
* @since 4.5.0
[47] Fix | Delete
*
[48] Fix | Delete
* @param string $content Entry content that possibly includes a Kickstarter embed.
[49] Fix | Delete
*
[50] Fix | Delete
* @return string
[51] Fix | Delete
*/
[52] Fix | Delete
function jetpack_kickstarter_embed_to_shortcode( $content ) {
[53] Fix | Delete
if ( ! is_string( $content ) || false === stripos( $content, 'www.kickstarter.com/projects' ) ) {
[54] Fix | Delete
return $content;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
$regexp = '!<iframe((?:\s+\w+=[\'"][^\'"]*[\'"])*)\s+src=[\'"](http://www\.kickstarter\.com/projects/[^/]+/[^/]+)/[^\'"]+[\'"]((?:\s+\w+=[\'"][^\'"]*[\'"])*)>[\s]*</iframe>!i';
[58] Fix | Delete
$regexp_ent = str_replace( '&amp;#0*58;', '&amp;#0*58;|&#0*58;', htmlspecialchars( $regexp, ENT_NOQUOTES ) ); // phpcs:ignore
[59] Fix | Delete
[60] Fix | Delete
foreach ( array( 'regexp', 'regexp_ent' ) as $reg ) {
[61] Fix | Delete
if ( ! preg_match_all( $$reg, $content, $matches, PREG_SET_ORDER ) ) {
[62] Fix | Delete
continue;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
foreach ( $matches as $match ) {
[66] Fix | Delete
$url = esc_url( $match[2] );
[67] Fix | Delete
[68] Fix | Delete
$params = $match[1] . $match[3];
[69] Fix | Delete
[70] Fix | Delete
if ( 'regexp_ent' === $reg ) {
[71] Fix | Delete
$params = html_entity_decode( $params, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 );
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
$params = wp_kses_hair( $params, array( 'http' ) );
[75] Fix | Delete
[76] Fix | Delete
$width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
[77] Fix | Delete
[78] Fix | Delete
$shortcode = '[kickstarter url=' . $url . ( ( ! empty( $width ) ) ? " width=$width" : '' ) . ']';
[79] Fix | Delete
$content = str_replace( $match[0], $shortcode, $content );
[80] Fix | Delete
}
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
return $content;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function