PluginProbe
Catch Breadcrumb / 2.3
Catch Breadcrumb v2.3
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 / catch-breadcrumb.php

catch-breadcrumb.php in Catch Breadcrumb 2.3, at catch-breadcrumb.php

217 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 plugin bootstrap file
5 *
6 * This file is read by WordPress to generate the plugin information in the plugin
7 * admin area. This file also includes all of the dependencies used by the plugin,
8 * registers the activation and deactivation functions, and defines a function
9 * that starts the plugin.
10 *
11 * @link https://catchplugins.com
12 * @since 1.0.0
13 * @package Catch_Breadcrumb
14 *
15 * @wordpress-plugin
16 * Plugin Name: Catch Breadcrumb
17 * Plugin URI: https://catchplugins.com/plugins/catch-breadcrumb/
18 * Description: Catch Breadcrumb lets you display Breadcrumb Navigation anywhere on your website elegantly. It helps your readers navigate easily through your website without getting lost.
19 * Version: 2.3
20 * Author: Catch Plugins
21 * Author URI: https://catchplugins.com
22 * License: GPL-2.0+
23 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
24 * Text Domain: catch-breadcrumb
25 * Tags: breadcrumb, breadcrumbs, menu, navigation, trail
26 * Domain Path: /languages
27 */
28
29 // If this file is called directly, abort.
30 if (! defined('WPINC')) {
31 die;
32 }
33
34 /**
35 * Currently plugin version.
36 * Start at version 1.0.0 and use SemVer - https://semver.org
37 * Rename this for your plugin and update it as you release new versions.
38 */
39 define('CATCH_BREADCRUMB_VERSION', '2.3');
40
41 /**
42 * The code that runs during plugin activation.
43 * This action is documented in includes/class-catch-breadcrumb-activator.php
44 */
45 // The URL of the directory that contains the plugin
46 if (! defined('CATCH_BREADCRUMB_URL')) {
47
48 define('CATCH_BREADCRUMB_URL', plugin_dir_url(__FILE__));
49 }
50
51
52 // The absolute path of the directory that contains the file
53 if (! defined('CATCH_BREADCRUMB_PATH')) {
54
55 define('CATCH_BREADCRUMB_PATH', plugin_dir_path(__FILE__));
56 }
57
58
59 // Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
60 if (! defined('CATCH_BREADCRUMB_BASENAME')) {
61
62 define('CATCH_BREADCRUMB_BASENAME', plugin_basename(__FILE__));
63 }
64
65 function activate_catch_breadcrumb()
66 {
67
68 /* Check if Catch Breadcrumb Pro is installed and active, abort plugin activation and return with message */
69 $required = 'catch-breadcrumb-pro/catch-breadcrumb-pro.php';
70
71 if (is_plugin_active($required)) {
72
73 // Translators: %1$s and %2$s wrap the "Return to Plugins" link. The message informs the user that the Pro version is active.
74
75 $message = esc_html__('Sorry, Pro plugin is already active. No need to activate Free version. %1$s&laquo; Return to Plugins%2$s.', 'catch-breadcrumb');
76 $message = sprintf($message, '<br><a href="' . esc_url(admin_url('plugins.php')) . '">', '</a>');
77 wp_die(wp_kses_post($message));
78 }
79
80 require_once plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb-activator.php';
81 Catch_Breadcrumb_Activator::activate();
82 }
83
84 /**
85 * The code that runs during plugin deactivation.
86 * This action is documented in includes/class-catch-breadcrumb-deactivator.php
87 */
88 function deactivate_catch_breadcrumb()
89 {
90
91 require_once plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb-deactivator.php';
92 Catch_Breadcrumb_Deactivator::deactivate();
93 }
94
95 register_activation_hook(__FILE__, 'activate_catch_breadcrumb');
96 register_deactivation_hook(__FILE__, 'deactivate_catch_breadcrumb');
97
98 /**
99 * The core plugin class that is used to define internationalization,
100 * admin-specific hooks, and public-facing site hooks.
101 */
102 require plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb.php';
103
104 /**
105 * Begins execution of the plugin.
106 *
107 * Since everything within the plugin is registered via hooks,
108 * then kicking off the plugin from this point in the file does
109 * not affect the page life cycle.
110 *
111 * @since 1.0.0
112 */
113 function breadcrumb_sanitize_checkbox($checked)
114 {
115
116 // Boolean check.
117 return ((isset($checked) && true == $checked) ? true : false);
118 }
119
120 if (! function_exists('catch_breadcrumb_get_options')) :
121
122 function catch_breadcrumb_get_options()
123 {
124
125 $defaults = catch_breadcrumb_default_options();
126 $options = get_option('catch_breadcrumb_options', $defaults);
127 return wp_parse_args($options, $defaults);
128 }
129
130 endif;
131
132
133 if (! function_exists('catch_breadcrumb_default_options')) :
134
135 /**
136 * Return array of default options
137 *
138 * @since 1.0
139 * @return array default options.
140 */
141 function catch_breadcrumb_default_options($option = null)
142 {
143
144 $default_options = array(
145 'breadcrumb_separator' => '&gt;',
146 'breadcrumb_home_icon' => 0,
147 'breadcrumb_display_home' => 0,
148 'content_selector' => '#content',
149 'status' => 1,
150 'breadcrumb_dynamic' => 'before',
151 );
152
153 if (current_theme_supports('catch-breadcrumb')) {
154
155 $catch_breadcumb_support = get_theme_support('catch-breadcrumb');
156 $default_options['content_selector'] = isset($catch_breadcumb_support[0]['content_selector']) ? esc_html($catch_breadcumb_support[0]['content_selector']) : '';
157 $default_options['breadcrumb_dynamic'] = isset($catch_breadcumb_support[0]['breadcrumb_dynamic']) ? esc_html($catch_breadcumb_support[0]['breadcrumb_dynamic']) : '';
158 }
159
160 if (null === $option) {
161
162 return apply_filters('catch_breadcrumb_options', $default_options);
163 } else {
164
165 return $default_options[$option];
166 }
167 }
168
169 endif; // breadcrumb_default_options
170
171 function run_catch_breadcrumb()
172 {
173
174 $plugin = new Catch_Breadcrumb();
175 $plugin->run();
176 }
177
178 run_catch_breadcrumb();
179
180 require plugin_dir_path(__FILE__) . 'includes/shortcodes.php';
181
182 /**
183 * Remove breadcrumb from default position
184 * Check template-parts/header/breadcrumb.php
185 */
186 function catch_breadcrumb_remove_wc_breadcrumbs()
187 {
188
189 remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
190 }
191
192 add_action('init', 'catch_breadcrumb_remove_wc_breadcrumbs');
193
194 function catch_breadcrumb_dynamic_position()
195 {
196
197 $options = array(
198 'before' => esc_html__('Before', 'catch-breadcrumb'),
199 'after' => esc_html__('After', 'catch-breadcrumb'),
200 );
201
202 return $options;
203 }
204
205 /* CTP tabs removal options */
206 require plugin_dir_path(__FILE__) . '/includes/ctp-tabs-removal.php';
207
208 $ctp_options = ctp_get_options();
209 if (1 == $ctp_options['theme_plugin_tabs']) {
210
211 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
212 if (! class_exists('CatchThemesThemePlugin') && ! function_exists('add_our_plugins_tab')) {
213
214 require plugin_dir_path(__FILE__) . '/includes/CatchThemesThemePlugin.php';
215 }
216 }
217