-
Notifications
You must be signed in to change notification settings - Fork 3
/
exchange-addon-gravity-forms-checkout-info.php
153 lines (128 loc) · 3.7 KB
/
exchange-addon-gravity-forms-checkout-info.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/*
Plugin Name: iThemes Exchange – Gravity Forms Checkout Info Add-on
Plugin URI: http://www.ironbounddesigns.com
Description: Add a Gravity Form for customers to fill out during the checkout process
Version: 1.6
Author: Iron Bound Designs
Author URI: http://www.ironbounddesigns.com
License: GPL2
Domain: ibd_gravity_forms_checkout_info
*/
/**
* This registers our plugin as a product feature add-on
*
* @since 1.0.0
*
* @return void
*/
function it_exchange_register_gravity_forms_checkout_form() {
$options = array(
'name' => __( 'Gravity Forms Checkout Info', 'ibd_gravity_forms_checkout_info' ),
'description' => __( 'Harness the full power of Gravity Forms during your checkout process.', 'ibd_gravity_forms_checkout_info' ),
'author' => 'Iron Bound Designs',
'author_url' => 'http://www.ironbounddesigns.com',
'file' => dirname( __FILE__ ) . '/init.php',
'icon' => IBD_GFCI_Plugin::$url . '/assets/icon-50x50.png',
'category' => 'product-feature',
'settings-callback' => 'it_exchange_gfci_addon_settings',
'basename' => plugin_basename( __FILE__ ),
'labels' => array(
'singular_name' => __( 'Gravity Forms Checkout Form', 'ibd_gravity_forms_checkout_info' ),
)
);
if ( ibd_gfci_deps_met() )
it_exchange_register_addon( 'ibd-gravity-forms-info-product-feature', $options );
}
add_action( 'it_exchange_register_addons', 'it_exchange_register_gravity_forms_checkout_form' );
/**
* Loads the translation data for WordPress
*
* @uses load_plugin_textdomain()
* @since 1.0.3
* @return void
*/
function it_exchange_gfci_set_textdomain() {
load_plugin_textdomain( 'ibd_gravity_forms_checkout_info', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
add_action( 'plugins_loaded', 'it_exchange_gfci_set_textdomain' );
/**
*
*/
function it_exchange_gfci_addon_show_deps_nag() {
if ( !ibd_gfci_deps_met() ) {
?>
<div id="it-exchange-add-on-deps-nag" class="it-exchange-nag">
<?php _e( 'You must have Gravity Forms active to use the Gravity Forms Checkout Info Exchange Add-on.', 'ibd_gravity_forms_checkout_info' ); ?>
</div>
<?php
}
}
add_action( 'admin_notices', 'it_exchange_gfci_addon_show_deps_nag' );
/**
* Determine if all of our deps are met
*
* @return bool
*/
function ibd_gfci_deps_met() {
return class_exists( 'GFForms' );
}
/**
* Class IBD_GFCI_Plugin
*/
class IBD_GFCI_Plugin {
/**
*
*/
const SLUG = 'ibd_gravity_forms_checkout_info';
/**
* @var string
*/
static $dir;
/**
* @var string
*/
static $url;
/**
*
*/
public function __construct() {
self::$dir = plugin_dir_path( __FILE__ );
self::$url = plugin_dir_url( __FILE__ );
spl_autoload_register( array( "IBD_GFCI_Plugin", "autoload" ) );
}
/**
* Autoloader
*
* @param $class_name string
*/
public static function autoload( $class_name ) {
if ( substr( $class_name, 0, 8 ) != "IBD_GFCI" ) {
$path = self::$dir . "lib/classes";
$class = strtolower( $class_name );
$name = str_replace( "_", "-", $class );
}
else {
$path = self::$dir . "lib";
$class = substr( $class_name, 8 );
$class = strtolower( $class );
$parts = explode( "_", $class );
$name = array_pop( $parts );
$path .= implode( "/", $parts );
}
$path .= "/class.$name.php";
if ( file_exists( $path ) ) {
require( $path );
return;
}
if ( file_exists( str_replace( "class.", "abstract.", $path ) ) ) {
require( str_replace( "class.", "abstract.", $path ) );
return;
}
if ( file_exists( str_replace( "class.", "interface.", $path ) ) ) {
require( str_replace( "class.", "interface.", $path ) );
return;
}
}
}
new IBD_GFCI_Plugin();