PluginProbe
Catch Breadcrumb / 2.1
Catch Breadcrumb v2.1
trunk 1.0.0 1.0.1 1.0.2 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6 1.7 1.8 1.9 2.0 2.1 2.2 All 29 releases
catch-breadcrumb / includes / class-catch-breadcrumb.php

class-catch-breadcrumb.php in Catch Breadcrumb 2.1, at includes/class-catch-breadcrumb.php

224 lines 6.1 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/plugins
10 * @since 1.0.0
11 *
12 * @package Catch_Breadcrumb
13 * @subpackage Catch_Breadcrumb/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 Catch_Breadcrumb
27 * @subpackage Catch_Breadcrumb/includes
28 * @author Catch Plugins <info@catchplugins.com>
29 */
30 class Catch_Breadcrumb {
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 Catch_Breadcrumb_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 = CATCH_BREADCRUMB_VERSION;
72
73 $this->plugin_name = 'catch-breadcrumb';
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 * - Catch_Breadcrumb_Loader. Orchestrates the hooks of the plugin.
88 * - Catch_Breadcrumb_i18n. Defines internationalization functionality.
89 * - Catch_Breadcrumb_Admin. Defines all hooks for the admin area.
90 * - Catch_Breadcrumb_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-catch-breadcrumb-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-catch-breadcrumb-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-catch-breadcrumb-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-catch-breadcrumb-public.php';
122
123 $this->loader = new Catch_Breadcrumb_Loader();
124
125 }
126
127 /**
128 * Define the locale for this plugin for internationalization.
129 *
130 * Uses the Catch_Breadcrumb_i18n class in order to set the domain and to register the hook
131 * with WordPress.
132 *
133 * @since 1.0.0
134 * @access private
135 */
136 private function set_locale() {
137
138 $plugin_i18n = new Catch_Breadcrumb_i18n();
139
140 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
141
142 }
143
144 /**
145 * Register all of the hooks related to the admin area functionality
146 * of the plugin.
147 *
148 * @since 1.0.0
149 * @access private
150 */
151 private function define_admin_hooks() {
152
153 $plugin_admin = new Catch_Breadcrumb_Admin( $this->get_plugin_name(), $this->get_version() );
154
155 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
156 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
157 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_settings_menu' );
158 $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
159 $this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'action_links', 10, 2 );
160 $this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'add_plugin_meta_links', 10, 2 );
161 }
162
163
164 /**
165 * Register all of the hooks related to the public-facing functionality
166 * of the plugin.
167 *
168 * @since 1.0.0
169 * @access private
170 */
171 private function define_public_hooks() {
172
173 $plugin_public = new Catch_Breadcrumb_Public( $this->get_plugin_name(), $this->get_version() );
174
175 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
176 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
177 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'catch_breadcrumb_localize' );
178 $this->loader->add_action( 'wp_footer', $plugin_public, 'show_breadcrumb' );
179
180 }
181
182 /**
183 * Run the loader to execute all of the hooks with WordPress.
184 *
185 * @since 1.0.0
186 */
187 public function run() {
188 $this->loader->run();
189 }
190
191 /**
192 * The name of the plugin used to uniquely identify it within the context of
193 * WordPress and to define internationalization functionality.
194 *
195 * @since 1.0.0
196 * @return string The name of the plugin.
197 */
198 public function get_plugin_name() {
199 return $this->plugin_name;
200 }
201
202 /**
203 * The reference to the class that orchestrates the hooks with the plugin.
204 *
205 * @since 1.0.0
206 * @return Catch_Breadcrumb_Loader Orchestrates the hooks of the plugin.
207 */
208 public function get_loader() {
209 return $this->loader;
210 }
211
212 /**
213 * Retrieve the version number of the plugin.
214 *
215 * @since 1.0.0
216 * @return string The version number of the plugin.
217 */
218 public function get_version() {
219 return $this->version;
220 }
221
222
223 }
224