Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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

#----------------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions templates/debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@
<td>
<button id="fs_set_db_option" class="button"><?php fs_esc_html_echo_inline( 'Set DB Option' ) ?></button>
</td>
<td>
<button id="fs_check_connectivity_option" class="button"><?php fs_esc_html_echo_inline( 'Check Connectivity' ) ?></button>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -140,6 +143,14 @@
}
}
});

$('#fs_check_connectivity_option').click(function () {
$.post(ajaxurl, {
action: 'fs_check_connectivity',
}, function (response) {
alert("Response: " + response);
});
})
})(jQuery);
</script>
<?php
Expand Down