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

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

166 lines 5.7 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: 1.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', '1.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 define( 'CATCH_BREADCRUMB_URL', plugin_dir_url( __FILE__ ) );
48 }
49
50
51 // The absolute path of the directory that contains the file
52 if ( !defined( 'CATCH_BREADCRUMB_PATH' ) ) {
53 define( 'CATCH_BREADCRUMB_PATH', plugin_dir_path( __FILE__ ) );
54 }
55
56
57 // Gets the path to a plugin file or directory, relative to the plugins directory, without the leading and trailing slashes.
58 if ( !defined( 'CATCH_BREADCRUMB_BASENAME' ) ) {
59 define( 'CATCH_BREADCRUMB_BASENAME', plugin_basename( __FILE__ ) );
60 }
61
62 function activate_catch_breadcrumb() {
63 /* Check if Catch Breadcrumb Pro is installed and active, abort plugin activation and return with message */
64 $required = 'catch-breadcrumb-pro/catch-breadcrumb-pro.php';
65 if ( is_plugin_active( $required ) ) {
66 $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' );
67 $message = sprintf( $message, '<br><a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' );
68 wp_die( $message );
69 }
70 require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb-activator.php';
71 Catch_Breadcrumb_Activator::activate();
72 }
73
74 /**
75 * The code that runs during plugin deactivation.
76 * This action is documented in includes/class-catch-breadcrumb-deactivator.php
77 */
78 function deactivate_catch_breadcrumb() {
79 require_once plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb-deactivator.php';
80 Catch_Breadcrumb_Deactivator::deactivate();
81 }
82
83 register_activation_hook( __FILE__, 'activate_catch_breadcrumb' );
84 register_deactivation_hook( __FILE__, 'deactivate_catch_breadcrumb' );
85
86 /**
87 * The core plugin class that is used to define internationalization,
88 * admin-specific hooks, and public-facing site hooks.
89 */
90 require plugin_dir_path( __FILE__ ) . 'includes/class-catch-breadcrumb.php';
91
92 /**
93 * Begins execution of the plugin.
94 *
95 * Since everything within the plugin is registered via hooks,
96 * then kicking off the plugin from this point in the file does
97 * not affect the page life cycle.
98 *
99 * @since 1.0.0
100 */
101 function breadcrumb_sanitize_checkbox( $checked ) {
102 // Boolean check.
103 return ( ( isset( $checked ) && true == $checked ) ? true : false );
104 }
105
106 if ( ! function_exists( 'catch_breadcrumb_get_options' ) ) :
107 function catch_breadcrumb_get_options() {
108 $defaults = catch_breadcrumb_default_options();
109 $options = get_option( 'catch_breadcrumb_options', $defaults );
110 return wp_parse_args( $options, $defaults ) ;
111 }
112 endif;
113
114
115 if ( ! function_exists( 'catch_breadcrumb_default_options' ) ) :
116 /**
117 * Return array of default options
118 *
119 * @since 1.0
120 * @return array default options.
121 */
122 function catch_breadcrumb_default_options( $option = null ) {
123 $default_options = array(
124 'breadcrumb_separator' => '&gt;',
125 'breadcrumb_display_home' => 0,
126 'content_selector' => '#content',
127 'status' => 1
128 );
129
130 if( current_theme_supports( 'catch-breadcumb' ) ) {
131 $catch_breadcumb_support = get_theme_support('catch-breadcumb');
132 $default_options['content_selector'] = $catch_breadcumb_support[0]['content_selector'];
133 }
134
135 if ( null == $option ) {
136 return apply_filters( 'catch_breadcrumb_options', $default_options );
137 }
138 else {
139 return $default_options[ $option ];
140 }
141 }
142 endif; // breadcrumb_default_options
143
144 function run_catch_breadcrumb() {
145
146 $plugin = new Catch_Breadcrumb();
147 $plugin->run();
148
149 }
150 run_catch_breadcrumb();
151 require plugin_dir_path( __FILE__ ) . 'includes/shortcodes.php';
152
153 /**
154 * Remove breadcrumb from default position
155 * Check template-parts/header/breadcrumb.php
156 */
157 function catch_breadcrumb_remove_wc_breadcrumbs() {
158 remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
159 }
160 add_action( 'init', 'catch_breadcrumb_remove_wc_breadcrumbs' );
161 /* Adds Catch Themes tab in Add theme page and Themes by Catch Themes in Customizer's change theme option. */
162 require plugin_dir_path( __FILE__ ) . 'includes/our-themes.php';
163
164 /* Adds Catch Plugins tab in Add theme page. */
165 require plugin_dir_path( __FILE__ ) . 'includes/our-plugins.php';
166