-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-depublish-posts.php
82 lines (69 loc) · 1.82 KB
/
wp-depublish-posts.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
80
81
82
<?php
namespace WPDP;
/**
* @package WPDP
* @author Sven van Hal <[email protected]>
*
* @wordpress-plugin
* Plugin Name: Depublish Posts
* Description: Set an expiration date for posts.
* Version: 1.0.0
* Author: Sven van Hal
* Author URI: Sven van Hal <[email protected]>
* Text Domain: wp-depublish-posts
*/
// If this file is called directly, abort.
if (! defined('WPINC')) {
die;
}
// Define base path
define('WPDP_ASSET_BASE', __FILE__);
// Load autoloader
require "autoloader.php";
/**
* WP Depublish Posts. Schedule posts to expire.
*
* @package WISVCH
*/
class WPDP_Plugin
{
/**
* Initialize plug-in.
*/
function __construct()
{
// Setup
add_action('admin_enqueue_scripts', [__CLASS__, 'load_assets']);
// Localization
add_action('plugins_loaded', [__CLASS__, 'load_textdomain']);
// Load sub-components
Post::register_hooks();
Scheduler::register_hooks();
Metabox::register_hooks();
if (is_admin()) {
Columns::register_hooks();
}
}
/**
* Load plug-in assets.
*
* @return void
*/
public static function load_assets($hook)
{
if ($hook === 'post.php' || $hook === 'post-new.php') {
wp_enqueue_style('wp-depublish-posts', plugins_url('assets/wp-depublish-posts.css', WPDP_ASSET_BASE));
wp_enqueue_script('wp-depublish-posts', plugins_url('assets/wp-depublish-posts.js', WPDP_ASSET_BASE), ['jquery'], false, true);
}
}
/**
* Load plugin textdomain.
*
* @return void
*/
public static function load_textdomain()
{
load_plugin_textdomain('wp-depublish-posts', false, dirname(plugin_basename(WPDP_ASSET_BASE)).'/lang/');
}
}
new WPDP_Plugin();