PluginProbe
Essential Widgets / 1.1
Essential Widgets v1.1
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.1, at includes/class-essential-widgets.php

220 lines 5.8 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 $this->version = '1.1';
71
72 $this->plugin_name = 'essential-widgets';
73
74 $this->load_dependencies();
75 $this->set_locale();
76 $this->define_admin_hooks();
77 $this->define_public_hooks();
78
79 }
80
81 /**
82 * Load the required dependencies for this plugin.
83 *
84 * Include the following files that make up the plugin:
85 *
86 * - Essential_Widgets_Loader. Orchestrates the hooks of the plugin.
87 * - Essential_Widgets_i18n. Defines internationalization functionality.
88 * - Essential_Widgets_Admin. Defines all hooks for the admin area.
89 * - Essential_Widgets_Public. Defines all hooks for the public side of the site.
90 *
91 * Create an instance of the loader which will be used to register the hooks
92 * with WordPress.
93 *
94 * @since 1.0.0
95 * @access private
96 */
97 private function load_dependencies() {
98
99 /**
100 * The class responsible for orchestrating the actions and filters of the
101 * core plugin.
102 */
103 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-essential-widgets-loader.php';
104
105 /**
106 * The class responsible for defining internationalization functionality
107 * of the plugin.
108 */
109 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-essential-widgets-i18n.php';
110
111 /**
112 * The class responsible for defining all actions that occur in the admin area.
113 */
114 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-essential-widgets-admin.php';
115
116 /**
117 * The class responsible for defining all actions that occur in the public-facing
118 * side of the site.
119 */
120 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-essential-widgets-public.php';
121
122 /* widgets include */
123 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/widgets/widgets.php';
124
125 $this->loader = new Essential_Widgets_Loader();
126
127 }
128
129 /**
130 * Define the locale for this plugin for internationalization.
131 *
132 * Uses the Essential_Widgets_i18n class in order to set the domain and to register the hook
133 * with WordPress.
134 *
135 * @since 1.0.0
136 * @access private
137 */
138 private function set_locale() {
139
140 $plugin_i18n = new Essential_Widgets_i18n();
141
142 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
143
144 }
145
146 /**
147 * Register all of the hooks related to the admin area functionality
148 * of the plugin.
149 *
150 * @since 1.0.0
151 * @access private
152 */
153 private function define_admin_hooks() {
154
155 $plugin_admin = new Essential_Widgets_Admin( $this->get_plugin_name(), $this->get_version() );
156
157 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
158 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
159
160 $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
161 }
162
163 /**
164 * Register all of the hooks related to the public-facing functionality
165 * of the plugin.
166 *
167 * @since 1.0.0
168 * @access private
169 */
170 private function define_public_hooks() {
171
172 $plugin_public = new Essential_Widgets_Public( $this->get_plugin_name(), $this->get_version() );
173
174 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
175 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
176
177 }
178
179 /**
180 * Run the loader to execute all of the hooks with WordPress.
181 *
182 * @since 1.0.0
183 */
184 public function run() {
185 $this->loader->run();
186 }
187
188 /**
189 * The name of the plugin used to uniquely identify it within the context of
190 * WordPress and to define internationalization functionality.
191 *
192 * @since 1.0.0
193 * @return string The name of the plugin.
194 */
195 public function get_plugin_name() {
196 return $this->plugin_name;
197 }
198
199 /**
200 * The reference to the class that orchestrates the hooks with the plugin.
201 *
202 * @since 1.0.0
203 * @return Essential_Widgets_Loader Orchestrates the hooks of the plugin.
204 */
205 public function get_loader() {
206 return $this->loader;
207 }
208
209 /**
210 * Retrieve the version number of the plugin.
211 *
212 * @since 1.0.0
213 * @return string The version number of the plugin.
214 */
215 public function get_version() {
216 return $this->version;
217 }
218
219 }
220