class-affiliates-settings-integrations.php
11.8 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
/**
* class-affiliates-settings-integrations.php
*
* Copyright (c) 2010 - 2015 "kento" Karim Rahimpur www.itthinx.com
*
* This code is released under the GNU General Public License.
* See COPYRIGHT.txt and LICENSE.txt.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This header and all notices must be kept intact.
*
* @author Karim Rahimpur
* @package affiliates
* @since affiliates 2.8.0
*/
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration section.
*/
class Affiliates_Settings_Integrations extends Affiliates_Settings {
private static $integrations = null;
public static function init() {
self::$integrations = array(
'affiliates-woocommerce-light' => array(
'title' => __( 'WooCommerce (light)', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates WooCommerce Integration Light', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'http://wordpress.org/plugins/affiliates-woocommerce-light/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> with WooCommerce. With this integration plugin, referrals are created automatically for your affiliates when sales are made.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-woocommerce-light/affiliates-woocommerce-light.php',
'notes' => __( 'This light integration is suitable to be used with the <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> plugin.', AFFILIATES_PLUGIN_DOMAIN ),
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates' ),
'platforms' => array( 'woocommerce' )
),
'affiliates-contact-form-7' => array(
'title' => __( 'Contact Form 7', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates Contact Form 7 Integration', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'http://wordpress.org/plugins/affiliates-contact-form-7/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a>, <a href="http://www.itthinx.com/plugins/affiliates-pro/">Affiliates Pro</a> and <a href="http://www.itthinx.com/plugins/affiliates-enterprise/">Affiliates Enterprise</a> with Contact Form 7. This integration stores data from submitted forms and tracks form submissions to the referring affiliate.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-contact-form-7/affiliates-contact-form-7.php',
'notes' => '',
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates', 'affiliates-pro', 'affiliates-enterprise' ),
'platforms' => array( 'contact-form-7' )
),
'affiliates-jigoshop-light' => array(
'title' => __( 'Jigoshop (light)', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates Jigoshop Integration Light', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'http://wordpress.org/plugins/affiliates-jigoshop-light/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> with Jigoshop. With this integration plugin, referrals are created automatically for your affiliates when sales are made.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-jigoshop-light/affiliates-jigoshop-light.php',
'notes' => __( 'This light integration is suitable to be used with the <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> plugin.', AFFILIATES_PLUGIN_DOMAIN ),
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates' ),
'platforms' => array( 'jigoshop' )
),
'affiliates-wp-e-commerce' => array(
'title' => __( 'WP e-Commerce', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates WP e-Commerce Integration', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'http://wordpress.org/plugins/affiliates-wp-e-commerce/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a>, <a href="http://www.itthinx.com/plugins/affiliates-pro/">Affiliates Pro</a> and <a href="http://www.itthinx.com/plugins/affiliates-enterprise/">Affiliates Enterprise</a> with WP e-Commerce. With this integration plugin, referrals are created automatically for your affiliates when sales are made.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-wp-e-commerce/affiliates-wp-e-commerce.php',
'notes' => '',
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates', 'affiliates-pro', 'affiliates-enterprise' ),
'platforms' => array( 'wp-e-commerce' )
),
'affiliates-eshop-light' => array(
'title' => __( 'eShop (light)', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates eShop Integration Light', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'https://wordpress.org/plugins/affiliates-eshop-light/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> with eShop. With this integration plugin, referrals are created automatically for your affiliates when sales are made through eShop.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-eshop-light/affiliates-eshop-light.php',
'notes' => __( 'This light integration is suitable to be used with the <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> plugin.', AFFILIATES_PLUGIN_DOMAIN ),
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates' ),
'platforms' => array( 'eshop' )
),
'affiliates-ecwid-light' => array(
'title' => __( 'Ecwid (light)', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_title' => __( 'Affiliates Ecwid Light', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_url' => 'http://wordpress.org/plugins/affiliates-ecwid-light/',
'description' => __( 'This plugin integrates <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> with Ecwid. With this integration plugin, affiliates are credited with referrals automatically after a customer has made a purchase through the online store powered by Ecwid.', AFFILIATES_PLUGIN_DOMAIN ),
'plugin_file' => 'affiliates-ecwid-light/affiliates-ecwid-light.php',
'notes' => __( 'This light integration is suitable to be used with the <a href="http://wordpress.org/plugins/affiliates/">Affiliates</a> plugin.', AFFILIATES_PLUGIN_DOMAIN ),
'repository' => 'wordpress',
'access' => 'free',
'targets' => array( 'affiliates' ),
'platforms' => array( 'ecwid' )
)
);
self::$integrations = apply_filters( 'affiliates_settings_integrations', self::$integrations );
}
/**
* Renders the integrations section.
*/
public static function section() {
$output = '';
$output .= '<p class="description">';
$output .= __( 'Integrations link the affiliate system to e-commerce plugins and other platforms.', AFFILIATES_PLUGIN_DOMAIN );
$output .= ' ';
$output .= __( 'The integrations are required to record referrals, as these award affiliates with commissions based on referred purchases or platform-specific actions.', AFFILIATES_PLUGIN_DOMAIN );
$output .= '</p>';
if ( AFFILIATES_PLUGIN_NAME != 'affiliates' ) {
$output .= '<p class="description">';
$output .= __( 'You can manage available integrations here, this includes the installation and activation of integrations with e-commerce and other systems.', AFFILIATES_PLUGIN_DOMAIN );
$output .= '</p>';
} else {
$output .= '<p class="description">';
$output .= sprintf( __( 'You can install available integrations in the <a href="%s">Plugins</a> section.', AFFILIATES_PLUGIN_DOMAIN ), esc_attr( admin_url( 'plugin-install.php?tab=search&type=author&s=itthinx' ) ) );
$output .= '</p>';
}
$output .= '<p class="description">';
$output .= __( 'You only need to install integrations with plugins that are actually used on the site.', AFFILIATES_PLUGIN_DOMAIN );
$output .= '</p>';
$output .= '<p class="description">';
$output .= __( 'User registrations do not require a specific integration to be installed.', AFFILIATES_PLUGIN_DOMAIN );
$output .= ' ';
$output .= sprintf(
__( 'Enable the built-in integration if the options provided under <a href="%s">User Registration</a> are sufficient.', AFFILIATES_PLUGIN_DOMAIN ),
esc_attr( admin_url( 'admin.php?page=affiliates-admin-user-registration' ) )
);
$output .= '</p>';
$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
$all_plugins = get_plugins();
$list = '<ul class="integrations">';
foreach( self::$integrations as $key => $integration ) {
$install_url = wp_nonce_url(
self_admin_url(
'update.php?action=install-plugin&plugin=' . $key ),
'install-plugin_' . $key
);
$activate_url = 'plugins.php?action=activate&plugin=' . urlencode( "$key/$key.php" ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( "activate-plugin_$key/$key.php" ) );
$deactivate_url = 'plugins.php?action=deactivate&plugin=' . urlencode( "$key/$key.php" ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( "deactivate-plugin_$key/$key.php" ) );
$integration_class = isset( $integration['class'] ) ? $integration['class'] : '';
$action = '';
$button = '';
$explanation = '';
if ( !key_exists( $integration['plugin_file'], $all_plugins ) ) {
$action = 'install';
$button = sprintf( '<a class="button" href="%s">Install</a>', esc_url( $install_url ) );
$explanation = sprintf(
__( 'The <a href="%s">%s</a> plugin is not installed.', AFFILIATES_PLUGIN_DOMAIN ),
esc_attr( $integration['plugin_url'] ),
esc_html( $integration['plugin_title'] )
);
} else {
if ( is_plugin_inactive( $integration['plugin_file'] ) ) {
$action = 'activate';
$button = sprintf( '<a class="button" href="%s">Activate</a>', esc_url( $activate_url ) );
$explanation = sprintf(
__( 'The <a href="%s">%s</a> plugin is installed but not activated.', AFFILIATES_PLUGIN_DOMAIN ),
esc_attr( $integration['plugin_url'] ),
esc_html( $integration['plugin_title'] )
);
$integration_class .= ' inactive';
} else {
$action = 'deactivate';
$button = sprintf( '<a class="button" href="%s">Deactivate</a>', esc_url( $deactivate_url ) );
$explanation = sprintf(
__( 'The <a href="%s">%s</a> plugin is installed and activated.', AFFILIATES_PLUGIN_DOMAIN ),
esc_attr( $integration['plugin_url'] ),
esc_html( $integration['plugin_title'] )
);
$integration_class .= ' active';
}
}
if ( AFFILIATES_PLUGIN_NAME == 'affiliates' ) {
$button = '';
}
$button = apply_filters( 'affiliates_settings_integration_button', $button, $action, $key, $integration );
$explanation = apply_filters( 'affiliates_settings_integration_explanation', $explanation, $action, $key, $integration );
$list .= sprintf( '<li id="integration-%s">', $key );
$list .= sprintf( '<div class="integration %s">', $integration_class );
$list .= '<h3>' . $integration['title'] . '</h3>';
$list .= '<p class="description">';
$list .= $integration['description'];
$list .= '</p>';
if ( !empty( $integration['notes'] ) ) {
$list .= '<p class="notes">';
$list .= $integration['notes'];
$list .= '</p>';
}
if ( !empty( $explanation ) ) {
$list .= '<p>';
$list .= $explanation;
$list .= '</p>';
}
if ( !empty( $button ) ) {
$list .= '<p>';
$list .= $button;
$list .= '</p>';
}
$list .= '</div>';
$list .= '</li>';
}
$list .= '</ul>';
$output .= $list;
echo $output;
affiliates_footer();
}
}
Affiliates_Settings_Integrations::init();