Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: slideshare.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Slideshare shortcode
[2] Fix | Delete
*
[3] Fix | Delete
* Formats:
[4] Fix | Delete
* Old style (still compatible): [slideshare id=5342235&doc=camprock-101002163655-phpapp01&w=300&h=200]
[5] Fix | Delete
* New style: [slideshare id=5342235&w=300&h=200&fb=0&mw=0&mh=0&sc=no]
[6] Fix | Delete
*
[7] Fix | Delete
* Legend:
[8] Fix | Delete
* id = Document ID provided by Slideshare
[9] Fix | Delete
* w = Width of iFrame (int)
[10] Fix | Delete
* h = Height of iFrame (int)
[11] Fix | Delete
* fb = iFrame frameborder (int)
[12] Fix | Delete
* mw = iFrame marginwidth (int)
[13] Fix | Delete
* mh = iFrame marginheight (int)
[14] Fix | Delete
* sc = iFrame Scrollbar (yes/no)
[15] Fix | Delete
* pro = Slideshare Pro (yes/no)
[16] Fix | Delete
* style = Inline CSS (string)
[17] Fix | Delete
*
[18] Fix | Delete
* @package automattic/jetpack
[19] Fix | Delete
*/
[20] Fix | Delete
[21] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[22] Fix | Delete
exit( 0 );
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Register and display shortcode.
[27] Fix | Delete
*
[28] Fix | Delete
* @param array $atts Shortcode attributes.
[29] Fix | Delete
*/
[30] Fix | Delete
function slideshare_shortcode( $atts ) {
[31] Fix | Delete
global $content_width;
[32] Fix | Delete
[33] Fix | Delete
$params = shortcode_new_to_old_params( $atts );
[34] Fix | Delete
parse_str( $params, $arguments );
[35] Fix | Delete
[36] Fix | Delete
if ( empty( $arguments ) ) {
[37] Fix | Delete
return '<!-- SlideShare error: no arguments -->';
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
$attr = shortcode_atts(
[41] Fix | Delete
array(
[42] Fix | Delete
'id' => '',
[43] Fix | Delete
'w' => '',
[44] Fix | Delete
'h' => '',
[45] Fix | Delete
'fb' => '',
[46] Fix | Delete
'mw' => '',
[47] Fix | Delete
'mh' => '',
[48] Fix | Delete
'sc' => '',
[49] Fix | Delete
'pro' => '',
[50] Fix | Delete
'style' => '',
[51] Fix | Delete
),
[52] Fix | Delete
$arguments
[53] Fix | Delete
);
[54] Fix | Delete
[55] Fix | Delete
// check that the Slideshare ID contains letters, numbers and query strings.
[56] Fix | Delete
$pattern = '/[^-_a-zA-Z0-9?=&]/';
[57] Fix | Delete
if ( empty( $attr['id'] ) || preg_match( $pattern, $attr['id'] ) ) {
[58] Fix | Delete
return '<!-- SlideShare error: id is missing or has illegal characters -->';
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
// check the width/height.
[62] Fix | Delete
$w = (int) $attr['w'];
[63] Fix | Delete
[64] Fix | Delete
// If no width was specified (or uses the wrong format), and if we have a $content_width, use that.
[65] Fix | Delete
if ( empty( $w ) && ! empty( $content_width ) ) {
[66] Fix | Delete
$w = (int) $content_width;
[67] Fix | Delete
} elseif ( $w < 300 || $w > 1600 ) { // If width was specified, but is too small/large, set default value.
[68] Fix | Delete
$w = 425;
[69] Fix | Delete
} else {
[70] Fix | Delete
$w = (int) $w;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
$h = ceil( $w * 348 / 425 ); // Note: user-supplied height is ignored.
[74] Fix | Delete
[75] Fix | Delete
if ( ! empty( $attr['pro'] ) ) {
[76] Fix | Delete
$source = 'https://www.slideshare.net/slidesharepro/' . $attr['id'];
[77] Fix | Delete
} else {
[78] Fix | Delete
$source = 'https://www.slideshare.net/slideshow/embed_code/' . $attr['id'];
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if ( isset( $attr['rel'] ) ) {
[82] Fix | Delete
$source = add_query_arg( 'rel', (int) $attr['rel'], $source );
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
if ( ! empty( $attr['startSlide'] ) ) {
[86] Fix | Delete
$source = add_query_arg( 'startSlide', (int) $attr['startSlide'], $source );
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$player = sprintf( "<iframe src='%s' width='%d' height='%d'", esc_url( $source ), $w, $h );
[90] Fix | Delete
[91] Fix | Delete
// check the frameborder.
[92] Fix | Delete
if ( ! empty( $attr['fb'] ) || '0' === $attr['fb'] ) {
[93] Fix | Delete
$player .= " frameborder='" . (int) $attr['fb'] . "'";
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
$is_amp = ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() );
[97] Fix | Delete
[98] Fix | Delete
if ( ! $is_amp ) {
[99] Fix | Delete
// check the margin width; if not empty, cast as int.
[100] Fix | Delete
if ( ( ! empty( $attr['mw'] ) || '0' === $attr['mw'] ) ) {
[101] Fix | Delete
$player .= " marginwidth='" . (int) $attr['mw'] . "'";
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
// check the margin height, if not empty, cast as int.
[105] Fix | Delete
if ( ( ! empty( $attr['mh'] ) || '0' === $attr['mh'] ) ) {
[106] Fix | Delete
$player .= " marginheight='" . (int) $attr['mh'] . "'";
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if ( ! empty( $attr['style'] ) ) {
[111] Fix | Delete
$player .= " style='" . esc_attr( $attr['style'] ) . "'";
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
// check the scrollbar; cast as a lowercase string for comparison.
[115] Fix | Delete
if ( ! empty( $attr['sc'] ) ) {
[116] Fix | Delete
$sc = strtolower( $attr['sc'] );
[117] Fix | Delete
[118] Fix | Delete
if ( in_array( $sc, array( 'yes', 'no' ), true ) ) {
[119] Fix | Delete
$player .= " scrolling='" . $sc . "'";
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
$player .= ' sandbox="allow-popups allow-scripts allow-same-origin allow-presentation" allowfullscreen webkitallowfullscreen mozallowfullscreen></iframe>';
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Filter the returned SlideShare shortcode.
[127] Fix | Delete
*
[128] Fix | Delete
* @module shortcodes
[129] Fix | Delete
*
[130] Fix | Delete
* @since 4.7.0
[131] Fix | Delete
*
[132] Fix | Delete
* @param string $player The iframe to return.
[133] Fix | Delete
* @param array $atts The attributes specified in the shortcode.
[134] Fix | Delete
*/
[135] Fix | Delete
return apply_filters( 'jetpack_slideshare_shortcode', $player, $atts );
[136] Fix | Delete
}
[137] Fix | Delete
add_shortcode( 'slideshare', 'slideshare_shortcode' );
[138] Fix | Delete
[139] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function