PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.1
Code Manager v1.0.1
1.0.49 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
507 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 $module_id = $fs->get_id();
88 $affiliate_program_terms_url = "https://freemius.com/plugin/{$module_id}/{$slug}/legal/affiliate-program/";
89 ?>
90 <div id="fs_affiliation_content_wrapper" class="wrap">
91 <form method="post" action="">
92 <div id="poststuff">
93 <div class="postbox">
94 <div class="inside">
95 <div id="messages">
96 <div id="error_message" class="error" style="display: none">
97 <p><strong></strong></p>
98 </div>
99 <div id="message" class="updated" style="display: none">
100 <p><strong></strong></p>
101 </div>
102 <?php if ( $is_affiliate ) : ?>
103 <?php if ( $affiliate->is_active() ) : ?>
104 <div class="updated">
105 <p><strong><?php
106 echo sprintf(
107 fs_esc_html_inline( "Your affiliate application for %s has been accepted! Log in to your affiliate area at: %s.", 'affiliate-application-accepted', $slug ),
108 $plugin_title,
109 sprintf(
110 '<a href="%s" target="_blank" rel="noopener">%s</a>',
111 $members_dashboard_login_url,
112 $members_dashboard_login_url
113 )
114 );
115 ?></strong></p>
116 </div>
117 <?php else : ?>
118 <?php
119 $message_text = '';
120
121 if ( $is_pending_affiliate ) {
122 $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 );
123 $message_container_class = 'updated';
124 } else if ( $affiliate->is_suspended() ) {
125 $message_text = fs_text_inline( 'Your affiliation account was temporarily suspended.', 'affiliate-account-suspended', $slug );
126 $message_container_class = 'notice notice-warning';
127 } else if ( $affiliate->is_rejected() ) {
128 $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 );
129 $message_container_class = 'error';
130 } else if ( $affiliate->is_blocked() ) {
131 $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 );
132 $message_container_class = 'error';
133 }
134 ?>
135 <div class="<?php echo $message_container_class ?>">
136 <p><strong><?php echo esc_html( $message_text ) ?></strong></p>
137 </div>
138 <?php endif ?>
139 <?php endif ?>
140 </div>
141 <div class="entry-content">
142 <?php if ( ! $is_affiliate ) : ?>
143 <div id="application_messages_container">
144 <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>
145 <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>
146 </div>
147 <?php endif ?>
148 <h3><?php fs_esc_html_echo_inline( 'Program Summary', 'program-summary', $slug ) ?></h3>
149 <ul>
150 <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>
151 <?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_renewals_commission() ) : ?>
152 <li><?php echo esc_html( sprintf( fs_text_inline( 'Get commission for automated subscription renewals.', 'renewals-commission', $slug ) ) ) ?></li>
153 <?php endif ?>
154 <?php if ( is_object( $affiliate_terms ) && ( ! $affiliate_terms->is_session_cookie() ) ) : ?>
155 <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>
156 <?php endif ?>
157 <?php if ( is_object( $affiliate_terms ) && $affiliate_terms->has_lifetime_commission() ) : ?>
158 <li><?php fs_esc_html_echo_inline( 'Unlimited commissions.', 'unlimited-commissions', $slug ) ?></li>
159 <?php endif ?>
160 <li><?php echo esc_html( sprintf( fs_text_inline( '%s minimum payout amount.', 'minimum-payout-amount', $slug ), '$100' ) ) ?></li>
161 <li><?php fs_esc_html_echo_inline( 'Payouts are in USD and processed monthly via PayPal.', 'payouts-unit-and-processing', $slug ) ?></li>
162 <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>
163 </ul>
164 <div id="application_form_container" <?php echo ( $is_pending_affiliate ) ? '' : 'style="display: none"' ?>>
165 <h3><?php fs_esc_html_echo_inline( 'Affiliate', 'affiliate', $slug ) ?></h3>
166 <form>
167 <div class="input-container input-container-text">
168 <label class="input-label"><?php fs_esc_html_echo_inline( 'Email address', 'email-address', $slug ) ?></label>
169 <input id="email_address" type="text" value="<?php echo esc_attr( $email_address ) ?>" class="regular-text" <?php echo ( $readonly || is_object( $user ) ) ? 'readonly' : '' ?>>
170 </div>
171 <div class="input-container input-container-text">
172 <label class="input-label"><?php fs_esc_html_echo_inline( 'Full name', 'full-name', $slug ) ?></label>
173 <input id="full_name" type="text" value="<?php echo esc_attr( $full_name ) ?>" class="regular-text" <?php echo $readonly ?>>
174 </div>
175 <div class="input-container input-container-text">
176 <label class="input-label"><?php fs_esc_html_echo_inline( 'PayPal account email address', 'paypal-account-email-address', $slug ) ?></label>
177 <input id="paypal_email" type="text" value="<?php echo esc_attr( $paypal_email_address ) ?>" class="regular-text" <?php echo $readonly ?>>
178 </div>
179 <div class="input-container input-container-text">
180 <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>
181 <input id="domain" type="text" value="<?php echo esc_attr( $domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
182 <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>
183 <?php if ( ! $is_affiliate ) : ?>
184 <a id="add_domain" href="#" class="disabled">+ <?php fs_esc_html_echo_inline( 'Add another domain', 'add-another-domain', $slug ) ?>...</a>
185 <?php endif ?>
186 </div>
187 <div id="extra_domains_container" class="input-container input-container-text" <?php echo $is_pending_affiliate ? '' : 'style="display: none"' ?>>
188 <label class="input-label"><?php fs_esc_html_echo_inline( 'Extra Domains', 'extra-domain-fields-label', $slug ) ?></label>
189 <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>
190 <?php if ( $is_pending_affiliate && ! empty( $extra_domains ) ) : ?>
191 <?php foreach ( $extra_domains as $extra_domain ) : ?>
192 <div class="extra-domain-input-container">
193 <input type="text" value="<?php echo esc_attr( $extra_domain ) ?>" class="domain regular-text" <?php echo $readonly ?>>
194 </div>
195 <?php endforeach ?>
196 <?php endif ?>
197 </div>
198 <div class="input-container">
199 <label class="input-label"><?php fs_esc_html_echo_inline( 'Promotion methods', 'promotion-methods', $slug ) ?></label>
200 <div>
201 <input id="promotion_method_social_media" type="checkbox" <?php checked( $promotion_method_social_media ) ?> <?php disabled( $is_affiliate ) ?>/>
202 <label for="promotion_method_social_media"><?php fs_esc_html_echo_inline( 'Social media (Facebook, Twitter, etc.)', 'social-media', $slug ) ?></label>
203 </div>
204 <div>
205 <input id="promotion_method_mobile_apps" type="checkbox" <?php checked( $promotion_method_mobile_apps ) ?> <?php disabled( $is_affiliate ) ?>/>
206 <label for="promotion_method_mobile_apps"><?php fs_esc_html_echo_inline( 'Mobile apps', 'mobile-apps', $slug ) ?></label>
207 </div>
208 </div>
209 <div class="input-container input-container-text">
210 <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>
211 <textarea id="statistics_information" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $statistics_information ?></textarea>
212 <?php if ( ! $is_affiliate ) : ?>
213 <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>
214 <?php endif ?>
215 </div>
216 <div class="input-container input-container-text">
217 <label class="input-label"><?php fs_esc_html_echo_inline( 'How will you promote us?', 'promotion-method-desc-field-label', $slug ) ?></label>
218 <textarea id="promotion_method_description" rows="5" <?php echo $readonly ?> class="regular-text"><?php echo $promotion_method_description ?></textarea>
219 <?php if ( ! $is_affiliate ) : ?>
220 <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>
221 <?php endif ?>
222 </div>
223 <div>
224 <input type="checkbox" id="legal_consent_checkbox">
225 <label for="legal_consent_checkbox">I agree to the <a href="<?php echo $affiliate_program_terms_url ?>" target="_blank" rel="noopener">Referrer Program</a>'s terms & conditions.</label>
226 </div>
227 </form>
228 </div>
229 <?php if ( ! $is_affiliate ) : ?>
230 <a id="cancel_button" href="#" class="button button-secondary button-cancel" style="display: none"><?php fs_esc_html_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>
231 <a id="submit_button" class="button button-primary disabled" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a>
232 <a id="apply_button" class="button button-primary" href="#"><?php fs_esc_html_echo_inline( 'Become an affiliate', 'become-an-affiliate', $slug ) ?></a>
233 <?php endif ?>
234 </div>
235 </div>
236 </div>
237 </div>
238 </form>
239 <script type="text/javascript">
240 jQuery(function ($) {
241 var
242 $contentWrapper = $('#fs_affiliation_content_wrapper'),
243 $socialMedia = $('#promotion_method_social_media'),
244 $mobileApps = $('#promotion_method_mobile_apps'),
245 $applyButton = $('#apply_button'),
246 $submitButton = $('#submit_button'),
247 $cancelButton = $('#cancel_button'),
248 $applicationFormContainer = $('#application_form_container'),
249 $errorMessageContainer = $('#error_message'),
250 $domain = $('#domain'),
251 $addDomain = $('#add_domain'),
252 $extraDomainsContainer = $('#extra_domains_container'),
253 $legalConsentCheckbox = $( '#legal_consent_checkbox' );
254
255 $applyButton.click(function (evt) {
256 evt.preventDefault();
257
258 var $this = $(this);
259 $this.hide();
260
261 $applicationFormContainer.show();
262 $cancelButton.show();
263 $submitButton.show();
264
265 $contentWrapper.find('input[type="text"]:first').focus();
266 });
267
268 $submitButton.click(function (evt) {
269 evt.preventDefault();
270
271 var $this = $(this);
272
273 if ($this.hasClass('disabled')) {
274 return;
275 }
276
277 $errorMessageContainer.hide();
278
279 var
280 $emailAddress = $('#email_address'),
281 emailAddress = null,
282 paypalEmailAddress = $('#paypal_email').val().trim();
283
284 if (1 === $emailAddress.length) {
285 emailAddress = $emailAddress.val().trim();
286
287 if (0 === emailAddress.length) {
288 showErrorMessage('<?php fs_esc_js_echo_inline( 'Email address is required.', 'email-address-is-required', $slug ) ?>');
289 return;
290 }
291 }
292
293 if (0 === paypalEmailAddress.length) {
294 showErrorMessage('<?php fs_esc_js_echo_inline( 'PayPal email address is required.', 'paypal-email-address-is-required', $slug ) ?>');
295 return;
296 }
297
298 var
299 $extraDomains = $extraDomainsContainer.find('.domain'),
300 domain = $domain.val().trim().toLowerCase(),
301 extraDomains = [];
302
303 if (0 === domain.length) {
304 showErrorMessage('<?php fs_esc_js_echo_inline( 'Domain is required.', 'domain-is-required', $slug ) ?>');
305 return;
306 } else if ('freemius.com' === domain) {
307 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + domain + '].');
308 return;
309 }
310
311 if ($extraDomains.length > 0) {
312 var hasError = false;
313
314 $extraDomains.each(function () {
315 var
316 $this = $(this),
317 extraDomain = $this.val().trim().toLowerCase();
318 if (0 === extraDomain.length || extraDomain === domain) {
319 return true;
320 } else if ('freemius.com' === extraDomain) {
321 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + extraDomain + '].');
322 hasError = true;
323 return false;
324 }
325
326 extraDomains.push(extraDomain);
327 });
328
329 if (hasError) {
330 return;
331 }
332 }
333
334 var
335 promotionMethods = [],
336 statisticsInformation = $('#statistics_information').val(),
337 promotionMethodDescription = $('#promotion_method_description').val();
338
339 if ($socialMedia.attr('checked')) {
340 promotionMethods.push('social_media');
341 }
342
343 if ($mobileApps.attr('checked')) {
344 promotionMethods.push('mobile_apps');
345 }
346
347 var affiliate = {
348 full_name : $('#full_name').val().trim(),
349 paypal_email : paypalEmailAddress,
350 stats_description : statisticsInformation,
351 promotion_method_description: promotionMethodDescription
352 };
353
354 if (null !== emailAddress) {
355 affiliate.email = emailAddress;
356 }
357
358 affiliate.domain = domain;
359 affiliate.additional_domains = extraDomains;
360
361 if (promotionMethods.length > 0) {
362 affiliate.promotion_methods = promotionMethods.join(',');
363 }
364
365 $.ajax({
366 url : ajaxurl,
367 method : 'POST',
368 data : {
369 action : '<?php echo $fs->get_ajax_action( 'submit_affiliate_application' ) ?>',
370 security : '<?php echo $fs->get_ajax_security( 'submit_affiliate_application' ) ?>',
371 module_id: '<?php echo $module_id ?>',
372 affiliate: affiliate
373 },
374 beforeSend: function () {
375 $cancelButton.addClass('disabled');
376 $submitButton.addClass('disabled');
377 $submitButton.text('<?php fs_esc_js_echo_inline( 'Submitting', 'submitting' ) ?>...');
378 },
379 success : function (result) {
380 if (result.success) {
381 location.reload();
382 } else {
383 if (result.error && result.error.length > 0) {
384 showErrorMessage(result.error);
385 }
386
387 $cancelButton.removeClass('disabled');
388 $submitButton.removeClass('disabled');
389 $submitButton.text('<?php echo esc_js( $apply_to_become_affiliate_text ) ?>')
390 }
391 }
392 });
393 });
394
395 $cancelButton.click(function (evt) {
396 evt.preventDefault();
397
398 var $this = $(this);
399
400 if ($this.hasClass('disabled')) {
401 return;
402 }
403
404 $applicationFormContainer.hide();
405 $this.hide();
406 $submitButton.hide();
407
408 $applyButton.show();
409
410 window.scrollTo(0, 0);
411 });
412
413 $domain.on('input propertychange', onDomainChange);
414
415 $addDomain.click(function (evt) {
416 evt.preventDefault();
417
418 var
419 $this = $(this),
420 domain = $domain.val().trim();
421
422 if ($this.hasClass('disabled') || 0 === domain.length) {
423 return;
424 }
425
426 $domain.off('input propertychange');
427 $this.addClass('disabled');
428
429 var
430 $extraDomainInputContainer = $('<div class="extra-domain-input-container"><input type="text" class="domain regular-text"/></div>'),
431 $extraDomainInput = $extraDomainInputContainer.find('input'),
432 $removeDomain = $('<a href="#" class="remove-domain"><i class="dashicons dashicons-no" title="<?php fs_esc_js_echo_inline( 'Remove', 'remove', $slug ) ?>"></i></a>');
433
434 $extraDomainInputContainer.append($removeDomain);
435
436 $extraDomainInput.on('input propertychange', onDomainChange);
437
438 $removeDomain.click(function (evt) {
439 evt.preventDefault();
440
441 var
442 $extraDomainInputs = $('.extra-domain-input-container .domain');
443
444 if (1 === $extraDomainInputs.length)
445 $extraDomainInputs.val('').focus();
446 else
447 $(this).parent().remove();
448 });
449
450 $extraDomainsContainer.show();
451
452 $extraDomainInputContainer.appendTo($extraDomainsContainer);
453 $extraDomainInput.focus();
454
455 $this.appendTo($extraDomainsContainer);
456 });
457
458 /**
459 * @author Leo Fajardo (@leorw)
460 */
461 function onDomainChange() {
462 var
463 domain = $(this).val().trim();
464
465 if (domain.length > 0) {
466 $addDomain.removeClass('disabled');
467 } else {
468 $addDomain.addClass('disabled');
469 }
470 }
471
472 /**
473 * @author Leo Fajardo (@leorw)
474 *
475 * @param {String} message
476 */
477 function showErrorMessage(message) {
478 $errorMessageContainer.find('strong').text(message);
479 $errorMessageContainer.show();
480
481 window.scrollTo(0, 0);
482 }
483
484 /**
485 * @author Xiaheng Chen (@xhchen)
486 *
487 * @since 2.4.0
488 */
489 $legalConsentCheckbox.click( function () {
490 if ( $( this ).prop( 'checked' ) ) {
491 $submitButton.removeClass( 'disabled' );
492 } else {
493 $submitButton.addClass( 'disabled' );
494 }
495 } );
496 });
497 </script>
498 </div>
499 <?php
500 $params = array(
501 'page' => 'affiliation',
502 'module_id' => $module_id,
503 'module_slug' => $slug,
504 'module_version' => $fs->get_plugin_version(),
505 );
506 fs_require_template( 'powered-by.php', $params );
507 ?>