forked from 10up/simple-google-news-sitemap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-google-news-sitemap.php
79 lines (72 loc) · 2.06 KB
/
simple-google-news-sitemap.php
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
<?php
/**
* Simple Google News Sitemap
*
* @package simple-google-news-sitemap
* @author 10up
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Simple Google News Sitemap
* Plugin URI: https://github.com/10up/simple-google-news-sitemap
* Description: A simple Google News sitemap is generated on-the-fly for articles that were published in the last two days.
* Version: 1.1.1
* Requires at least: 6.5
* Requires PHP: 7.4
* Author: 10up
* Author URI: https://10up.com
* Text Domain: simple-google-news-sitemap
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: https://github.com/10up/simple-google-news-sitemap
*/
namespace SimpleGoogleNewsSitemap;
if ( ! defined( 'ABSPATH' ) ) {
die( 'Cannot access page directly' );
}
/**
* PSR-4 autoloading
*/
spl_autoload_register(
function( $class ) {
// Project-specific namespace prefix.
$prefix = 'SimpleGoogleNewsSitemap\\';
// Base directory for the namespace prefix.
$base_dir = __DIR__ . '/includes/classes/';
// Does the class use the namespace prefix?
$len = strlen( $prefix );
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
return;
}
$relative_class = substr( $class, $len );
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
// If the file exists, require it.
if ( file_exists( $file ) ) {
require $file;
}
}
);
// Require Composer autoloader if it exists.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
// Initialise plugin core.
$plugin_core = new Core();
$plugin_core->init();
/**
* Flush rewrites on activation and deactivation.
*/
register_activation_hook(
__FILE__,
function() use ( $plugin_core ) {
$plugin_core->create_rewrites();
flush_rewrite_rules( false );
}
);
register_deactivation_hook(
__FILE__,
function() use ( $plugin_core ) {
$plugin_core->remove_rewrites();
flush_rewrite_rules( false );
}
);