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 / catch-breadcrumb.php

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

223 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 catchplugins.com
12 * @since 1.0.0
13 * @package Catch_Breadcrumb
14 *
15 * @wordpress-plugin
16 * Plugin Name: Catch Breadcrumb
17 * Plugin URI: 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.1
20 * Author: Catch Plugins
21 * Author URI: 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.1' );
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
53 // The absolute path of the directory that contains the file
54 if ( ! defined( 'CATCH_BREADCRUMB_PATH' ) ) {
55
56 define( 'CATCH_BREADCRUMB_PATH', plugin_dir_path( __FILE__ ) );
57
58 }
59
60
61 // Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
62 if ( ! defined( 'CATCH_BREADCRUMB_BASENAME' ) ) {
63
64 define( 'CATCH_BREADCRUMB_BASENAME', plugin_basename( __FILE__ ) );
65
66 }
67
68 function activate_catch_breadcrumb() {
69
70 /* Check if Catch Breadcrumb Pro is installed and active, abort plugin activation and return with message */
71 $required = 'catch-breadcrumb-pro/catch-breadcrumb-pro.php';
72
73 if ( is_plugin_active( $required ) ) {
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( $message );
78
79 }
80
81 require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb-activator.php';
82 Catch_Breadcrumb_Activator::activate();
83
84 }
85
86 /**
87 * The code that runs during plugin deactivation.
88 * This action is documented in includes/class-catch-breadcrumb-deactivator.php
89 */
90 function deactivate_catch_breadcrumb() {
91
92 require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb-deactivator.php';
93 Catch_Breadcrumb_Deactivator::deactivate();
94
95 }
96
97 register_activation_hook( __FILE__, 'activate_catch_breadcrumb' );
98 register_deactivation_hook( __FILE__, 'deactivate_catch_breadcrumb' );
99
100 /**
101 * The core plugin class that is used to define internationalization,
102 * admin-specific hooks, and public-facing site hooks.
103 */
104 require plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb.php';
105
106 /**
107 * Begins execution of the plugin.
108 *
109 * Since everything within the plugin is registered via hooks,
110 * then kicking off the plugin from this point in the file does
111 * not affect the page life cycle.
112 *
113 * @since 1.0.0
114 */
115 function breadcrumb_sanitize_checkbox( $checked ) {
116
117 // Boolean check.
118 return ( ( isset( $checked ) && true == $checked ) ? true : false );
119
120 }
121
122 if ( ! function_exists( 'catch_breadcrumb_get_options' ) ) :
123
124 function catch_breadcrumb_get_options() {
125
126 $defaults = catch_breadcrumb_default_options();
127 $options = get_option( 'catch_breadcrumb_options', $defaults );
128 return wp_parse_args( $options, $defaults );
129
130 }
131
132 endif;
133
134
135 if ( ! function_exists( 'catch_breadcrumb_default_options' ) ) :
136
137 /**
138 * Return array of default options
139 *
140 * @since 1.0
141 * @return array default options.
142 */
143 function catch_breadcrumb_default_options( $option = null ) {
144
145 $default_options = array(
146 'breadcrumb_separator' => '&gt;',
147 'breadcrumb_home_icon' => 0,
148 'breadcrumb_display_home' => 0,
149 'content_selector' => '#content',
150 'status' => 1,
151 'breadcrumb_dynamic' => 'before',
152 );
153
154 if ( current_theme_supports( 'catch-breadcrumb' ) ) {
155
156 $catch_breadcumb_support = get_theme_support( 'catch-breadcrumb' );
157 $default_options['content_selector'] = isset( $catch_breadcumb_support[0]['content_selector'] ) ? esc_html( $catch_breadcumb_support[0]['content_selector'] ) : '';
158 $default_options['breadcrumb_dynamic'] = isset( $catch_breadcumb_support[0]['breadcrumb_dynamic'] ) ? esc_html( $catch_breadcumb_support[0]['breadcrumb_dynamic'] ) : '';
159
160 }
161
162 if ( null === $option ) {
163
164 return apply_filters( 'catch_breadcrumb_options', $default_options );
165
166 } else {
167
168 return $default_options[ $option ];
169
170 }
171
172 }
173
174 endif; // breadcrumb_default_options
175
176 function run_catch_breadcrumb() {
177
178 $plugin = new Catch_Breadcrumb();
179 $plugin->run();
180
181 }
182
183 run_catch_breadcrumb();
184
185 require plugin_dir_path( __FILE__ ) . 'includes/shortcodes.php';
186
187 /**
188 * Remove breadcrumb from default position
189 * Check template-parts/header/breadcrumb.php
190 */
191 function catch_breadcrumb_remove_wc_breadcrumbs() {
192
193 remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
194
195 }
196
197 add_action( 'init', 'catch_breadcrumb_remove_wc_breadcrumbs' );
198
199 function catch_breadcrumb_dynamic_position() {
200
201 $options = array(
202 'before' => esc_html__( 'Before', 'catch-breadcrumb' ),
203 'after' => esc_html__( 'After', 'catch-breadcrumb' ),
204 );
205
206 return $options;
207
208 }
209
210 /* CTP tabs removal options */
211 require plugin_dir_path( __FILE__ ) . '/includes/ctp-tabs-removal.php';
212
213 $ctp_options = ctp_get_options();
214 if ( 1 == $ctp_options['theme_plugin_tabs'] ) {
215
216 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
217 if ( ! class_exists( 'CatchThemesThemePlugin' ) && ! function_exists( 'add_our_plugins_tab' ) ) {
218
219 require plugin_dir_path( __FILE__ ) . '/includes/CatchThemesThemePlugin.php';
220
221 }
222 }
223