diff --git a/includes/class-freemius.php b/includes/class-freemius.php index a5b94fc54..cd8c73165 100755 --- a/includes/class-freemius.php +++ b/includes/class-freemius.php @@ -3425,6 +3425,8 @@ private static function _load_required_static() { self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) ); + self::add_ajax_action_static( 'check_connectivity', array( 'Freemius', '_check_connectivity' ) ); + if ( 0 == did_action( 'plugins_loaded' ) ) { add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 ); } @@ -3781,6 +3783,26 @@ static function _debug_page_render() { fs_require_once_template( 'debug.php', $vars ); } + /** + * @author Xiaheng Chen (@xhchen) + */ + static function _check_connectivity() { + $ch = curl_init( 'https://api.freemius.com/v1/ping.json' ); + + curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 ); + curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 ); + + curl_exec( $ch ); + + $httpcode = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); + + curl_close( $ch ); + + echo "\nCode: " . $httpcode; + + exit; + } + #endregion #---------------------------------------------------------------------------------- diff --git a/templates/debug.php b/templates/debug.php index 44b1efc1f..b77dd3f04 100644 --- a/templates/debug.php +++ b/templates/debug.php @@ -100,6 +100,9 @@ + + + @@ -140,6 +143,14 @@ } } }); + + $('#fs_check_connectivity_option').click(function () { + $.post(ajaxurl, { + action: 'fs_check_connectivity', + }, function (response) { + alert("Response: " + response); + }); + }) })(jQuery);