| @@ -12,10 +12,12 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * @var array $VARS |
| 15 | 15 | * @var Freemius $fs |
| 16 | + * @var string $plugin_title | |
| 16 | 17 | */ |
| 17 | - $fs = freemius( $VARS['id'] ); | |
| 18 | + $fs = freemius( $VARS['id'] ); | |
| 19 | + $plugin_title = $VARS['plugin_title']; | |
| 18 | 20 | |
| 19 | 21 | $slug = $fs->get_slug(); |
| 20 | 22 | |
| 21 | 23 | $user = $fs->get_user(); |
| @@ -21,9 +23,8 @@ | ||
| 21 | 23 | $user = $fs->get_user(); |
| 22 | 24 | $affiliate = $fs->get_affiliate(); |
| 23 | 25 | $affiliate_terms = $fs->get_affiliate_terms(); |
| 24 | 26 | |
| 25 | - $plugin_title = $fs->get_plugin_title(); | |
| 26 | 27 | $module_type = $fs->is_plugin() ? |
| 27 | 28 | WP_FS__MODULE_TYPE_PLUGIN : |
| 28 | 29 | WP_FS__MODULE_TYPE_THEME; |
| 29 | 30 | |
| @@ -44,9 +45,9 @@ | ||
| 44 | 45 | $promotion_method_social_media = false; |
| 45 | 46 | $promotion_method_mobile_apps = false; |
| 46 | 47 | $statistics_information = false; |
| 47 | 48 | $promotion_method_description = false; |
| 48 | - $members_dashboard_login_url = 'https://members.freemius.com/login/'; | |
| 49 | + $members_dashboard_login_url = 'https://users.freemius.com/login'; | |
| 49 | 50 | |
| 50 | 51 | $affiliate_application_data = $fs->get_affiliate_application_data(); |
| 51 | 52 | |
| 52 | 53 | if ( $is_affiliate && $affiliate->is_pending() ) { |
| @@ -67,12 +68,15 @@ | ||
| 67 | 68 | $promotion_method_social_media = in_array( 'social_media', $promotion_methods ); |
| 68 | 69 | $promotion_method_mobile_apps = in_array( 'mobile_apps', $promotion_methods ); |
| 69 | 70 | } |
| 70 | 71 | } 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() ); | |
| 72 | + if ( ! is_object( $user ) ) { | |
| 73 | + $current_user = Freemius::_get_current_wp_user(); | |
| 74 | + $full_name = trim( $current_user->user_firstname . ' ' . $current_user->user_lastname ); | |
| 75 | + $email_address = $current_user->user_email; | |
| 76 | + } | |
| 77 | + | |
| 78 | + $domain = Freemius::get_unfiltered_site_url( null, true ); | |
| 75 | 79 | } |
| 76 | 80 | |
| 77 | 81 | $affiliate_tracking = 30; |
| 78 | 82 | |
| @@ -82,8 +86,13 @@ | ||
| 82 | 86 | fs_text_inline( 'Non-expiring', 'non-expiring', $slug ) ); |
| 83 | 87 | } |
| 84 | 88 | |
| 85 | 89 | $apply_to_become_affiliate_text = fs_text_inline( 'Apply to become an affiliate', 'apply-to-become-an-affiliate', $slug ); |
| 90 | + | |
| 91 | + $module_id = $fs->get_id(); | |
| 92 | + $affiliate_program_terms_url = "https://freemius.com/plugin/{$module_id}/{$slug}/legal/affiliate-program/"; | |
| 93 | + | |
| 94 | + $has_tabs = $fs->_add_tabs_before_content(); | |
| 86 | 95 | ?> |
| 87 | 96 | <div id="fs_affiliation_content_wrapper" class="wrap"> |
| 88 | 97 | <form method="post" action=""> |
| 89 | 98 | <div id="poststuff"> |
| @@ -103,9 +112,9 @@ | ||
| 103 | 112 | echo sprintf( |
| 104 | 113 | fs_esc_html_inline( "Your affiliate application for %s has been accepted! Log in to your affiliate area at: %s.", 'affiliate-application-accepted', $slug ), |
| 105 | 114 | $plugin_title, |
| 106 | 115 | sprintf( |
| 107 | - '<a href="%s" target="_blank">%s</a>', | |
| 116 | + '<a href="%s" target="_blank" rel="noopener">%s</a>', | |
| 108 | 117 | $members_dashboard_login_url, |
| 109 | 118 | $members_dashboard_login_url |
| 110 | 119 | ) |
| 111 | 120 | ); |
| @@ -216,13 +225,19 @@ | ||
| 216 | 225 | <?php if ( ! $is_affiliate ) : ?> |
| 217 | 226 | <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> |
| 218 | 227 | <?php endif ?> |
| 219 | 228 | </div> |
| 229 | + <?php if ( ! $is_affiliate ) : ?> | |
| 230 | + <div> | |
| 231 | + <input type="checkbox" id="legal_consent_checkbox"> | |
| 232 | + <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> | |
| 233 | + </div> | |
| 234 | + <?php endif ?> | |
| 220 | 235 | </form> |
| 221 | 236 | </div> |
| 222 | 237 | <?php if ( ! $is_affiliate ) : ?> |
| 223 | 238 | <a id="cancel_button" href="#" class="button button-secondary button-cancel" style="display: none"><?php fs_esc_html_echo_inline( 'Cancel', 'cancel', $slug ) ?></a> |
| 224 | - <a id="submit_button" class="button button-primary" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a> | |
| 239 | + <a id="submit_button" class="button button-primary disabled" href="#" style="display: none"><?php echo esc_html( $apply_to_become_affiliate_text ) ?></a> | |
| 225 | 240 | <a id="apply_button" class="button button-primary" href="#"><?php fs_esc_html_echo_inline( 'Become an affiliate', 'become-an-affiliate', $slug ) ?></a> |
| 226 | 241 | <?php endif ?> |
| 227 | 242 | </div> |
| 228 | 243 | </div> |
| @@ -241,9 +256,10 @@ | ||
| 241 | 256 | $applicationFormContainer = $('#application_form_container'), |
| 242 | 257 | $errorMessageContainer = $('#error_message'), |
| 243 | 258 | $domain = $('#domain'), |
| 244 | 259 | $addDomain = $('#add_domain'), |
| 245 | - $extraDomainsContainer = $('#extra_domains_container'); | |
| 260 | + $extraDomainsContainer = $('#extra_domains_container'), | |
| 261 | + $legalConsentCheckbox = $( '#legal_consent_checkbox' ); | |
| 246 | 262 | |
| 247 | 263 | $applyButton.click(function (evt) { |
| 248 | 264 | evt.preventDefault(); |
| 249 | 265 | |
| @@ -354,14 +370,14 @@ | ||
| 354 | 370 | affiliate.promotion_methods = promotionMethods.join(','); |
| 355 | 371 | } |
| 356 | 372 | |
| 357 | 373 | $.ajax({ |
| 358 | - url : ajaxurl, | |
| 374 | + url : <?php echo Freemius::ajax_url() ?>, | |
| 359 | 375 | method : 'POST', |
| 360 | 376 | data : { |
| 361 | 377 | action : '<?php echo $fs->get_ajax_action( 'submit_affiliate_application' ) ?>', |
| 362 | 378 | security : '<?php echo $fs->get_ajax_security( 'submit_affiliate_application' ) ?>', |
| 363 | - module_id: '<?php echo $fs->get_id() ?>', | |
| 379 | + module_id: '<?php echo $module_id ?>', | |
| 364 | 380 | affiliate: affiliate |
| 365 | 381 | }, |
| 366 | 382 | beforeSend: function () { |
| 367 | 383 | $cancelButton.addClass('disabled'); |
| @@ -471,16 +487,24 @@ | ||
| 471 | 487 | $errorMessageContainer.show(); |
| 472 | 488 | |
| 473 | 489 | window.scrollTo(0, 0); |
| 474 | 490 | } |
| 491 | + | |
| 492 | + /** | |
| 493 | + * @author Xiaheng Chen (@xhchen) | |
| 494 | + * | |
| 495 | + * @since 2.4.0 | |
| 496 | + */ | |
| 497 | + $legalConsentCheckbox.click( function () { | |
| 498 | + if ( $( this ).prop( 'checked' ) ) { | |
| 499 | + $submitButton.removeClass( 'disabled' ); | |
| 500 | + } else { | |
| 501 | + $submitButton.addClass( 'disabled' ); | |
| 502 | + } | |
| 503 | + } ); | |
| 475 | 504 | }); |
| 476 | 505 | </script> |
| 477 | 506 | </div> |
| 478 | 507 | <?php |
| 479 | - $params = array( | |
| 480 | - 'page' => 'affiliation', | |
| 481 | - 'module_id' => $fs->get_id(), | |
| 482 | - 'module_slug' => $slug, | |
| 483 | - 'module_version' => $fs->get_plugin_version(), | |
| 484 | - ); | |
| 485 | - fs_require_template( 'powered-by.php', $params ); | |
| 486 | -?> | |
| 508 | + if ( $has_tabs ) { | |
| 509 | + $fs->_add_tabs_after_content(); | |
| 510 | + } | |