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