-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgravityforms-product-addons.php
101 lines (85 loc) · 3.45 KB
/
gravityforms-product-addons.php
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
<?php
/**
* Plugin Name: WooCommerce Gravity Forms Product Add-Ons
* Plugin URI: http://woothemes.com/products/gravity-forms-add-ons/
* Description: Allows you to use Gravity Forms on individual WooCommerce products. Requires the Gravity Forms plugin to work.
* Version: 3.6.3
* Author: Element Stark
* Author URI: https://www.elementstark.com/
* Developer: Lucas Stark
* Developer URI: http://www.elementstark.com/
* Requires at least: 3.1
* Tested up to: 6.5
* Text Domain: wc_gf_addons
* Copyright: © 2009-2024 Element Stark.
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* WC requires at least: 7.0
* WC tested up to: 9.0
* Woo: 18633:a6ac0ab1a1536e3a357ccf24c0650ed0
*
* @package WooCommerce Gravity Forms Product Add-Ons
**/
/**
* Required functions
*/
if ( ! function_exists( 'is_woocommerce_active' ) ) {
require_once 'woo-includes/woo-functions.php';
}
// Declare support for features.
add_action(
'before_woocommerce_init',
function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
}
}
);
if ( is_woocommerce_active() ) {
load_plugin_textdomain( 'wc_gf_addons', null, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
add_action( 'init', 'wc_gravityforms_product_addons_load_textdomain', 0 );
function wc_gravityforms_product_addons_load_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), 'wc_gf_addons' );
load_textdomain( 'wc_gf_addons', WP_LANG_DIR . '/woocommerce/woocommerce-gravityforms-product-addons-' . $locale . '.mo' );
load_plugin_textdomain( 'wc_gf_addons', false, plugin_basename( __DIR__ ) . '/i18n/languages' );
}
include 'compatibility.php';
add_action( 'plugins_loaded', 'wc_gravityforms_product_addons_plugins_loaded' );
function wc_gravityforms_product_addons_plugins_loaded() {
if ( wc_gravityforms_is_plugin_active( 'gravityforms/gravityforms.php' ) || wc_gravityforms_is_plugin_active_for_network( 'gravityforms/gravityforms.php' ) ) {
require_once 'gravityforms-product-addons-main.php';
} else {
add_action( 'admin_notices', 'wc_gravityforms_admin_install_notices' );
}
}
function wc_gravityforms_is_plugin_active( $plugin ) {
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || wc_gravityforms_is_plugin_active_for_network( $plugin );
}
function wc_gravityforms_is_plugin_active_for_network( $plugin ) {
if ( ! is_multisite() ) {
return false;
}
$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}
return false;
}
function wc_gfpa_get_plugin_url() {
return plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) );
}
function wc_gravityforms_admin_install_notices() {
?>
<div id="message" class="updated woocommerce-error wc-connect">
<div class="squeezer">
<h4><?php _e( '<strong>Gravity Forms Not Found</strong> – The Gravity Forms Plugin is required to build and manage the forms for your products.', 'wc_gf_addons' ); ?></h4>
<p class="submit">
<a href="https://www.gravityforms.com/"
class="button-primary"><?php _e( 'Get Gravity Forms', 'wc_gf_addons' ); ?></a>
</p>
</div>
</div>
<?php
}
}