-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathgenesis-connect-woocommerce.php
More file actions
137 lines (113 loc) · 4.15 KB
/
genesis-connect-woocommerce.php
File metadata and controls
137 lines (113 loc) · 4.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
/**
* Plugin Name: Genesis Connect for WooCommerce
* Plugin URI: https://wordpress.org/plugins/genesis-connect-woocommerce/
* Version: 1.1.3
* Author: StudioPress
* Author URI: https://www.studiopress.com/
* Description: Allows you to seamlessly integrate WooCommerce with the Genesis Framework and Genesis child themes.
* Text Domain: gencwooc
* License: GNU General Public License v2.0 (or later)
* License URI: http://www.opensource.org/licenses/gpl-license.php
* Requires PHP: 5.6
* Requires at least: 4.7
*
* WC requires at least: 3.3.0
* WC tested up to: 4.4.0
*
* @package Genesis_Connect_WooCommerce
*
* Special thanks to Ade Walker (http://www.studiograsshopper.ch/) for his contributions to this plugin.
*/
define( 'GCW_DIR', dirname( __FILE__ ) );
define( 'GCW_TEMPLATE_DIR', dirname( __FILE__ ) . '/templates' );
define( 'GCW_LIB_DIR', dirname( __FILE__ ) . '/lib' );
define( 'GCW_ADMIN_DIR', dirname( __FILE__ ) . '/admin' );
define( 'GCW_WIDGETS_DIR', dirname( __FILE__ ) . '/widgets' );
define( 'GCW_SP_DIR', dirname( __FILE__ ) . '/sp-plugins-integration' );
add_action( 'after_setup_theme', 'gencwooc_setup' );
/**
* Setup Genesis Connect for WooCommerce.
*
* Checks whether WooCommerce is active.
* Once past these checks, loads the necessary files, actions and filters for the plugin
* to do its thing.
*
* @since 0.9.0
*/
function gencwooc_setup() {
require_once GCW_ADMIN_DIR . '/notices.php';
$ready = true;
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
add_action( 'admin_notices', 'gencwooc_woocommerce_notice' );
$ready = false;
}
if ( ! function_exists( 'genesis' ) ) {
if ( ! is_multisite() ) {
add_action( 'admin_notices', 'gencwooc_genesis_notice' );
}
$ready = false;
}
if ( ! $ready ) {
return;
}
global $woocommerce;
require_once GCW_LIB_DIR . '/template-loader.php';
require_once GCW_LIB_DIR . '/posts-per-page.php';
require_once GCW_LIB_DIR . '/widgets.php';
if ( ! current_theme_supports( 'gencwooc-woo-breadcrumbs' ) ) {
require_once GCW_LIB_DIR . '/breadcrumb.php';
}
add_theme_support( 'woocommerce' );
add_post_type_support( 'product', array( 'genesis-layouts', 'genesis-scripts', 'genesis-seo' ) );
add_post_type_support( 'product', array( 'genesis-simple-sidebars', 'genesis-simple-menus' ) );
if ( current_theme_supports( 'gencwooc-featured-products-widget' ) ) {
require_once GCW_WIDGETS_DIR . '/class-gencwooc-featured-products.php';
}
remove_filter( 'template_include', array( &$woocommerce, 'template_loader' ) );
add_filter( 'template_include', 'gencwooc_template_loader', 20 );
if ( is_plugin_active( 'genesis-simple-sidebars/plugin.php' ) ) {
require_once GCW_SP_DIR . '/genesis-simple-sidebars.php';
}
if ( is_plugin_active( 'genesis-simple-menus/simple-menu.php' ) ) {
require_once GCW_SP_DIR . '/genesis-simple-menus.php';
}
}
add_action( 'plugins_loaded', 'gencwooc_load_plugin_textdomain' );
/**
* Load plugin translated strings.
*
* Callback for WordPress 'plugins_loaded' action.
*
* @uses load_plugin_textdomain()
* @link https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
*
* @since 1.1.0
*/
function gencwooc_load_plugin_textdomain() {
load_plugin_textdomain( 'gencwooc', false, GCW_DIR . '/languages' );
}
add_action( 'before_woocommerce_init', 'gencwooc_declare_compat' );
/**
* Declare compatibility.
*/
function gencwooc_declare_compat() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
}
/**
* Initialize checking of plugin updates from WP Engine.
*/
function genesis_connect_woocommerce_check_for_upgrades() {
$properties = array(
'plugin_slug' => 'genesis-connect-woocommerce',
'plugin_basename' => plugin_basename( __FILE__ ),
);
require_once __DIR__ . '/lib/class-genesis-connect-woocommerce-plugin-updater.php';
new Genesis_Connect_Woocommerce_Plugin_Updater( $properties );
}
add_action( 'admin_init', 'genesis_connect_woocommerce_check_for_upgrades' );