PluginProbe
Essential Widgets / 1.8
Essential Widgets v1.8
3.2.1 3.3 3.2 trunk 1.0.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.3 1.4 1.4.1 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 1.9 2.0 2.1 2.2 All 31 releases
essential-widgets / includes / class-essential-widgets.php

class-essential-widgets.php in Essential Widgets 1.8, at includes/class-essential-widgets.php

227 lines 6.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://catchplugins.com
10 * @since 1.0.0
11 *
12 * @package Essential_Widgets
13 * @subpackage Essential_Widgets/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Essential_Widgets
27 * @subpackage Essential_Widgets/includes
28 * @author Catch Plugins <info@catchplugins.com>
29 */
30 class Essential_Widgets {
31
32 /**
33 * The loader that's responsible for maintaining and registering all hooks that power
34 * the plugin.
35 *
36 * @since 1.0.0
37 * @access protected
38 * @var Essential_Widgets_Loader $loader Maintains and registers all hooks for the plugin.
39 */
40 protected $loader;
41
42 /**
43 * The unique identifier of this plugin.
44 *
45 * @since 1.0.0
46 * @access protected
47 * @var string $plugin_name The string used to uniquely identify this plugin.
48 */
49 protected $plugin_name;
50
51 /**
52 * The current version of the plugin.
53 *
54 * @since 1.0.0
55 * @access protected
56 * @var string $version The current version of the plugin.
57 */
58 protected $version;
59
60 /**
61 * Define the core functionality of the plugin.
62 *
63 * Set the plugin name and the plugin version that can be used throughout the plugin.
64 * Load the dependencies, define the locale, and set the hooks for the admin area and
65 * the public-facing side of the site.
66 *
67 * @since 1.0.0
68 */
69 public function __construct() {
70
71 $this->version = ESSENTIAL_WIDGETS_VERSION;
72
73 $this->plugin_name = 'essential-widgets';
74
75 $this->load_dependencies();
76 $this->set_locale();
77 $this->define_admin_hooks();
78 $this->define_public_hooks();
79
80 }
81
82 /**
83 * Load the required dependencies for this plugin.
84 *
85 * Include the following files that make up the plugin:
86 *
87 * - Essential_Widgets_Loader. Orchestrates the hooks of the plugin.
88 * - Essential_Widgets_i18n. Defines internationalization functionality.
89 * - Essential_Widgets_Admin. Defines all hooks for the admin area.
90 * - Essential_Widgets_Public. Defines all hooks for the public side of the site.
91 *
92 * Create an instance of the loader which will be used to register the hooks
93 * with WordPress.
94 *
95 * @since 1.0.0
96 * @access private
97 */
98 private function load_dependencies() {
99
100 /**
101 * The class responsible for orchestrating the actions and filters of the
102 * core plugin.
103 */
104 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-essential-widgets-loader.php';
105
106 /**
107 * The class responsible for defining internationalization functionality
108 * of the plugin.
109 */
110 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-essential-widgets-i18n.php';
111
112 /**
113 * The class responsible for defining all actions that occur in the admin area.
114 */
115 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-essential-widgets-admin.php';
116
117 /**
118 * The class responsible for defining all actions that occur in the public-facing
119 * side of the site.
120 */
121 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-essential-widgets-public.php';
122
123 /* widgets include */
124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/widgets/widgets.php';
125
126 $this->loader = new Essential_Widgets_Loader();
127
128 }
129
130 /**
131 * Define the locale for this plugin for internationalization.
132 *
133 * Uses the Essential_Widgets_i18n class in order to set the domain and to register the hook
134 * with WordPress.
135 *
136 * @since 1.0.0
137 * @access private
138 */
139 private function set_locale() {
140
141 $plugin_i18n = new Essential_Widgets_i18n();
142
143 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
144
145 }
146
147 /**
148 * Register all of the hooks related to the admin area functionality
149 * of the plugin.
150 *
151 * @since 1.0.0
152 * @access private
153 */
154 private function define_admin_hooks() {
155
156 $plugin_admin = new Essential_Widgets_Admin( $this->get_plugin_name(), $this->get_version() );
157
158 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
159 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
160
161 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_settings_menu' );
162
163 $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
164 $this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'action_links', 10, 2 );
165 $this->loader->add_action( 'wp_ajax_ew_switch', $plugin_admin, 'ew_switch' );
166 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'add_plugin_meta_links', 10, 2 );
167
168 }
169
170 /**
171 * Register all of the hooks related to the public-facing functionality
172 * of the plugin.
173 *
174 * @since 1.0.0
175 * @access private
176 */
177 private function define_public_hooks() {
178
179 $plugin_public = new Essential_Widgets_Public( $this->get_plugin_name(), $this->get_version() );
180
181 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
182 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
183
184 }
185
186 /**
187 * Run the loader to execute all of the hooks with WordPress.
188 *
189 * @since 1.0.0
190 */
191 public function run() {
192 $this->loader->run();
193 }
194
195 /**
196 * The name of the plugin used to uniquely identify it within the context of
197 * WordPress and to define internationalization functionality.
198 *
199 * @since 1.0.0
200 * @return string The name of the plugin.
201 */
202 public function get_plugin_name() {
203 return $this->plugin_name;
204 }
205
206 /**
207 * The reference to the class that orchestrates the hooks with the plugin.
208 *
209 * @since 1.0.0
210 * @return Essential_Widgets_Loader Orchestrates the hooks of the plugin.
211 */
212 public function get_loader() {
213 return $this->loader;
214 }
215
216 /**
217 * Retrieve the version number of the plugin.
218 *
219 * @since 1.0.0
220 * @return string The version number of the plugin.
221 */
222 public function get_version() {
223 return $this->version;
224 }
225
226 }
227