function save_ldp_meta_for_post($resource_id) { $fields = WpLdpUtils::getResourceFieldsList($resource_id); if (!empty($fields)) { foreach ($_POST as $key => $value) { foreach ($fields as $field) { if ($key === $field->name) { update_post_meta($resource_id, $key, $value); } } } } }
<?php header('Content-Type: application/ld+json'); header('Access-Control-Allow-Origin: *'); // Getting general information about the container associated with the current resource $fields = WpLdpUtils::getResourceFieldsList($post->ID); $rdfType = isset($termMeta["ldp_rdf_type"]) ? $termMeta["ldp_rdf_type"] : null; ?> { "@context": "<?php echo get_option('ldp_context', 'http://owl.openinitiative.com/oicontext.jsonld'); ?> ", "@graph": [ <?php while (have_posts()) { the_post(); ?> { <?php $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null; // Handling special case of editing trhough the wordpress admin backend if (!empty($referer) && strstr($referer, 'wp-admin/post.php')) { foreach ($fields as $field) { echo ' "' . $field->name . '": '; echo '' . json_encode(get_post_custom_values($field->name)[0]) . ','; echo "\n"; } } else { $arrayToProcess = []; $fieldNotToRender = [];