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