This repository has been archived by the owner on Dec 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-notification-list.php
134 lines (113 loc) · 3.21 KB
/
wp-notification-list.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
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 // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
/**
* Plugin Name: WP Notification List
* Plugin URI: https://github.com/TremiDkhar/wp-notification-list
* Description: Display list of notification or information to the public.
* Version: 0.3.0
* Author: Tremi Dkhar
* Author URI: https://github.com/TremiDkhar
* License: GPL-2.0+
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wpnotificationlist
*
* @package WPNotificationList
* @author Tremi Dkhar
* @copyright Copyright (c) Tremi Dkhar, 2020
* @license GPL-2.0+
*/
/**
* Main Notification List Instance
*
* @since 0.1.0
* @return object WPNotificationList
*/
final class WPNotificationList {
/**
* Holds instance of WPNotificationList
*
* @var object WPNotificationList
*/
public static $instance;
/**
* CPT Object
*
* @var object WPNotificationList_Register_CPT
*/
private $cpt;
/**
* Main WPNotificationList instance
*
* Insure that only one instance of WPNotificationList exists in memory at any one time.
* Also prevent needing to define globals all over the place.
*
* @since 0.1.0
* @return object WPNotificationList
*/
public static function instance() {
if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
self::$instance = new self();
self::$instance->constants();
self::$instance->includes();
self::$instance->cpt = new WPNotificationList_Register_CPT();
self::$instance->shortcode = new WPNotificationList_Shortcode();
add_action( 'widgets_init', array( self::$instance, 'register_widget' ) );
}
return self::$instance;
}
/**
* Initialized constants required by the plugins.
*
* @since 0.1.0
* @return void
*/
private function constants() {
// Plugin Version.
if ( ! defined( 'WPNOTIFICATIONLIST_VERSION' ) ) {
define( 'WPNOTIFICATIONLIST_VERSION', '0.1.0' );
}
// Plugin URI.
if ( ! defined( 'WPNOTIFICATIONLIST_URI' ) ) {
define( 'WPNOTIFICATIONLIST_URI', plugin_dir_url( __FILE__ ) );
}
// Plugin Path.
if ( ! defined( 'WPNOTIFICATIONLIST_PATH' ) ) {
define( 'WPNOTIFICATIONLIST_PATH', plugin_dir_path( __FILE__ ) );
}
// Plugin Apps FIle.
if ( ! defined( 'WPNOTIFICATIONLIST_PLUGIN_FILE' ) ) {
define( 'WPNOTIFICATIONLIST_PLUGIN_FILE', __FILE__ );
}
}
/**
* Include required files.
*
* @access private
* @since 0.1.0
* @return void
*/
private function includes() {
require_once WPNOTIFICATIONLIST_PATH . 'includes/class-wpnotificationlist-register-cpt.php';
require_once WPNOTIFICATIONLIST_PATH . 'includes/class-wpnotificationlist-widget-display.php';
require_once WPNOTIFICATIONLIST_PATH . 'includes/class-wpnotificationlist-shortcode.php';
}
/**
* Register the widget
*
* @since 0.1.0
* @return void
*/
public function register_widget() {
register_widget( 'WPNotificationList_Widget_Display' );
}
}
/**
* Get the object from the main class and return the instance
*
* @since 0.1.0
* @return object
*/
function WPNotificationList() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
return WPNotificationList::instance();
}
// Get the notification list running.
WPNotificationList();