endpoint_url ) ) { return []; } $data = $this->get_config_data_from_endpoint(); // Store in transient for next time. set_transient( $transient_name, $data, MONTH_IN_SECONDS ); } return $data; } /** * Query the endpoint for config data. * * @return array */ protected function get_config_data_from_endpoint() : array { $data = []; $response = wp_safe_remote_get( $this->endpoint_url, [ 'method' => 'GET', 'timeout' => 30, 'user_agent' => WP_LAUNCH_CHECKLIST_NAME, 'reject_unsafe_urls' => true, ] ); if ( is_wp_error( $response ) ) { return $data; } $response_body = wp_remote_retrieve_body( $response ); if ( empty( $response_body ) ) { return $data; } /** * Format the accessibility config array to the same format * as the plugin's checklist_items.php file so we can * combine it with that array for easier display. */ foreach ( json_decode( $response_body ) as $key => $items ) { foreach ( $items as $index => $obj ) { $data['tasks'][] = [ 'name' => $obj->checkboxId, 'label' => $obj->title, 'description' => sprintf( '

%s

%s', $obj->description, $obj->url, $obj->wcag ), ]; } } return $data; } }