/** * Get boxes with properties slug for a taxonomy. * * @param int $id * @param bool $only_slugs * * @since 3.1.0 `$id` param is optional. * * @return array */ function papi_get_term_slugs($id = 0, $only_slugs = false) { if (is_bool($id)) { $only_slugs = $id; $id = null; } return papi_get_slugs(papi_get_term_id($id), $only_slugs, 'term'); }
/** * Get boxes with properties slug for a page. * * You should use papi_get_slugs() instead. * * @param int $post_id * * @deprecated deprecated since version 2.0.0. * * @return array */ function papi_fields($post_id = 0) { _deprecated_function(__FUNCTION__, '2.0.0', 'papi_get_slugs'); return papi_get_slugs($post_id); }
/** * Restore to post revision. * * @param int $post_id * @param int $revision_id */ public function restore_post_revision($post_id, $revision_id) { $slugs = papi_get_slugs($revision_id, true); foreach ($slugs as $slug) { $value = papi_get_field($revision_id, $slug); if (papi_is_empty($value)) { papi_delete_field($post_id, $slug); } else { papi_update_field($post_id, $slug, $value); } } }
/** * Export data from Papi. With or without all property options. * * @param mixed $post_id * @param bool $only_values * * @return array */ public function export($post_id, $only_values = false) { $post_id = papi_get_post_id($post_id); if (empty($post_id)) { return []; } $slugs = papi_get_slugs($post_id); foreach ($slugs as $key => $box) { foreach ($box as $index => $slug) { unset($slugs[$key][$index]); $value = papi_get_field($post_id, $slug, null); if ($only_values === true) { $slugs[$key][$slug] = $value; } else { $store = papi_get_meta_store($post_id); // @codeCoverageIgnoreStart if (is_null($store)) { continue; } // @codeCoverageIgnoreEnd $property = $store->get_property($slug); // @codeCoverageIgnoreStart if (!papi_is_property($property)) { continue; } // @codeCoverageIgnoreEnd $options = clone $property->get_options(); $options->value = $value; $slugs[$key][$slug] = $options; } } } return $slugs; }
?> </td> </tr> <tr> <td>Template</td> <td><?php global $template; echo basename($template); ?> </td> </tr> <tr> <td>Fields</td> <td> <?php print_r(papi_get_slugs()); ?> </td> </tr> <tr> <td>URL</td> <td> <a href="<?php echo current_url(); ?> "><?php echo current_url(); ?> </a> </td> </tr>