-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap-html.php
51 lines (43 loc) · 1.66 KB
/
sitemap-html.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
<?php
/**
* Plugin Name: Sitemap HTML
* Plugin URI: https://github.com/xwp/sitemap-html
* Description: Generates a Monthly Sitemap in HTML for your WordPress site.
* Version: 1.0.0
* Author: XWP
* Author URI: https://xwp.co
* License: GPLv2+
* Text Domain: sitemap-html
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Define plugin constants.
define( 'SITEMAP_HTML_VERSION', '1.0.0' );
define( 'SITEMAP_HTML_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'SITEMAP_HTML_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
// Load Classes.
require_once SITEMAP_HTML_PLUGIN_DIR . 'includes/class-singleton.php';
require_once SITEMAP_HTML_PLUGIN_DIR . 'includes/class-posts.php';
require_once SITEMAP_HTML_PLUGIN_DIR . 'includes/class-date.php';
require_once SITEMAP_HTML_PLUGIN_DIR . 'includes/class-plugin.php';
// Initialize the plugin.
function sitemap_html_init() {
SitemapHtml\Plugin::get_instance();
}
add_action( 'plugins_loaded', 'sitemap_html_init' );
// Activation Hook.
register_activation_hook( __FILE__, 'sitemap_html_activate' );
function sitemap_html_activate() {
$plugin = SitemapHtml\Plugin::get_instance();
$plugin->update_sitemap();
$plugin->create_sitemap_page();
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
flush_rewrite_rules(); // Flush rewrite rules after creating page.
}
// Deactivation Hook.
register_deactivation_hook( __FILE__, 'sitemap_html_deactivate' );
function sitemap_html_deactivate() {
// phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules
flush_rewrite_rules(); // Flush rewrite rules on deactivation.
}