Created
July 12, 2016 16:43
-
-
Save NateJLewis/53a5466f1d3a1ef41fdfb758877d37ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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