Skip to content

Instantly share code, notes, and snippets.

@NateJLewis
Created July 12, 2016 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NateJLewis/53a5466f1d3a1ef41fdfb758877d37ab to your computer and use it in GitHub Desktop.
Save NateJLewis/53a5466f1d3a1ef41fdfb758877d37ab to your computer and use it in GitHub Desktop.
<?php
function _wgt_scripts() {
// styles and scripts code...
$form_html = array(
'trip_signup_form' => _wgt_get_trip_signup_form_html(),
'request_trip_quote' => _wgt_request_trip_quote_form_html()
);
wp_localize_script(
'wgt-app',
'wgtApi',
array(
//bunch of code added to rest..
'form_html' => $form_html
)
);
}
add_action( 'wp_enqueue_scripts', '_wgt_scripts' );
function _wgt_get_trip_signup_form_html() {
$trip_signup_form_endpoint = esc_url_raw( get_rest_url() ) . 'frm/v2/forms/13?return=html';
$curl = curl_init( $trip_signup_form_endpoint );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
$trip_signup_form_response = curl_exec( $curl );
curl_close( $curl );
$trip_signup_form = json_decode( $trip_signup_form_response, true );
return $trip_signup_form;
}
function _wgt_request_trip_quote_form_html() {
$request_trip_quote_form_endpoint = esc_url_raw( get_rest_url() ) . 'frm/v2/forms/11?return=html';
$curl = curl_init( $request_trip_quote_form_endpoint );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0 );
$request_trip_quote_form_response = curl_exec( $curl );
curl_close( $curl );
$request_trip_quote_form = json_decode( $request_trip_quote_form_response, true );
return $request_trip_quote_form;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment