Skip to main content

Wordpress

<?php
/**
* Template Name: FluentC Connected Page
*
* @package WordPress
* @subpackage FluentC
* @since Forever
*/


get_header(); ?>

<?php

$url_lang = get_query_var('l');
$browserlang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);

if ($url_lang == $browserlang) {
//The same language
$l = $browserlang;
}
elseif (strlen($url_lang) < 1) {
$l = $browserlang;
}
else {
$l = $url_lang;
}
//Change environmentID to your FluentC environmentID
$query = "query {
requestContent(environmentID: \"b3d2db17-fd81-42ee-81f1-f0541d8e81a8\", language: \"".$l."\") {
body {
key
value
}
}
}";

$payload = json_encode( array( "query"=> $query ) );
$graphqlEndpoint = 'https://api.fluentc.io/graphql';

// This is where you run the code and display the output
// Change x-api-key to match your x-api-key
$curl = curl_init();
$headers = array(
'Content-Type : application/json; charset=UTF-8',
'x-api-key : da2-wtkl5bpofjbu5ex5iugu4o2mbm',
);
curl_setopt_array($curl, array(
CURLOPT_URL => $graphqlEndpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => $headers,
));

$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
$body = json_decode($response);
$data = $body->data->requestContent->body;

//The following is display code that should be replaced with your display code
?>
<div id="primary" class="content-area container" role="main">
<div class="row">
<div class="<?php echo apply_filters( 'jobify_single_column_spans', 'col-sm-12 col-md-10 col-md-offset-1' ); ?>">

<?php
// End Display code
$content = get_the_content();
$content = apply_filters( 'the_content', $content );
$content = str_replace( ']]>', ']]&gt;', $content );
/////Form Txt Change
// Temp till FluentC is on every page - MVP
///////////////
$form_fields = array("First Name", "Last Name", "E-mail", "Password", "Contact Info");

foreach($form_fields as $field) {
$content = str_replace($field,"{*".$field."*}",$content);
}
foreach($data as $key => $value) { //foreach element in $arr

$fluentckey = "{*".$value->key."*}";

$fluentcvalue = $value->value;
$content = str_replace($fluentckey,$fluentcvalue,$content);

}

echo $content;

//End of Display code
?>
</div>
</div>

<?php do_action( 'jobify_loop_after' ); ?>
</div><!-- #primary -->

<?php get_footer(); ?>