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