PluginProbe
Catch Breadcrumb / 2.4
Catch Breadcrumb v2.4
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.4, at catch-breadcrumb.php

200 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.4
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 if ( ! defined( 'CATCH_BREADCRUMB_VERSION' ) ) {
40 define( 'CATCH_BREADCRUMB_VERSION', '2.4' );
41 }
42
43 /**
44 * The code that runs during plugin activation.
45 * This action is documented in includes/class-catch-breadcrumb-activator.php
46 */
47 // The URL of the directory that contains the plugin
48 if (! defined('CATCH_BREADCRUMB_URL')) {
49 define('CATCH_BREADCRUMB_URL', plugin_dir_url(__FILE__));
50 }
51
52
53 // The absolute path of the directory that contains the file
54 if (! defined('CATCH_BREADCRUMB_PATH')) {
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 define('CATCH_BREADCRUMB_BASENAME', plugin_basename(__FILE__));
62 }
63
64 function activate_catch_breadcrumb() {
65 /* Check if Catch Breadcrumb Pro is installed and active, abort plugin activation and return with message */
66 $required = 'catch-breadcrumb-pro/catch-breadcrumb-pro.php';
67
68 if (is_plugin_active($required)) {
69
70 // Translators: %1$s and %2$s wrap the "Return to Plugins" link. The message informs the user that the Pro version is active.
71
72 $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');
73 $message = sprintf($message, '<br><a href="' . esc_url(admin_url('plugins.php')) . '">', '</a>');
74 wp_die(wp_kses_post($message));
75 }
76
77 require_once plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb-activator.php';
78 Catch_Breadcrumb_Activator::activate();
79 }
80
81 /**
82 * The code that runs during plugin deactivation.
83 * This action is documented in includes/class-catch-breadcrumb-deactivator.php
84 */
85 function deactivate_catch_breadcrumb() {
86
87 require_once plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb-deactivator.php';
88 Catch_Breadcrumb_Deactivator::deactivate();
89 }
90
91 register_activation_hook(__FILE__, 'activate_catch_breadcrumb');
92 register_deactivation_hook(__FILE__, 'deactivate_catch_breadcrumb');
93
94 /**
95 * The core plugin class that is used to define internationalization,
96 * admin-specific hooks, and public-facing site hooks.
97 */
98 require plugin_dir_path(__FILE__) . 'includes/class-catch-breadcrumb.php';
99
100 /**
101 * Begins execution of the plugin.
102 *
103 * Since everything within the plugin is registered via hooks,
104 * then kicking off the plugin from this point in the file does
105 * not affect the page life cycle.
106 *
107 * @since 1.0.0
108 */
109 function breadcrumb_sanitize_checkbox($checked) {
110 // Boolean check.
111 return ((isset($checked) && true == $checked) ? true : false);
112 }
113
114 if (! function_exists('catch_breadcrumb_get_options')) :
115 function catch_breadcrumb_get_options() {
116
117 $defaults = catch_breadcrumb_default_options();
118 $options = get_option('catch_breadcrumb_options', $defaults);
119 return wp_parse_args($options, $defaults);
120 }
121
122 endif;
123
124 if (! function_exists('catch_breadcrumb_default_options')) :
125
126 /**
127 * Return array of default options
128 *
129 * @since 1.0
130 * @return array default options.
131 */
132 function catch_breadcrumb_default_options($option = null) {
133
134 $default_options = array(
135 'breadcrumb_separator' => '&gt;',
136 'breadcrumb_home_icon' => 0,
137 'breadcrumb_display_home' => 0,
138 'content_selector' => '#content',
139 'status' => 1,
140 'breadcrumb_dynamic' => 'before',
141 );
142
143 if (current_theme_supports('catch-breadcrumb')) {
144
145 $catch_breadcumb_support = get_theme_support('catch-breadcrumb');
146 $default_options['content_selector'] = isset($catch_breadcumb_support[0]['content_selector']) ? esc_html($catch_breadcumb_support[0]['content_selector']) : '';
147 $default_options['breadcrumb_dynamic'] = isset($catch_breadcumb_support[0]['breadcrumb_dynamic']) ? esc_html($catch_breadcumb_support[0]['breadcrumb_dynamic']) : '';
148 }
149
150 if (null === $option) {
151
152 return apply_filters('catch_breadcrumb_options', $default_options);
153 } else {
154
155 return $default_options[$option];
156 }
157 }
158
159 endif; // breadcrumb_default_options
160
161 function run_catch_breadcrumb() {
162 $plugin = new Catch_Breadcrumb();
163 $plugin->run();
164 }
165
166 run_catch_breadcrumb();
167
168 require plugin_dir_path(__FILE__) . 'includes/shortcodes.php';
169
170 /**
171 * Remove breadcrumb from default position
172 * Check template-parts/header/breadcrumb.php
173 */
174 function catch_breadcrumb_remove_wc_breadcrumbs() {
175 remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0);
176 }
177
178 add_action('init', 'catch_breadcrumb_remove_wc_breadcrumbs');
179
180 function catch_breadcrumb_dynamic_position() {
181 $options = array(
182 'before' => esc_html__('Before', 'catch-breadcrumb'),
183 'after' => esc_html__('After', 'catch-breadcrumb'),
184 );
185
186 return $options;
187 }
188
189 /* CTP tabs removal options */
190 require plugin_dir_path(__FILE__) . '/includes/ctp-tabs-removal.php';
191
192 $ctp_options = ctp_get_options();
193 if (1 == $ctp_options['theme_plugin_tabs']) {
194 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
195 if (! class_exists('CatchThemesThemePlugin') && ! function_exists('add_our_plugins_tab')) {
196
197 require plugin_dir_path(__FILE__) . '/includes/CatchThemesThemePlugin.php';
198 }
199 }
200