-
Notifications
You must be signed in to change notification settings - Fork 0
/
radium-newscore-shortcodes.php
194 lines (151 loc) · 4.69 KB
/
radium-newscore-shortcodes.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
/*
Plugin Name: Radium NewsCore Shortcodes
Plugin URI: http://radiumthemes.com/plugins/shortcodes
Description: Easy to use shortcode manager for Radium Themes
Author: Franklin M Gitonga
Version: 1.0.5
Author URI: http://radiumthemes.com/
License: GPL v2+
*/
if ( ! defined( 'ABSPATH' ) ) exit;
/** Load all of the necessary class files for the plugin */
spl_autoload_register( 'Radium_Shortcodes::autoload' );
/**
* Init class for Radium_NewscoresShortcodes.
*
* Loads all of the necessary components for the radium shortcodes plugin.
*
* @since 1.0.0
*
* @package Radium_Shortcodes
* @author Franklin Gitonga
*/
class Radium_Shortcodes {
/**
* Holds a copy of the object for easy reference.
*
* @since 1.0.0
*
* @var object
*/
private static $instance;
/**
* Current version of the plugin.
*
* @since 1.0.0
*
* @var string
*/
public $version = '1.0.3';
/**
* Holds a copy of the main plugin filepath.
*
* @since 1.0.0
*
* @var string
*/
private static $file = __FILE__;
/**
* Constructor. Hooks all interactions into correct areas to start
* the class.
*
* @since 1.0.0
*/
public function __construct() {
self::$instance = $this;
/** Run a hook before the slider is loaded and pass the object */
do_action_ref_array( 'radium_shortcodes_init', array( $this ) );
/** Run activation hook and make sure the WordPress version supports the plugin */
register_activation_hook( __FILE__, array( $this, 'activation' ) );
/** Load the plugin */
add_action( 'widgets_init', array( $this, 'widget' ) );
add_action( 'init', array( $this, 'init' ) );
}
/**
* Registers a plugin activation hook to make sure the current WordPress
* version is suitable (>= 3.9) for use.
*
* @since 1.0.0
*
* @global int $wp_version The current version of this particular WP instance
*/
public function activation() {
global $wp_version;
if ( version_compare( $wp_version, '3.9', '<' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( printf( __( 'Sorry, but your version of WordPress, <strong>%s</strong>, does not meet the Radium Shortcode\'s required version of <strong>3.9</strong> to run properly. The plugin has been deactivated. <a href="%s">Click here to return to the Dashboard</a>', 'radium_shortcodes' ), $wp_version, admin_url() ) );
}
}
/**
* Registers the widget with WordPress.
*
* @since 1.0.0
*/
public function widget() {
//register_widget( 'Radium_Shortcodes_Widget' );
}
/**
* Loads the plugin upgrader, registers the post type and
* loads all the actions and filters for the class.
*
* @since 1.0.0
*/
public function init() {
/** Load the plugin textdomain for internationalizing strings */
load_plugin_textdomain( 'radium_shortcodes', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
/** Instantiate all the necessary components of the plugin */
$radium_shortcodes_assets = new Radium_Shortcodes_Assets;
$radium_shortcodes_register = new Radium_Shortcodes_Register;
if ( is_admin() ) new Radium_Shortcodes_Integrate();
}
/**
* PSR-0 compliant autoloader to load classes as needed.
*
* @since 1.0.0
*
* @param string $classname The name of the class
* @return null Return early if the class name does not start with the correct prefix
*/
public static function autoload( $classname ) {
if ( 'Radium' !== mb_substr( $classname, 0, 6 ) )
return;
$filename = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $classname ) . '.php';
if ( file_exists( $filename ) )
require $filename;
}
/**
* Getter method for retrieving the url.
*
* @since 1.0.0
*/
public static function get_url() {
return plugins_url('', __FILE__);;
}
/**
* Getter method for retrieving the url.
*
* @since 1.0.0
*/
public static function get_dir() {
return plugin_dir_path(__FILE__);;
}
/**
* Getter method for retrieving the object instance.
*
* @since 1.0.0
*/
public static function get_instance() {
return self::$instance;
}
/**
* Getter method for retrieving the main plugin filepath.
*
* @since 1.0.0
*/
public static function get_file() {
return self::$file;
}
}
/** Instantiate the init class */
new Radium_Shortcodes;