PluginProbe
Catch Breadcrumb / 1.1
Catch Breadcrumb v1.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 1.1, at includes/class-catch-breadcrumb.php

224 lines 6.4 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 if ( defined( 'CATCH_BREADCRUMB_VERSION' ) ) {
71 $this->version = CATCH_BREADCRUMB_VERSION;
72 } else {
73 $this->version = '1.0.0';
74 }
75 $this->plugin_name = 'catch-breadcrumb';
76
77 $this->load_dependencies();
78 $this->set_locale();
79 $this->define_admin_hooks();
80 $this->define_public_hooks();
81
82 }
83
84 /**
85 * Load the required dependencies for this plugin.
86 *
87 * Include the following files that make up the plugin:
88 *
89 * - Catch_Breadcrumb_Loader. Orchestrates the hooks of the plugin.
90 * - Catch_Breadcrumb_i18n. Defines internationalization functionality.
91 * - Catch_Breadcrumb_Admin. Defines all hooks for the admin area.
92 * - Catch_Breadcrumb_Public. Defines all hooks for the public side of the site.
93 *
94 * Create an instance of the loader which will be used to register the hooks
95 * with WordPress.
96 *
97 * @since 1.0.0
98 * @access private
99 */
100 private function load_dependencies() {
101
102 /**
103 * The class responsible for orchestrating the actions and filters of the
104 * core plugin.
105 */
106 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-catch-breadcrumb-loader.php';
107
108 /**
109 * The class responsible for defining internationalization functionality
110 * of the plugin.
111 */
112 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-catch-breadcrumb-i18n.php';
113
114 /**
115 * The class responsible for defining all actions that occur in the admin area.
116 */
117 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-catch-breadcrumb-admin.php';
118
119 /**
120 * The class responsible for defining all actions that occur in the public-facing
121 * side of the site.
122 */
123 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-catch-breadcrumb-public.php';
124
125 $this->loader = new Catch_Breadcrumb_Loader();
126
127 }
128
129 /**
130 * Define the locale for this plugin for internationalization.
131 *
132 * Uses the Catch_Breadcrumb_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 Catch_Breadcrumb_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 Catch_Breadcrumb_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 $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_settings_menu' );
160 $this->loader->add_action( 'admin_init', $plugin_admin, 'register_settings' );
161 $this->loader->add_filter( 'plugin_action_links', $plugin_admin, 'action_links', 10, 2 );
162 }
163
164
165 /**
166 * Register all of the hooks related to the public-facing functionality
167 * of the plugin.
168 *
169 * @since 1.0.0
170 * @access private
171 */
172 private function define_public_hooks() {
173
174 $plugin_public = new Catch_Breadcrumb_Public( $this->get_plugin_name(), $this->get_version() );
175
176 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
177 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
178 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'catch_breadcrumb_front' );
179 $this->loader->add_action( 'wp_localize_script', $plugin_public,'breadcrumb_object' );
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