Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/sitemaps
File: sitemap-buffer-image-xmlwriter.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
[0] Fix | Delete
/**
[1] Fix | Delete
* XMLWriter implementation of the image sitemap buffer.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 14.6
[4] Fix | Delete
* @package automattic/jetpack
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit( 0 );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* A buffer for constructing sitemap image xml files using XMLWriter.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 14.6
[15] Fix | Delete
*/
[16] Fix | Delete
class Jetpack_Sitemap_Buffer_Image_XMLWriter extends Jetpack_Sitemap_Buffer_XMLWriter {
[17] Fix | Delete
/**
[18] Fix | Delete
* Initialize the buffer with required headers (no root element here).
[19] Fix | Delete
*/
[20] Fix | Delete
protected function initialize_buffer() {
[21] Fix | Delete
// Add generator comment
[22] Fix | Delete
$this->writer->writeComment( "generator='jetpack-" . JETPACK__VERSION . "'" );
[23] Fix | Delete
$this->writer->writeComment( 'Jetpack_Sitemap_Buffer_Image_XMLWriter' );
[24] Fix | Delete
[25] Fix | Delete
// Add stylesheet
[26] Fix | Delete
$this->writer->writePi(
[27] Fix | Delete
'xml-stylesheet',
[28] Fix | Delete
'type="text/xsl" href="' . $this->finder->construct_sitemap_url( 'image-sitemap.xsl' ) . '"'
[29] Fix | Delete
);
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Start the root element and write its namespaces.
[34] Fix | Delete
*/
[35] Fix | Delete
protected function start_root() {
[36] Fix | Delete
$this->writer->startElement( 'urlset' );
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* Filter the XML namespaces included in image sitemaps.
[40] Fix | Delete
*
[41] Fix | Delete
* @module sitemaps
[42] Fix | Delete
*
[43] Fix | Delete
* @since 4.8.0
[44] Fix | Delete
*
[45] Fix | Delete
* @param array $namespaces Associative array with namespaces and namespace URIs.
[46] Fix | Delete
*/
[47] Fix | Delete
$namespaces = apply_filters(
[48] Fix | Delete
'jetpack_sitemap_image_ns',
[49] Fix | Delete
array(
[50] Fix | Delete
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
[51] Fix | Delete
'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
[52] Fix | Delete
'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9',
[53] Fix | Delete
'xmlns:image' => 'http://www.google.com/schemas/sitemap-image/1.1',
[54] Fix | Delete
)
[55] Fix | Delete
);
[56] Fix | Delete
[57] Fix | Delete
foreach ( $namespaces as $name => $value ) {
[58] Fix | Delete
$this->writer->writeAttribute( $name, $value );
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Append a URL entry with image information to the sitemap.
[64] Fix | Delete
*
[65] Fix | Delete
* @param array $array The URL item to append.
[66] Fix | Delete
*/
[67] Fix | Delete
protected function append_item( $array ) {
[68] Fix | Delete
if ( ! isset( $array['url'] ) || ! is_array( $array['url'] ) ) {
[69] Fix | Delete
return;
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if ( isset( $array['url']['image:image'] ) ) {
[73] Fix | Delete
if ( empty( $array['url']['image:image']['image:title'] ) ) {
[74] Fix | Delete
unset( $array['url']['image:image']['image:title'] );
[75] Fix | Delete
}
[76] Fix | Delete
if ( empty( $array['url']['image:image']['image:caption'] ) ) {
[77] Fix | Delete
unset( $array['url']['image:image']['image:caption'] );
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
$this->array_to_xml( $array );
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function