PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.0
Code Manager v1.0.0
1.0.48 1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / freemius / templates / forms / affiliation.php
code-manager / freemius / templates / forms Last commit date
deactivation 5 years ago affiliation.php 5 years ago data-debug-mode.php 5 years ago index.php 5 years ago license-activation.php 5 years ago optout.php 5 years ago premium-versions-upgrade-handler.php 5 years ago premium-versions-upgrade-metadata.php 5 years ago resend-key.php 5 years ago subscription-cancellation.php 5 years ago trial-start.php 5 years ago user-change.php 5 years ago
affiliation.php
486 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.2.3
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $fs = freemius( $VARS['id'] );
18
19 $slug = $fs->get_slug();
20
21 $user = $fs->get_user();
22 $affiliate = $fs->get_affiliate();
23 $affiliate_terms = $fs->get_affiliate_terms();
24
25 $plugin_title = $fs->get_plugin_title();
26 $module_type = $fs->is_plugin() ?
27 WP_FS__MODULE_TYPE_PLUGIN :
28 WP_FS__MODULE_TYPE_THEME;
29
30 $commission = $affiliate_terms->get_formatted_commission();
31
32 $readonly = false;
33 $is_affiliate = is_object( $affiliate );
34 $is_pending_affiliate = false;
35 $email_address = ( is_object( $user ) ?
36 $user->email :
37 '' );
38 $full_name = ( is_object( $user ) ?
39 $user->get_name() :
40 '' );
41 $paypal_email_address = '';
42 $domain = '';
43 $extra_domains = array();
44 $promotion_method_social_media = false;
45 $promotion_method_mobile_apps = false;
46 $statistics_information = false;
47 $promotion_method_description = false;
48 $members_dashboard_login_url = 'https://members.freemius.com/login/';
49
50 $affiliate_application_data = $fs->get_affiliate_application_data();
51
52 if ( $is_affiliate && $affiliate->is_pending() ) {
53 $readonly = 'readonly';
54 $is_pending_affiliate = true;
55
56 $paypal_email_address = $affiliate->paypal_email;
57 $domain = $affiliate->domain;
58 $statistics_information = $affiliate_application_data['stats_description'];
59 $promotion_method_description = $affiliate_application_data['promotion_method_description'];
60
61 if ( ! empty( $affiliate_application_data['additional_domains'] ) ) {
62 $extra_domains = $affiliate_application_data['additional_domains'];
63 }
64
65 if ( ! empty( $affiliate_application_data['promotion_methods'] ) ) {
66 $promotion_methods = explode( ',', $affiliate_application_data['promotion_methods'] );
67 $promotion_method_social_media = in_array( 'social_media', $promotion_methods );
68 $promotion_method_mobile_apps = in_array( 'mobile_apps', $promotion_methods );
69 }
70 } else {
71 $current_user = Freemius::_get_current_wp_user();
72 $full_name = trim( $current_user->user_firstname . ' ' . $current_user->user_lastname );
73 $email_address = $current_user->user_email;
74 $domain = fs_strip_url_protocol( get_site_url() );
75 }
76
77 $affiliate_tracking = 30;
78
79 if ( is_object( $affiliate_terms ) ) {
80 $affiliate_tracking = ( ! is_null( $affiliate_terms->cookie_days ) ?
81 ( $affiliate_terms->cookie_days . '-day' ) :
82 fs_text_inline( 'Non-expiring', 'non-expiring', $slug ) );
83 }
84
85 $apply_to_become_affiliate_text = fs_text_inline( 'Apply to become an affiliate', 'apply-to-become-an-affiliate', $slug );
86 ?>
87 <div id="fs_affiliation_content_wrapper" class="wrap">
88 <form method="post" action="">
89 <div id="poststuff">
90 <div class="postbox">
91 <div class="inside">
92 <div id="messages">
93 <div id="error_message" class="error" style="display: none">
94 <p><strong></strong></p>
95 </div>
96 <div id="message" class="updated" style="display: none">
97 <p><strong></strong></p>
98 </div>
99 <?php if ( $is_affiliate ) : ?>
100 <?php if ( $affiliate->is_active() ) : ?>
101 <div class="updated">
102 <p><strong><?php
103 echo sprintf(
104 fs_esc_html_inline( "Your affiliate application for %s has been accepted! Log in to your affiliate area at: %s.", 'affiliate-application-accepted', $slug ),
105 $plugin_title,
106 sprintf(
107 '<a href="%s" target="_blank">%s</a>',
108 $members_dashboard_login_url,
109 $members_dashboard_login_url
110 )
111 );
112 ?></strong></p>
113 </div>
114 <?php else : ?>
115 <?php
116 $message_text = '';
117
118 if ( $is_pending_affiliate ) {
119 $message_text = fs_text_inline( "Thank you for applying for our affiliate program, we'll review your details during the next 14 days and will get back to you with further information.", 'affiliate-application-thank-you', $slug );
120 $message_container_class = 'updated';
121 } else if ( $affiliate->is_suspended() ) {
122 $message_text = fs_text_inline( 'Your affiliation account was temporarily suspended.', 'affiliate-account-suspended', $slug );
123 $message_container_class = 'notice notice-warning';
124 } else if ( $affiliate->is_rejected() ) {
125 $message_text = fs_text_inline( "Thank you for applying for our affiliate program, unfortunately, we've decided at this point to reject your application. Please try again in 30 days.", 'affiliate-application-rejected', $slug );
126 $message_container_class = 'error';
127 } else if ( $affiliate->is_blocked() ) {
128 $message_text = fs_text_inline( 'Due to violation of our affiliation terms, we decided to temporarily block your affiliation account. If you have any questions, please contact support.', 'affiliate-account-blocked', $slug );
129 $message_container_class = 'error';
130 }
131 ?>
132 <div class="<?php echo $message_container_class ?>">
133 <p><strong><?php echo esc_html( $message_text ) ?></strong></p>
134 </div>
135 <?php endif ?>
136 <?php endif ?>
137 </div>
138 <div class="entry-content">
139 <?php if ( ! $is_affiliate ) : ?>
140 <div id="application_messages_container">
141 <p><?php echo esc_html( sprintf( fs_text_inline( 'Like the %s? Become our ambassador and earn cash ;-)', 'become-an-ambassador', $slug ), $module_type ) ) ?></p>
142 <p><?php echo esc_html( sprintf( fs_text_inline( 'Refer new customers to our %s and earn %s commission on each successful sale you refer!', 'refer-new-customers', $slug ), $module_type, $commission ) ) ?></p>
143 </div>
144 <?php endif ?>
145 <h3><?php fs_esc_html_echo_inline( 'Program Summary', 'program-summary', $slug ) ?></h3>
146 <ul>
147 <li><?php echo esc_html( sprintf( fs_text_inline( '%s commission when a customer purchases a new license.', 'commission-on-new-license-purchase', $slug ), $commission ) ) ?></li>
148 <?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_renewals_commission() ) : ?>
149 <li><?php echo esc_html( sprintf( fs_text_inline( 'Get commission for automated subscription renewals.', 'renewals-commission', $slug ) ) ) ?></li>
150 <?php endif ?>
151 <?php if ( is_object( $affiliate_terms ) && ( ! $affiliate_terms->is_session_cookie() ) ) : ?>
152 <li><?php echo esc_html( sprintf( fs_text_inline( '%s tracking cookie after the first visit to maximize earnings potential.', 'affiliate-tracking', $slug ), $affiliate_tracking ) ) ?></li>
153 <?php endif ?>
154 <?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_lifetime_commission() ) : ?>
155 <li><?php fs_esc_html_echo_inline( 'Unlimited commissions.', 'unlimited-commissions', $slug ) ?></li>
156 <?php endif ?>
157 <li><?php echo esc_html( sprintf( fs_text_inline( '%s minimum payout amount.', 'minimum-payout-amount', $slug ), '$100' ) ) ?></li>
158 <li><?php fs_esc_html_echo_inline( 'Payouts are in USD and processed monthly via PayPal.', 'payouts-unit-and-processing', $slug ) ?></li>
159 <li><?php fs_esc_html_echo_inline( 'As we reserve 30 days for potential refunds, we only pay commissions that are older than 30 days.', 'commission-payment', $slug ) ?></li>
160 </ul>
161 <div id="application_form_container" <?php echo ( $is_pending_affiliate ) ? '' : 'style="display: none"' ?>>
162 <h3><?php fs_esc_html_echo_inline( 'Affiliate', 'affiliate', $slug ) ?></h3>
163 <form>
164 <div class="input-container input-container-text">
165 <label class="input-label"><?php fs_esc_html_echo_inline( 'Email address', 'email-address', $slug ) ?></label>
166 <input id="email_address" type="text" value="<?php echo esc_attr( $email_address ) ?>" class="regular-text" <?php echo ( $readonly || is_object( $user ) ) ? 'readonly' : '' ?>>
167 </div>
168 <div class="input-container input-container-text">
169 <label class="input-label"><?php fs_esc_html_echo_inline( 'Full name', 'full-name', $slug ) ?></label>
170 <input id="full_name" type="text" value="<?php echo esc_attr( $full_name ) ?>" class="regular-text" <?php echo $readonly ?>>
171 </div>
172 <div class="input-container input-container-text">
173 <label class="input-label"><?php fs_esc_html_echo_inline( 'PayPal account email address', 'paypal-account-email-address', $slug ) ?></label>
174 <input id="paypal_email" type="text" value="<?php echo esc_attr( $paypal_email_address ) ?>" class="regular-text" <?php echo $readonly ?>>
175 </div>
176 <div class="input-container input-container-text">
177 <label class="input-label"><?php echo esc_html( sprintf( fs_text_inline( 'Where are you going to promote the %s?', 'domain-field-label', $slug ), $module_type ) ) ?></label>
178 <input id="domain" type="text" value="<?php echo esc_attr( $domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
179 <p class="description"><?php echo esc_html( sprintf( fs_text_inline( 'Enter the domain of your website or other websites from where you plan to promote the %s.', 'domain-field-desc', $slug ), $module_type ) ) ?></p>
180 <?php if ( ! $is_affiliate ) : ?>
181 <a id="add_domain" href="#" class="disabled">+ <?php fs_esc_html_echo_inline( 'Add another domain', 'add-another-domain', $slug ) ?>...</a>
182 <?php endif ?>
183 </div>
184 <div id="extra_domains_container" class="input-container input-container-text" <?php echo $is_pending_affiliate ? '' : 'style="display: none"' ?>>
185 <label class="input-label"><?php fs_esc_html_echo_inline( 'Extra Domains', 'extra-domain-fields-label', $slug ) ?></label>
186 <p class="description"><?php fs_esc_html_echo_inline( 'Extra domains where you will be marketing the product from.', 'extra-domain-fields-desc', $slug ) ?></p>
187 <?php if ( $is_pending_affiliate && ! empty( $extra_domains ) ) : ?>
188 <?php foreach ( $extra_domains as $extra_domain ) : ?>
189 <div class="extra-domain-input-container">
190 <input type="text" value="<?php echo esc_attr( $extra_domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
191 </div>
192 <?php endforeach ?>
193 <?php endif ?>
194 </div>
195 <div class="input-container">
196 <label class="input-label"><?php fs_esc_html_echo_inline( 'Promotion methods', 'promotion-methods', $slug ) ?></label>
197 <div>
198 <input id="promotion_method_social_media" type="checkbox" <?php checked( $promotion_method_social_media ) ?> <?php disabled( $is_affiliate ) ?>/>
199 <label for="promotion_method_social_media"><?php fs_esc_html_echo_inline( 'Social media (Facebook, Twitter, etc.)', 'social-media', $slug ) ?></label>
200 </div>
201 <div>
202 <input id="promotion_method_mobile_apps" type="checkbox" <?php checked( $promotion_method_mobile_apps ) ?> <?php disabled( $is_affiliate ) ?>/>
203 <label for="promotion_method_mobile_apps"><?php fs_esc_html_echo_inline( 'Mobile apps', 'mobile-apps', $slug ) ?></label>
204 </div>
205 </div>
206 <div class="input-container input-container-text">
207 <label class="input-label"><nobr><?php fs_esc_html_echo_inline( 'Website, email, and social media statistics (optional)', 'statistics-information-field-label', $slug ) ?></nobr></label>
208 <textarea id="statistics_information" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $statistics_information ?></textarea>
209 <?php if ( ! $is_affiliate ) : ?>
210 <p class="description"><?php fs_esc_html_echo_inline( 'Please feel free to provide any relevant website or social media statistics, e.g. monthly unique site visits, number of email subscribers, followers, etc. (we will keep this information confidential).', 'statistics-information-field-desc', $slug ) ?></p>
211 <?php endif ?>
212 </div>
213 <div class="input-container input-container-text">
214 <label class="input-label"><?php fs_esc_html_echo_inline( 'How will you promote us?', 'promotion-method-desc-field-label', $slug ) ?></label>
215 <textarea id="promotion_method_description" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $promotion_method_description ?></textarea>
216 <?php if ( ! $is_affiliate ) : ?>
217 <p class="description"><?php echo esc_html( sprintf( fs_text_inline( 'Please provide details on how you intend to promote %s (please be as specific as possible).', 'promotion-method-desc-field-desc', $slug ), $plugin_title ) ) ?></p>
218 <?php endif ?>
219 </div>
220 </form>
221 </div>
222 <?php if ( ! $is_affiliate ) : ?>
223 <a id="cancel_button" href="#" class="button button-secondary button-cancel" style="display: none"><?php fs_esc_html_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>
224 <a id="submit_button" class="button button-primary" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a>
225 <a id="apply_button" class="button button-primary" href="#"><?php fs_esc_html_echo_inline( 'Become an affiliate', 'become-an-affiliate', $slug ) ?></a>
226 <?php endif ?>
227 </div>
228 </div>
229 </div>
230 </div>
231 </form>
232 <script type="text/javascript">
233 jQuery(function ($) {
234 var
235 $contentWrapper = $('#fs_affiliation_content_wrapper'),
236 $socialMedia = $('#promotion_method_social_media'),
237 $mobileApps = $('#promotion_method_mobile_apps'),
238 $applyButton = $('#apply_button'),
239 $submitButton = $('#submit_button'),
240 $cancelButton = $('#cancel_button'),
241 $applicationFormContainer = $('#application_form_container'),
242 $errorMessageContainer = $('#error_message'),
243 $domain = $('#domain'),
244 $addDomain = $('#add_domain'),
245 $extraDomainsContainer = $('#extra_domains_container');
246
247 $applyButton.click(function (evt) {
248 evt.preventDefault();
249
250 var $this = $(this);
251 $this.hide();
252
253 $applicationFormContainer.show();
254 $cancelButton.show();
255 $submitButton.show();
256
257 $contentWrapper.find('input[type="text"]:first').focus();
258 });
259
260 $submitButton.click(function (evt) {
261 evt.preventDefault();
262
263 var $this = $(this);
264
265 if ($this.hasClass('disabled')) {
266 return;
267 }
268
269 $errorMessageContainer.hide();
270
271 var
272 $emailAddress = $('#email_address'),
273 emailAddress = null,
274 paypalEmailAddress = $('#paypal_email').val().trim();
275
276 if (1 === $emailAddress.length) {
277 emailAddress = $emailAddress.val().trim();
278
279 if (0 === emailAddress.length) {
280 showErrorMessage('<?php fs_esc_js_echo_inline( 'Email address is required.', 'email-address-is-required', $slug ) ?>');
281 return;
282 }
283 }
284
285 if (0 === paypalEmailAddress.length) {
286 showErrorMessage('<?php fs_esc_js_echo_inline( 'PayPal email address is required.', 'paypal-email-address-is-required', $slug ) ?>');
287 return;
288 }
289
290 var
291 $extraDomains = $extraDomainsContainer.find('.domain'),
292 domain = $domain.val().trim().toLowerCase(),
293 extraDomains = [];
294
295 if (0 === domain.length) {
296 showErrorMessage('<?php fs_esc_js_echo_inline( 'Domain is required.', 'domain-is-required', $slug ) ?>');
297 return;
298 } else if ('freemius.com' === domain) {
299 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + domain + '].');
300 return;
301 }
302
303 if ($extraDomains.length > 0) {
304 var hasError = false;
305
306 $extraDomains.each(function () {
307 var
308 $this = $(this),
309 extraDomain = $this.val().trim().toLowerCase();
310 if (0 === extraDomain.length || extraDomain === domain) {
311 return true;
312 } else if ('freemius.com' === extraDomain) {
313 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + extraDomain + '].');
314 hasError = true;
315 return false;
316 }
317
318 extraDomains.push(extraDomain);
319 });
320
321 if (hasError) {
322 return;
323 }
324 }
325
326 var
327 promotionMethods = [],
328 statisticsInformation = $('#statistics_information').val(),
329 promotionMethodDescription = $('#promotion_method_description').val();
330
331 if ($socialMedia.attr('checked')) {
332 promotionMethods.push('social_media');
333 }
334
335 if ($mobileApps.attr('checked')) {
336 promotionMethods.push('mobile_apps');
337 }
338
339 var affiliate = {
340 full_name : $('#full_name').val().trim(),
341 paypal_email : paypalEmailAddress,
342 stats_description : statisticsInformation,
343 promotion_method_description: promotionMethodDescription
344 };
345
346 if (null !== emailAddress) {
347 affiliate.email = emailAddress;
348 }
349
350 affiliate.domain = domain;
351 affiliate.additional_domains = extraDomains;
352
353 if (promotionMethods.length > 0) {
354 affiliate.promotion_methods = promotionMethods.join(',');
355 }
356
357 $.ajax({
358 url : ajaxurl,
359 method : 'POST',
360 data : {
361 action : '<?php echo $fs->get_ajax_action( 'submit_affiliate_application' ) ?>',
362 security : '<?php echo $fs->get_ajax_security( 'submit_affiliate_application' ) ?>',
363 module_id: '<?php echo $fs->get_id() ?>',
364 affiliate: affiliate
365 },
366 beforeSend: function () {
367 $cancelButton.addClass('disabled');
368 $submitButton.addClass('disabled');
369 $submitButton.text('<?php fs_esc_js_echo_inline( 'Submitting', 'submitting' ) ?>...');
370 },
371 success : function (result) {
372 if (result.success) {
373 location.reload();
374 } else {
375 if (result.error && result.error.length > 0) {
376 showErrorMessage(result.error);
377 }
378
379 $cancelButton.removeClass('disabled');
380 $submitButton.removeClass('disabled');
381 $submitButton.text('<?php echo esc_js( $apply_to_become_affiliate_text ) ?>')
382 }
383 }
384 });
385 });
386
387 $cancelButton.click(function (evt) {
388 evt.preventDefault();
389
390 var $this = $(this);
391
392 if ($this.hasClass('disabled')) {
393 return;
394 }
395
396 $applicationFormContainer.hide();
397 $this.hide();
398 $submitButton.hide();
399
400 $applyButton.show();
401
402 window.scrollTo(0, 0);
403 });
404
405 $domain.on('input propertychange', onDomainChange);
406
407 $addDomain.click(function (evt) {
408 evt.preventDefault();
409
410 var
411 $this = $(this),
412 domain = $domain.val().trim();
413
414 if ($this.hasClass('disabled') || 0 === domain.length) {
415 return;
416 }
417
418 $domain.off('input propertychange');
419 $this.addClass('disabled');
420
421 var
422 $extraDomainInputContainer = $('<div class="extra-domain-input-container"><input type="text" class="domain regular-text"/></div>'),
423 $extraDomainInput = $extraDomainInputContainer.find('input'),
424 $removeDomain = $('<a href="#" class="remove-domain"><i class="dashicons dashicons-no" title="<?php fs_esc_js_echo_inline( 'Remove', 'remove', $slug ) ?>"></i></a>');
425
426 $extraDomainInputContainer.append($removeDomain);
427
428 $extraDomainInput.on('input propertychange', onDomainChange);
429
430 $removeDomain.click(function (evt) {
431 evt.preventDefault();
432
433 var
434 $extraDomainInputs = $('.extra-domain-input-container .domain');
435
436 if (1 === $extraDomainInputs.length)
437 $extraDomainInputs.val('').focus();
438 else
439 $(this).parent().remove();
440 });
441
442 $extraDomainsContainer.show();
443
444 $extraDomainInputContainer.appendTo($extraDomainsContainer);
445 $extraDomainInput.focus();
446
447 $this.appendTo($extraDomainsContainer);
448 });
449
450 /**
451 * @author Leo Fajardo (@leorw)
452 */
453 function onDomainChange() {
454 var
455 domain = $(this).val().trim();
456
457 if (domain.length > 0) {
458 $addDomain.removeClass('disabled');
459 } else {
460 $addDomain.addClass('disabled');
461 }
462 }
463
464 /**
465 * @author Leo Fajardo (@leorw)
466 *
467 * @param {String} message
468 */
469 function showErrorMessage(message) {
470 $errorMessageContainer.find('strong').text(message);
471 $errorMessageContainer.show();
472
473 window.scrollTo(0, 0);
474 }
475 });
476 </script>
477 </div>
478 <?php
479 $params = array(
480 'page' => 'affiliation',
481 'module_id' => $fs->get_id(),
482 'module_slug' => $slug,
483 'module_version' => $fs->get_plugin_version(),
484 );
485 fs_require_template( 'powered-by.php', $params );
486 ?>