Conditions | 3 |
Paths | 2 |
Total Lines | 36 |
Code Lines | 14 |
Lines | 36 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
19 | protected function get_root_element() { |
||
20 | if ( ! isset( $this->root ) ) { |
||
21 | |||
22 | /** |
||
23 | * Filter the attribute value pairs used for namespace and namespace URI mappings. |
||
24 | * |
||
25 | * @module sitemaps |
||
26 | * |
||
27 | * @since 3.9.0 |
||
28 | * |
||
29 | * @param array $namespaces Associative array with namespaces and namespace URIs. |
||
30 | */ |
||
31 | $namespaces = apply_filters( |
||
32 | 'jetpack_sitemap_ns', |
||
33 | array( |
||
34 | 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
||
35 | 'xsi:schemaLocation' => 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', |
||
36 | 'xmlns' => 'http://www.sitemaps.org/schemas/sitemap/0.9', |
||
37 | ) |
||
38 | ); |
||
39 | |||
40 | $jetpack_version = JETPACK__VERSION; |
||
41 | $sitemap_xsl_url = $this->finder->construct_sitemap_url( 'sitemap.xsl' ); |
||
42 | |||
43 | $this->root = array( |
||
44 | "<!-- generator='jetpack-{$jetpack_version}' -->" . PHP_EOL |
||
45 | . "<?xml-stylesheet type='text/xsl' href='{$sitemap_xsl_url}'?>" . PHP_EOL |
||
46 | . '<urlset ' . $this->array_to_xml_attr_string( $namespaces ) . '>', |
||
47 | '</urlset>' |
||
48 | ); |
||
49 | |||
50 | $this->byte_capacity -= strlen( join( '', $this->root ) ); |
||
51 | } |
||
52 | |||
53 | return $this->root; |
||
54 | } |
||
55 | } |
||
56 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.