PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.9
Code Manager v1.0.9
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 4 years ago affiliation.php 4 years ago data-debug-mode.php 4 years ago index.php 4 years ago license-activation.php 4 years ago optout.php 4 years ago premium-versions-upgrade-handler.php 4 years ago premium-versions-upgrade-metadata.php 4 years ago resend-key.php 4 years ago subscription-cancellation.php 4 years ago trial-start.php 4 years ago user-change.php 4 years ago
affiliation.php
509 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 <?php if ( ! $is_affiliate ) : ?>
224 <div>
225 <input type="checkbox" id="legal_consent_checkbox">
226 <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>
227 </div>
228 <?php endif ?>
229 </form>
230 </div>
231 <?php if ( ! $is_affiliate ) : ?>
232 <a id="cancel_button" href="#" class="button button-secondary button-cancel" style="display: none"><?php fs_esc_html_echo_inline( 'Cancel', 'cancel', $slug ) ?></a>
233 <a id="submit_button" class="button button-primary disabled" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a>
234 <a id="apply_button" class="button button-primary" href="#"><?php fs_esc_html_echo_inline( 'Become an affiliate', 'become-an-affiliate', $slug ) ?></a>
235 <?php endif ?>
236 </div>
237 </div>
238 </div>
239 </div>
240 </form>
241 <script type="text/javascript">
242 jQuery(function ($) {
243 var
244 $contentWrapper = $('#fs_affiliation_content_wrapper'),
245 $socialMedia = $('#promotion_method_social_media'),
246 $mobileApps = $('#promotion_method_mobile_apps'),
247 $applyButton = $('#apply_button'),
248 $submitButton = $('#submit_button'),
249 $cancelButton = $('#cancel_button'),
250 $applicationFormContainer = $('#application_form_container'),
251 $errorMessageContainer = $('#error_message'),
252 $domain = $('#domain'),
253 $addDomain = $('#add_domain'),
254 $extraDomainsContainer = $('#extra_domains_container'),
255 $legalConsentCheckbox = $( '#legal_consent_checkbox' );
256
257 $applyButton.click(function (evt) {
258 evt.preventDefault();
259
260 var $this = $(this);
261 $this.hide();
262
263 $applicationFormContainer.show();
264 $cancelButton.show();
265 $submitButton.show();
266
267 $contentWrapper.find('input[type="text"]:first').focus();
268 });
269
270 $submitButton.click(function (evt) {
271 evt.preventDefault();
272
273 var $this = $(this);
274
275 if ($this.hasClass('disabled')) {
276 return;
277 }
278
279 $errorMessageContainer.hide();
280
281 var
282 $emailAddress = $('#email_address'),
283 emailAddress = null,
284 paypalEmailAddress = $('#paypal_email').val().trim();
285
286 if (1 === $emailAddress.length) {
287 emailAddress = $emailAddress.val().trim();
288
289 if (0 === emailAddress.length) {
290 showErrorMessage('<?php fs_esc_js_echo_inline( 'Email address is required.', 'email-address-is-required', $slug ) ?>');
291 return;
292 }
293 }
294
295 if (0 === paypalEmailAddress.length) {
296 showErrorMessage('<?php fs_esc_js_echo_inline( 'PayPal email address is required.', 'paypal-email-address-is-required', $slug ) ?>');
297 return;
298 }
299
300 var
301 $extraDomains = $extraDomainsContainer.find('.domain'),
302 domain = $domain.val().trim().toLowerCase(),
303 extraDomains = [];
304
305 if (0 === domain.length) {
306 showErrorMessage('<?php fs_esc_js_echo_inline( 'Domain is required.', 'domain-is-required', $slug ) ?>');
307 return;
308 } else if ('freemius.com' === domain) {
309 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + domain + '].');
310 return;
311 }
312
313 if ($extraDomains.length > 0) {
314 var hasError = false;
315
316 $extraDomains.each(function () {
317 var
318 $this = $(this),
319 extraDomain = $this.val().trim().toLowerCase();
320 if (0 === extraDomain.length || extraDomain === domain) {
321 return true;
322 } else if ('freemius.com' === extraDomain) {
323 showErrorMessage('<?php fs_esc_js_echo_inline( 'Invalid domain', 'invalid-domain', $slug ) ?>' + ' [' + extraDomain + '].');
324 hasError = true;
325 return false;
326 }
327
328 extraDomains.push(extraDomain);
329 });
330
331 if (hasError) {
332 return;
333 }
334 }
335
336 var
337 promotionMethods = [],
338 statisticsInformation = $('#statistics_information').val(),
339 promotionMethodDescription = $('#promotion_method_description').val();
340
341 if ($socialMedia.attr('checked')) {
342 promotionMethods.push('social_media');
343 }
344
345 if ($mobileApps.attr('checked')) {
346 promotionMethods.push('mobile_apps');
347 }
348
349 var affiliate = {
350 full_name : $('#full_name').val().trim(),
351 paypal_email : paypalEmailAddress,
352 stats_description : statisticsInformation,
353 promotion_method_description: promotionMethodDescription
354 };
355
356 if (null !== emailAddress) {
357 affiliate.email = emailAddress;
358 }
359
360 affiliate.domain = domain;
361 affiliate.additional_domains = extraDomains;
362
363 if (promotionMethods.length > 0) {
364 affiliate.promotion_methods = promotionMethods.join(',');
365 }
366
367 $.ajax({
368 url : ajaxurl,
369 method : 'POST',
370 data : {
371 action : '<?php echo $fs->get_ajax_action( 'submit_affiliate_application' ) ?>',
372 security : '<?php echo $fs->get_ajax_security( 'submit_affiliate_application' ) ?>',
373 module_id: '<?php echo $module_id ?>',
374 affiliate: affiliate
375 },
376 beforeSend: function () {
377 $cancelButton.addClass('disabled');
378 $submitButton.addClass('disabled');
379 $submitButton.text('<?php fs_esc_js_echo_inline( 'Submitting', 'submitting' ) ?>...');
380 },
381 success : function (result) {
382 if (result.success) {
383 location.reload();
384 } else {
385 if (result.error && result.error.length > 0) {
386 showErrorMessage(result.error);
387 }
388
389 $cancelButton.removeClass('disabled');
390 $submitButton.removeClass('disabled');
391 $submitButton.text('<?php echo esc_js( $apply_to_become_affiliate_text ) ?>')
392 }
393 }
394 });
395 });
396
397 $cancelButton.click(function (evt) {
398 evt.preventDefault();
399
400 var $this = $(this);
401
402 if ($this.hasClass('disabled')) {
403 return;
404 }
405
406 $applicationFormContainer.hide();
407 $this.hide();
408 $submitButton.hide();
409
410 $applyButton.show();
411
412 window.scrollTo(0, 0);
413 });
414
415 $domain.on('input propertychange', onDomainChange);
416
417 $addDomain.click(function (evt) {
418 evt.preventDefault();
419
420 var
421 $this = $(this),
422 domain = $domain.val().trim();
423
424 if ($this.hasClass('disabled') || 0 === domain.length) {
425 return;
426 }
427
428 $domain.off('input propertychange');
429 $this.addClass('disabled');
430
431 var
432 $extraDomainInputContainer = $('<div class="extra-domain-input-container"><input type="text" class="domain regular-text"/></div>'),
433 $extraDomainInput = $extraDomainInputContainer.find('input'),
434 $removeDomain = $('<a href="#" class="remove-domain"><i class="dashicons dashicons-no" title="<?php fs_esc_js_echo_inline( 'Remove', 'remove', $slug ) ?>"></i></a>');
435
436 $extraDomainInputContainer.append($removeDomain);
437
438 $extraDomainInput.on('input propertychange', onDomainChange);
439
440 $removeDomain.click(function (evt) {
441 evt.preventDefault();
442
443 var
444 $extraDomainInputs = $('.extra-domain-input-container .domain');
445
446 if (1 === $extraDomainInputs.length)
447 $extraDomainInputs.val('').focus();
448 else
449 $(this).parent().remove();
450 });
451
452 $extraDomainsContainer.show();
453
454 $extraDomainInputContainer.appendTo($extraDomainsContainer);
455 $extraDomainInput.focus();
456
457 $this.appendTo($extraDomainsContainer);
458 });
459
460 /**
461 * @author Leo Fajardo (@leorw)
462 */
463 function onDomainChange() {
464 var
465 domain = $(this).val().trim();
466
467 if (domain.length > 0) {
468 $addDomain.removeClass('disabled');
469 } else {
470 $addDomain.addClass('disabled');
471 }
472 }
473
474 /**
475 * @author Leo Fajardo (@leorw)
476 *
477 * @param {String} message
478 */
479 function showErrorMessage(message) {
480 $errorMessageContainer.find('strong').text(message);
481 $errorMessageContainer.show();
482
483 window.scrollTo(0, 0);
484 }
485
486 /**
487 * @author Xiaheng Chen (@xhchen)
488 *
489 * @since 2.4.0
490 */
491 $legalConsentCheckbox.click( function () {
492 if ( $( this ).prop( 'checked' ) ) {
493 $submitButton.removeClass( 'disabled' );
494 } else {
495 $submitButton.addClass( 'disabled' );
496 }
497 } );
498 });
499 </script>
500 </div>
501 <?php
502 $params = array(
503 'page' => 'affiliation',
504 'module_id' => $module_id,
505 'module_slug' => $slug,
506 'module_version' => $fs->get_plugin_version(),
507 );
508 fs_require_template( 'powered-by.php', $params );
509 ?>