Skip to content

Commit

Permalink
⚡ JSON invalid added additional checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydeeptrivedi13 committed Jan 7, 2025
1 parent 2d065fc commit c3dc07c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion edwiser-bridge/admin/class-eb-settings-ajax-initiater.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,22 @@ public function check_valid_json_response() {
$url = isset( $_POST['url'] ) ? sanitize_text_field( wp_unslash( $_POST['url'] ) ) : '';
$token = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';


$url2 = rest_url('edwiser-bridge');
// Send a GET request to the endpoint
$internal_response = wp_safe_remote_get($url2, array('timeout' => '60'));
$body = json_decode( wp_remote_retrieve_body( $internal_response ) );

if ( json_last_error() === JSON_ERROR_NONE ) {
$valid = true;
} else {
$valid = false;
return wp_send_json_success( array( 'data' => $valid ) );
}

$connection_helper = new Eb_Connection_Helper( $this->plugin_name, $this->version );
$response = $connection_helper->get_raw_response( $url, $token );

$body = json_decode( wp_remote_retrieve_body( $response ) );
if ( null !== $body || json_last_error() === JSON_ERROR_NONE ) {
$valid = true;
Expand Down
4 changes: 2 additions & 2 deletions edwiser-bridge/freemius/includes/class-freemius.php
Original file line number Diff line number Diff line change
Expand Up @@ -3429,8 +3429,8 @@ private static function _load_required_static() {

FS_DebugManager::load_required_static();

if ( 0 == did_action( 'plugins_loaded' ) ) {
add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
if ( 0 == did_action( 'init' ) ) {
add_action( 'init', array( 'Freemius', '_load_textdomain' ), 1 );
}

$clone_manager = FS_Clone_Manager::instance();
Expand Down

0 comments on commit c3dc07c

Please sign in to comment.