account
4 years ago
debug
5 years ago
forms
5 years ago
js
5 years ago
partials
4 years ago
plugin-info
5 years ago
account.php
5 years ago
add-ons.php
5 years ago
add-trial-to-pricing.php
5 years ago
admin-notice.php
5 years ago
ajax-loader.php
4 years ago
auto-installation.php
5 years ago
checkout.php
5 years ago
connect.php
5 years ago
contact.php
5 years ago
debug.php
4 years ago
email.php
5 years ago
firewall-issues-js.php
4 years ago
gdpr-optin-js.php
5 years ago
index.php
5 years ago
plugin-icon.php
5 years ago
powered-by.php
5 years ago
pricing.php
5 years ago
secure-https-header.php
5 years ago
sticky-admin-notice-js.php
4 years ago
tabs-capture-js.php
5 years ago
tabs.php
5 years ago
firewall-issues-js.php
64 lines
| 1 | <?php |
| 2 | /** |
| 3 | * API connectivity issues (CloudFlare's firewall) handler for handling different |
| 4 | * scenarios selected by the user after connectivity issue is detected, by sending |
| 5 | * AJAX call to the server in order to make the actual actions. |
| 6 | * |
| 7 | * @package Freemius |
| 8 | * @copyright Copyright (c) 2015, Freemius, Inc. |
| 9 | * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 |
| 10 | * @since 1.0.9 |
| 11 | */ |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; |
| 15 | } |
| 16 | ?> |
| 17 | <script type="text/javascript"> |
| 18 | jQuery( document ).ready(function( $ ) { |
| 19 | $( '#fs_firewall_issue_options a.fs-resolve' ).click(function() { |
| 20 | var |
| 21 | error_type = $( this ).attr( 'data-type' ), |
| 22 | notice = $( this ).parents( '.fs-notice' ), |
| 23 | ajaxActionSuffix = notice.attr( 'data-manager-id' ).replace( ':', '-' ); |
| 24 | |
| 25 | var data = { |
| 26 | action : 'fs_resolve_firewall_issues_' + ajaxActionSuffix, |
| 27 | // As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline. |
| 28 | _wpnonce : <?php echo wp_json_encode( wp_create_nonce( 'fs_resolve_firewall_issues' ) ); ?>, |
| 29 | error_type: error_type |
| 30 | }; |
| 31 | |
| 32 | if ( 'squid' === error_type ) { |
| 33 | data.hosting_company = prompt( 'What is the name or URL of your hosting company?' ); |
| 34 | if ( null == data.hosting_company ) |
| 35 | return false; |
| 36 | |
| 37 | if ( '' === data.hosting_company ) { |
| 38 | alert( 'We won\'t be able to help without knowing your hosting company.' ); |
| 39 | return false; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | if ( 'retry_ping' === error_type ) { |
| 44 | data.action = 'fs_retry_connectivity_test_' + ajaxActionSuffix; |
| 45 | // As such we don't need to use `wp_json_encode` method but using it to follow wp.org guideline. |
| 46 | data._wpnonce = <?php echo wp_json_encode( wp_create_nonce( 'fs_retry_connectivity_test' ) ); ?>; |
| 47 | } |
| 48 | |
| 49 | $( this ).css({'cursor': 'wait'}); |
| 50 | |
| 51 | // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php |
| 52 | $.post( ajaxurl, data, function( response ) { |
| 53 | if ( 1 == response ) { |
| 54 | // Refresh page on success. |
| 55 | location.reload(); |
| 56 | } else if ( 'http' === response.substr( 0, 4 ) ) { |
| 57 | // Ping actually worked, redirect. |
| 58 | window.location = response; |
| 59 | } |
| 60 | }); |
| 61 | }); |
| 62 | }); |
| 63 | </script> |
| 64 |