-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathxml-sitemap.php
More file actions
134 lines (115 loc) · 3.82 KB
/
xml-sitemap.php
File metadata and controls
134 lines (115 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* Plugin Name: XML Sitemap & Google News
* Plugin URI: https://status301.net/wordpress-plugins/xml-sitemap-feed/
* Description: Feed the hungry spiders in compliance with the XML Sitemap and Google News protocols.
* Version: 5.7.3
* Text Domain: xml-sitemap-feed
* Requires at least: 4.4
* Requires PHP: 5.6
* Author: RavanH
* Author URI: https://status301.net/
*
* @package XML Sitemap & Google News
*/
/**
* Copyright 2026 RavanH
* https://status301.net/
* mailto: ravanhagen@gmail.com
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/**
* --------------------
* AVAILABLE HOOKS
* --------------------
*
* Documented on https://premium.status301.com/knowledge-base/xml-sitemap-google-news/action-and-filter-hooks/
*
* ---------------------
* AVAILABLE FUNCTIONS
* ---------------------
*
* Conditional tags https://premium.status301.com/knowledge-base/xml-sitemap-google-news/conditional-tags/
*
* Feel free to request, suggest or submit more :)
*/
defined( 'WPINC' ) || die;
define( 'XMLSF_VERSION', '5.7.3' );
define( 'XMLSF_ADV_MIN_VERSION', '1.3' );
define( 'XMLSF_NEWS_ADV_MIN_VERSION', '1.4.5' );
define( 'XMLSF_DIR', __DIR__ );
define( 'XMLSF_BASENAME', plugin_basename( __FILE__ ) );
// Pluggable functions.
require_once XMLSF_DIR . '/inc/functions-pluggable.php';
// Shared functions.
require_once XMLSF_DIR . '/inc/functions.php';
// Prepare hooks for debugging.
WP_DEBUG && require_once XMLSF_DIR . '/inc/functions-debugging.php';
// Fire it up at plugins_loaded.
add_action( 'plugins_loaded', 'xmlsf', 9 );
add_filter( 'robots_txt', 'XMLSF\robots_txt', 11 );
add_action( 'xmlsf_sitemap_loaded', 'XMLSF\sitemap_loaded' );
add_action( 'xmlsf_news_sitemap_loaded', 'XMLSF\sitemap_loaded' );
// Admin.
add_action( 'admin_menu', array( 'XMLSF\Admin\Main', 'add_options_pages' ) );
add_action( 'admin_init', array( 'XMLSF\Admin\Main', 'register_settings' ), 7 );
add_action( 'admin_init', array( 'XMLSF\Admin\Main', 'init' ), 9 );
add_action( 'admin_init', array( 'XMLSF\Admin\Main', 'compat' ) );
register_deactivation_hook( __FILE__, array( 'XMLSF\Admin\Main', 'deactivate' ) );
register_activation_hook( __FILE__, array( 'XMLSF\Admin\Main', 'activate' ) );
/**
* Get sitemap object.
*
* @since 5.0
*
* @static XMLSF\XMLSitemapFeed $xmlsf
*
* @return XMLSF\XMLSitemapFeed object by reference
*/
function &xmlsf() {
global $xmlsf;
if ( ! isset( $xmlsf ) ) {
$xmlsf = new XMLSF\XMLSitemapFeed();
}
return $xmlsf;
}
/**
* Register XMLSF autoloader
*
* @since 5.5
*
* @param string $class_name Namespaced class name.
*/
spl_autoload_register(
function ( $class_name ) {
// Bail if the class is not in our namespace.
if ( 0 !== strpos( $class_name, 'XMLSF\\' ) ) {
return;
}
// Build the filename and path.
$class_name = str_replace( 'XMLSF', 'inc', $class_name );
$class_name = strtolower( $class_name );
$path_array = explode( '\\', $class_name );
$class_name = array_pop( $path_array );
$class_name = str_replace( '_', '-', $class_name );
$file = realpath( XMLSF_DIR ) . DIRECTORY_SEPARATOR . \implode( DIRECTORY_SEPARATOR, $path_array ) . DIRECTORY_SEPARATOR . 'class-' . $class_name . '.php';
// If the file exists for the class name, load it.
if ( file_exists( $file ) ) {
include_once $file;
}
}
);
/**
* Deprecated, innit?
*
* Keep for backwards compatibility with Google News Advanced pre 1.3.6
*/
function xmlsf_init() {
_deprecated_function( __FUNCTION__, '5.5', 'xmlsf' );
}