本文整理汇总了PHP中get_post_custom_keys函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_custom_keys函数的具体用法?PHP get_post_custom_keys怎么用?PHP get_post_custom_keys使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_custom_keys函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_if_post_or_page_has_embed
/**
* Thanks to http://t31os.wordpress.com/2010/05/24/post-has-embed/ for a nicer solution than mine
*/
function test_if_post_or_page_has_embed($post_id = false)
{
if (!$post_id) {
$post_id = get_the_ID();
} else {
$post_id = absint($post_id);
}
if (!$post_id) {
return false;
}
// Get meta keys for current post
$post_meta = get_post_custom_keys($post_id);
if (empty($post_meta)) {
return false;
}
// Search for the first meta_key [$value] that begins with the oembed string [$string]
// After the first hits: continue to return true
if (is_array($post_meta) || $post_meta instanceof Traversable) {
foreach ($post_meta as $meta) {
$first_seven_chars = substr(trim($meta), 0, 7);
if ($first_seven_chars == 'oembed_' || $first_seven_chars == '_oembed') {
return true;
}
// '_oembed' is used by WordPress standardly; 'oembed_' is used by some plugins and themes
}
return false;
} else {
return false;
}
}
示例2: fyb_all_custom_fields
function fyb_all_custom_fields($fyb_allposts)
{
$fyb_customfields = array();
foreach ($fyb_allposts as $fyb_post) {
setup_postdata($fyb_post);
$fyb_post_id = $fyb_post->ID;
$fyb_fields = get_post_custom_keys($fyb_post_id);
if ($fyb_fields) {
foreach ($fyb_fields as $fyb_key => $fyb_value) {
if ($fyb_value[0] != '_') {
if (!isset($fyb_customfields[$fyb_value])) {
$fyb_customfields[$fyb_value] = array();
#$fyb_customfields[$fyb_value]['html'] = '<option value="'.$fyb_value.'">'.$fyb_value.'</option>';
$fyb_customfields[$fyb_value]['count'] = 1;
$fyb_customfields[$fyb_value]['userPost'] = array();
$fyb_customfields[$fyb_value]['userPost'][] = $fyb_post->ID;
$fyb_customfields[$fyb_value]['usedPostType'] = array();
$fyb_customfields[$fyb_value]['usedPostType'][] = $fyb_post->post_type;
} else {
$fyb_customfields[$fyb_value]['count'] = $fyb_customfields[$fyb_value]['count'] + 1;
$fyb_customfields[$fyb_value]['userPost'][] = $fyb_post->ID;
if (!in_array($fyb_post->post_type, $fyb_customfields[$fyb_value]['usedPostType'])) {
$fyb_customfields[$fyb_value]['usedPostType'][] = $fyb_post->post_type;
}
}
}
}
}
}
wp_reset_postdata();
return $fyb_customfields;
}
示例3: AB_external_permalink
function AB_external_permalink($permalink)
{
global $post;
$thePostID = $post->ID;
$internal_post = get_post($thePostID);
$title = $internal_post->post_title;
$post_keys = array();
$post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey == 'original_source') {
$post_val = get_post_custom_values($pkey, $thePostID);
break;
}
}
if (empty($post_val)) {
$link = $permalink;
} else {
$link = $post_val[0];
}
} else {
$link = $permalink;
}
return $link;
}
示例4: tumblrLinkBacks
function tumblrLinkBacks($content)
{
global $wp_query, $post;
$post_id = get_post($post->ID);
$posttitle = $post_id->post_title;
$permalink = get_permalink(get_post($post->ID));
$tumblr_keys = get_post_custom_keys($post->ID);
if (get_post_meta($wp_query->post->ID, 'TumblrURL', true)) {
if ($tumblr_keys) {
foreach ($tumblr_keys as $tumblr_key) {
if ($tumblr_key == 'TumblrURL') {
$tumblr_vals = get_post_custom_values($tumblr_key);
}
}
if ($tumblr_vals) {
if (is_feed()) {
$content .= '<p><a href="' . $tumblr_vals[0] . '" title="Direct link to featured article">Direct Link to Article</a> — ';
$content .= '<a href="' . $permalink . '">Permalink</a></p>';
return $content;
} else {
return $content;
}
}
}
} else {
$content = $content;
return $content;
}
}
示例5: cs_external_permalink
function cs_external_permalink($permalink)
{
global $post;
$thePostID = $post->ID;
$post_id = get_post($thePostID);
$title = $post_id->post_title;
$post_keys = array();
$post_val = array();
$post_keys = get_post_custom_keys($thePostID);
if (!empty($post_keys)) {
foreach ($post_keys as $pkey) {
if ($pkey == 'url1' || $pkey == 'title_url' || $pkey == 'url_title' || $pkey == 'external') {
$post_val = get_post_custom_values($pkey);
}
}
if (empty($post_val)) {
$link = $permalink;
} else {
$link = $post_val[0];
}
} else {
$link = $permalink;
}
return $link;
}
示例6: get_fields
function get_fields($post_id = false)
{
// vars
global $post;
if (!$post_id) {
$post_id = $post->ID;
} elseif ($post_id == "options") {
$post_id = 999999999;
}
// default
$value = array();
$keys = get_post_custom_keys($post_id);
if ($keys) {
foreach ($keys as $key) {
if (substr($key, 0, 1) != "_") {
$value[$key] = get_field($key, $post_id);
}
}
}
// no value
if (empty($value)) {
return false;
}
return $value;
}
示例7: clear_meta
private function clear_meta($post_id)
{
$post_meta_keys = get_post_custom_keys($post_id);
$blacklist = $this->get_meta_key_whitelist($post_id);
$post_meta_keys = array_diff($post_meta_keys, $blacklist);
foreach ($post_meta_keys as $key) {
delete_post_meta($post_id, $key);
}
}
示例8: job_notification_templates
function job_notification_templates($post_id, $notification_receiver)
{
// Applied job title
$job_title = get_the_title($post_id);
// Site URL
$site_url = get_option('siteurl');
$parent_id = wp_get_post_parent_id($post_id);
$job_post_keys = get_post_custom_keys($parent_id);
$applicant_post_keys = get_post_custom_keys($post_id);
if (NULL != $job_post_keys) {
if (in_array('jobfeature_company_name', $job_post_keys)) {
$company_name = get_post_meta($parent_id, 'jobfeature_company_name', TRUE);
}
}
if (NULL != $applicant_post_keys) {
if (in_array('jobapp_name', $applicant_post_keys)) {
$applicant_name = get_post_meta($post_id, 'jobapp_name', TRUE);
}
}
if ('applicant' != $notification_receiver) {
$message = '<div style="width:700px; margin:0 auto; border: 1px solid #95B3D7;font-family:Arial;">' . '<div style="border: 1px solid #95B3D7; background-color:#95B3D7;">' . ' <h2 style="text-align:center;">Job Application </h2>' . ' </div>' . '<div style="margin:10px;">' . '<p>' . date("Y/m/d") . '</p>' . '<p>';
if (NULL != $notification_receiver) {
$message .= 'Hi ' . $notification_receiver . ',';
}
$message .= '</p>' . '<p>I ';
if (NULL != $applicant_name) {
$message .= $applicant_name . '';
}
$message .= ',would like to apply for the post of ' . $job_title . ' at your company ';
if (NULL != $company_name) {
$message .= $company_name . '';
}
$message .= '.</p>' . '<p>I have gone through the application criterion and requirements for the particular job and have posted my resume at given address ' . $site_url . '<br/>' . 'I have also filled the detail of the online application form on ' . date("Y/m/d") . '.' . '</p>' . '<p>I sincerely believe that my educational qualifications and extra-curricular activities will be appropriate for the job and the type of applicant it possible requires.' . 'I promiss to devote my heart and soul to the job once selected to serve your company ';
if (NULL != $company_name) {
$message .= $company_name . '';
}
$message .= '.</p>' . 'I will be extremely grateful if you kindly glance through my application and consider me for the interview and the adjacent processes.' . '</p>' . '<p>I will be eagerly looking forward to your reply mail.</p>' . '<p>Thank you</p>' . '<p>Sincerely,</p>';
if (NULL != $applicant_name) {
$message .= $applicant_name . '';
}
$message .= '</div>' . ' </div>';
} else {
$message = '<div style="width:700px; margin:0 auto; border: 1px solid #95B3D7;font-family:Arial;">' . '<div style="border: 1px solid #95B3D7; background-color:#95B3D7;">' . ' <h2 style="text-align:center;">Job Application Acknowledgement</h2>' . ' </div>' . '<div style="margin:10px;">' . '<p>' . date("Y/m/d") . '</p>' . '<p>';
$message .= 'Hi ';
if (NULL != $applicant_name) {
$message .= '' . $applicant_name . ',';
}
$message .= '<p>Thank you for your interest in ';
if (NULL != $company_name) {
$message .= $company_name . '.';
}
$message .= 'We acknowledge receipt of your resume and application for a position ' . $job_title . ' and sincerely appreciate your interest in our company.' . '</p>' . '<p>We will screen all applicants and select candidates whose qualifications seem to meet our needs.' . ' We will carefully consider your application during the initial screening and will contact you if you are selected to continue in the recruitment process. ' . 'We wish you every success.</p>' . '<p>Regards,</p>' . '<p>Admin,</p>' . '<p>' . get_bloginfo('name') . '</p>';
$message .= '</div>' . ' </div>';
}
return $message;
}
示例9: jobpost_applicants_detail_page_content
/**
* Creates Detail Page for Applicants
*
*
* @access public
* @since 1.0.0
* @return void
*/
public function jobpost_applicants_detail_page_content()
{
global $post;
if (!empty($post) and 'jobpost_applicants' === $post->post_type) {
$keys = get_post_custom_keys($post->ID);
do_action('sjb_applicants_details_before');
?>
<div class="wrap"><div id="icon-tools" class="icon32"></div>
<h3>
<?php
if (in_array('jobapp_name', $keys)) {
echo get_post_meta($post->ID, 'jobapp_name', true);
}
if (in_array('resume', $keys)) {
?>
<small><a href="<?php
echo get_post_meta($post->ID, 'resume', true);
?>
" target="_blank" ><?php
echo __('Resume', 'simple-job-board');
?>
</a></small>
<?php
}
?>
</h3>
<table class="widefat striped">
<?php
do_action('sjb_applicants_details_start');
foreach ($keys as $key) {
if (substr($key, 0, 7) == 'jobapp_') {
echo '<tr><td>' . ucwords(str_replace('_', ' ', substr($key, 7))) . '</td><td>' . get_post_meta($post->ID, $key, true) . '</td></tr>';
}
}
do_action('sjb_applicants_details_end');
?>
</table>
</div>
<?php
do_action('sjb-applicants-details-after');
?>
<h2><?php
_e('Application Notes', 'simple-job-board');
?>
</h2>
<?php
do_action('sjb_applicantion_notes');
}
}
示例10: save_post
function save_post($post_ID, $post)
{
$post_metas = get_post_custom_keys($post->ID);
if (empty($post_metas)) {
return;
}
foreach ($post_metas as $post_meta_key) {
if (0 === strpos($post_meta_key, '_npr_api_')) {
delete_post_meta($post->ID, $post_meta_key);
}
}
}
示例11: tt_acf_fields_required
function tt_acf_fields_required($group_id)
{
$acf_field_keys = get_post_custom_keys($group_id);
$acf_field_label = array();
foreach ($acf_field_keys as $key => $value) {
if (stristr($value, 'field_')) {
$acf_field = get_field_object($value, $group_id);
$acf_field_label[] = $acf_field['required'];
}
}
return $acf_field_label;
}
示例12: get_saved_meta_option
function get_saved_meta_option()
{
global $post;
$keys = @get_post_custom_keys($post->ID);
if (is_array($keys)) {
foreach ($keys as $key) {
$metas[preg_replace('/_/', '', $key, 1)] = get_post_meta($post->ID, $key, true);
}
return $metas;
}
return false;
}
示例13: copy_meta_info
static function copy_meta_info($new_id, $old_id)
{
$post_meta_keys = get_post_custom_keys($old_id);
if (empty($post_meta_keys)) {
return;
}
foreach ($post_meta_keys as $meta_key) {
$meta_values = get_post_custom_values($meta_key, $old_id);
foreach ($meta_values as $meta_value) {
$meta_value = maybe_unserialize($meta_value);
update_post_meta($new_id, $meta_key, $meta_value);
}
}
}
示例14: cloneMeta
/**
* Copies post meta data
* @param int $oldId
* @param int $newId
* @return boolean
*/
protected function cloneMeta($oldId, $newId)
{
$metaKeys = get_post_custom_keys($oldId);
if (empty($metaKeys)) {
return false;
}
foreach ($metaKeys as $metaKey) {
$metaValues = get_post_custom_values($metaKey, $oldId);
foreach ($metaValues as $metaValue) {
$metaValue = maybe_unserialize($metaValue);
update_post_meta($newId, $metaKey, $metaValue);
}
}
return true;
}
示例15: tool_acf_get_post_custom_keys
function tool_acf_get_post_custom_keys($p = array())
{
$p += array('post_id' => false, 'filter' => '_');
$ret = false;
if ($p['post_id']) {
$ret = get_post_custom_keys($p['post_id']);
if (count($ret) > 0) {
foreach ($ret as $key => $item) {
if ($p['filter'] == '_' && $item[0] === '_') {
unset($ret[$key]);
}
}
}
}
return $ret;
}