Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/shortcod...
File: archiveorg.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Archive.org book shortcode.
[2] Fix | Delete
*
[3] Fix | Delete
* Usage:
[4] Fix | Delete
* [archiveorg Experime1940]
[5] Fix | Delete
* [archiveorg http://archive.org/details/Experime1940 poster=http://archive.org/images/map.png]
[6] Fix | Delete
* [archiveorg id=Experime1940 width=640 height=480 autoplay=1]
[7] Fix | Delete
[8] Fix | Delete
* <iframe src="http://archive.org/embed/Experime1940&autoplay=1&poster=http://archive.org/images/map.png" width="640" height="480" frameborder="0" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe>
[9] Fix | Delete
*
[10] Fix | Delete
* @package automattic/jetpack
[11] Fix | Delete
*/
[12] Fix | Delete
[13] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[14] Fix | Delete
exit( 0 );
[15] Fix | Delete
}
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* Get ID of requested archive.org embed.
[19] Fix | Delete
*
[20] Fix | Delete
* @since 4.5.0
[21] Fix | Delete
*
[22] Fix | Delete
* @param array $atts Shortcode attributes.
[23] Fix | Delete
*
[24] Fix | Delete
* @return int|string
[25] Fix | Delete
*/
[26] Fix | Delete
function jetpack_shortcode_get_archiveorg_id( $atts ) {
[27] Fix | Delete
if ( isset( $atts[0] ) ) {
[28] Fix | Delete
$atts[0] = trim( $atts[0], '=' );
[29] Fix | Delete
if ( preg_match( '#archive.org/(details|embed)/(.+)/?$#i', $atts[0], $match ) ) {
[30] Fix | Delete
$id = $match[2];
[31] Fix | Delete
} else {
[32] Fix | Delete
$id = $atts[0];
[33] Fix | Delete
}
[34] Fix | Delete
return $id;
[35] Fix | Delete
}
[36] Fix | Delete
return 0;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Convert an archive.org shortcode into an embed code.
[41] Fix | Delete
*
[42] Fix | Delete
* @since 4.5.0
[43] Fix | Delete
*
[44] Fix | Delete
* @param array $atts An array of shortcode attributes.
[45] Fix | Delete
* @return string The embed code for the archive.org video.
[46] Fix | Delete
*/
[47] Fix | Delete
function jetpack_archiveorg_shortcode( $atts ) {
[48] Fix | Delete
global $content_width;
[49] Fix | Delete
[50] Fix | Delete
if ( isset( $atts[0] ) && empty( $atts['id'] ) ) {
[51] Fix | Delete
$atts['id'] = jetpack_shortcode_get_archiveorg_id( $atts );
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$atts = shortcode_atts(
[55] Fix | Delete
array(
[56] Fix | Delete
'id' => '',
[57] Fix | Delete
'width' => 640,
[58] Fix | Delete
'height' => 480,
[59] Fix | Delete
'autoplay' => 0,
[60] Fix | Delete
'poster' => '',
[61] Fix | Delete
),
[62] Fix | Delete
$atts
[63] Fix | Delete
);
[64] Fix | Delete
[65] Fix | Delete
if ( ! $atts['id'] ) {
[66] Fix | Delete
return '<!-- error: missing archive.org ID -->';
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
$id = $atts['id'];
[70] Fix | Delete
[71] Fix | Delete
if ( ! $atts['width'] ) {
[72] Fix | Delete
$width = absint( $content_width );
[73] Fix | Delete
} else {
[74] Fix | Delete
$width = (int) $atts['width'];
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if ( ! $atts['height'] ) {
[78] Fix | Delete
$height = round( ( $width / 640 ) * 360 );
[79] Fix | Delete
} else {
[80] Fix | Delete
$height = (int) $atts['height'];
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
if ( $atts['autoplay'] ) {
[84] Fix | Delete
$autoplay = '&autoplay=1';
[85] Fix | Delete
} else {
[86] Fix | Delete
$autoplay = '';
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if ( $atts['poster'] ) {
[90] Fix | Delete
$poster = '&poster=' . $atts['poster'];
[91] Fix | Delete
} else {
[92] Fix | Delete
$poster = '';
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return sprintf(
[96] Fix | Delete
'<div class="embed-archiveorg" style="text-align:center;"><iframe title="%s" src="%s" width="%s" height="%s" style="border:0;" webkitallowfullscreen="true" mozallowfullscreen="true" allowfullscreen></iframe></div>',
[97] Fix | Delete
esc_attr__( 'Archive.org', 'jetpack' ),
[98] Fix | Delete
esc_url( "https://archive.org/embed/{$id}{$autoplay}{$poster}" ),
[99] Fix | Delete
esc_attr( $width ),
[100] Fix | Delete
esc_attr( $height )
[101] Fix | Delete
);
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
add_shortcode( 'archiveorg', 'jetpack_archiveorg_shortcode' );
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Compose shortcode from archive.org iframe.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 4.5.0
[110] Fix | Delete
*
[111] Fix | Delete
* @param string $content Post content.
[112] Fix | Delete
*
[113] Fix | Delete
* @return mixed
[114] Fix | Delete
*/
[115] Fix | Delete
function jetpack_archiveorg_embed_to_shortcode( $content ) {
[116] Fix | Delete
if ( ! is_string( $content ) || false === stripos( $content, 'archive.org/embed/' ) ) {
[117] Fix | Delete
return $content;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
$regexp = '!<iframe\s+src=[\'"]https?://archive\.org/embed/([^\'"]+)[\'"]((?:\s+\w+(=[\'"][^\'"]*[\'"])?)*)></iframe>!i';
[121] Fix | Delete
[122] Fix | Delete
if ( ! preg_match_all( $regexp, $content, $matches, PREG_SET_ORDER ) ) {
[123] Fix | Delete
return $content;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
foreach ( $matches as $match ) {
[127] Fix | Delete
$url = explode( '&amp;', $match[1] );
[128] Fix | Delete
$id = 'id=' . $url[0];
[129] Fix | Delete
[130] Fix | Delete
$autoplay = '';
[131] Fix | Delete
$poster = '';
[132] Fix | Delete
$url_count = count( $url );
[133] Fix | Delete
[134] Fix | Delete
for ( $ii = 1; $ii < $url_count; $ii++ ) {
[135] Fix | Delete
if ( 'autoplay=1' === $url[ $ii ] ) {
[136] Fix | Delete
$autoplay = ' autoplay="1"';
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
$map_matches = array();
[140] Fix | Delete
if ( preg_match( '/^poster=(.+)$/', $url[ $ii ], $map_matches ) ) {
[141] Fix | Delete
$poster = " poster=\"{$map_matches[1]}\"";
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
$params = $match[2];
[146] Fix | Delete
[147] Fix | Delete
$params = wp_kses_hair( $params, array( 'http' ) );
[148] Fix | Delete
[149] Fix | Delete
$width = isset( $params['width'] ) ? (int) $params['width']['value'] : 0;
[150] Fix | Delete
$height = isset( $params['height'] ) ? (int) $params['height']['value'] : 0;
[151] Fix | Delete
[152] Fix | Delete
$wh = '';
[153] Fix | Delete
if ( $width && $height ) {
[154] Fix | Delete
$wh = ' width=' . $width . ' height=' . $height;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
$shortcode = '[archiveorg ' . $id . $wh . $autoplay . $poster . ']';
[158] Fix | Delete
$content = str_replace( $match[0], $shortcode, $content );
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
return $content;
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
if ( jetpack_shortcodes_should_hook_pre_kses() ) {
[165] Fix | Delete
add_filter( 'pre_kses', 'jetpack_archiveorg_embed_to_shortcode' );
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function