args = $args; // Get the patches. if ( $client->get_cached() ) { self::$patches = $client->get_cached(); } else { self::$patches = $client->query_patch_server(); // Cache the patches. $client->cache_response(); } // Returns a formatted array of patches. return $client->prepare_patches(); } /** * Queries the patches server for a list of patches. * * @return bool|array */ private function query_patch_server() { $args = [ 'limit' => true, ]; if ( defined( 'AVADA_VERSION' ) ) { $args['avada_version'] = AVADA_VERSION; } if ( defined( 'FUSION_CORE_VERSION' ) ) { $args['fusion_core_version'] = FUSION_CORE_VERSION; } if ( defined( 'FUSION_BUILDER_VERSION' ) ) { $args['fusion_builder_version'] = FUSION_BUILDER_VERSION; } if ( defined( 'FUSION_WHITE_LABEL_BRANDING_VERSION' ) ) { $args['fusion_white_label_branding_version'] = FUSION_WHITE_LABEL_BRANDING_VERSION; } // Pass on reg data just in case. if ( class_exists( 'Avada' ) ) { if ( Avada()->registration->is_registered() ) { $args['code'] = Avada()->registration->get_purchase_code(); } elseif ( Avada()->registration->legacy_support() ) { $args['token'] = Avada()->registration->get_token(); } } // Bypass cache if forced. if ( isset( $_GET['reset_transient'] ) && '1' === $_GET['reset_transient'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $args['avada-api'] = 1; } // Build the remote server URL using the provided version. $url = add_query_arg( $args, self::$remote_patches_uri ); // Get the server response. $response = wp_remote_get( $url, [ 'user-agent' => 'fusion-patcher-client', ] ); // Return false if we couldn't get to the server. if ( is_wp_error( $response ) ) { /* translators: Update server url. */ new Fusion_Patcher_Admin_Notices( 'server-unreachable', sprintf( esc_html__( 'The ThemeFusion patches server could not be reached. Please contact your host to unblock the "%s" domain.', 'Avada' ), FUSION_UPDATES_URL ) ); return false; } // Return false if the response does not have a body. if ( ! isset( $response['body'] ) || 200 !== $response['response']['code'] ) { return false; } $json = $response['body']; // Response may have comments from caching plugins making it invalid. if ( false !== strpos( $response['body'], '