PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.4
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.4
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / forms / affiliation.php

affiliation.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.4, at freemius/templates/forms/affiliation.php

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