/** * 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; } }
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; }
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; }
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; } }
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; }
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; }
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); } }
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; }
/** * 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'); } }
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); } } }
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; }
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; }
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); } } }
/** * 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; }
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; }
function ddleetspeak_filter_the_content($content) { global $DDLeetSpeak, $post; // Check if the there is a meta keyword for this page/post. if (in_array('leet', get_post_custom_keys($post->ID))) { $content = $DDLeetSpeak->leetize($content); } else { // Find all tagged text -- [leet][/leet] preg_match_all('!\\[leet\\].*?\\[/leet\\]!', $content, $matches); $matches = $matches[0]; foreach ($matches as $string) { $content = str_replace($string, htmlspecialchars($DDLeetSpeak->leetize(str_replace(array('[leet]', '[/leet]'), '', $string)), ENT_COMPAT, 'UTF-8'), $content); } } return $content; }
/** * push the contents and fields for a post to the NPR API * * Limited to users that can publish posts * * @param unknown_type $post_ID * @param unknown_type $post */ function nprstory_api_push($post_ID, $post) { if (!current_user_can('publish_posts')) { wp_die(__('You do not have permission to publish posts, and therefore you do not have permission to push posts to the NPR API.'), __('NPR Story API Error'), 403); } $push_post_type = get_option('ds_npr_push_post_type'); if (empty($push_post_type)) { $push_post_type = 'post'; } //if the push url isn't set, don't even try to push. $push_url = get_option('ds_npr_api_push_url'); if (!empty($push_url)) { // For now, only submit regular posts, and only on publish. if ($post->post_type != $push_post_type || $post->post_status != 'publish') { return; } //we may be able to have a custom body, so we need to check for that. $content = $post->post_content; $use_custom = get_option('dp_npr_push_use_custom_map'); $body_field = 'Body'; if ($use_custom) { //get the list of metas available for this post $post_metas = get_post_custom_keys($post->ID); $custom_content_meta = get_option('ds_npr_api_mapping_body'); $body_field = $custom_content_meta; if (!empty($custom_content_meta) && $custom_content_meta != '#NONE#' && in_array($custom_content_meta, $post_metas)) { $content = get_post_meta($post->ID, $custom_content_meta, true); } } // Abort pushing to NPR if the post has no content if (empty($content)) { update_post_meta($post_ID, NPR_PUSH_STORY_ERROR, $body_field . ' is required for a post to be pushed to the NPR API.'); return; } else { delete_post_meta($post_ID, NPR_PUSH_STORY_ERROR, $body_field . ' is required for a post to be pushed to the NPR API.'); } $api = new NPRAPIWordpress(); // Don't push stories to the NPR story API if they were originally pulled from the NPR Story API $retrieved = get_post_meta($post_ID, NPR_RETRIEVED_STORY_META_KEY, true); if (empty($retrieved) || $retrieved == 0) { $api->send_request($api->create_NPRML($post), $post_ID); } else { nprstory_error_log('Not pushing the story with post_ID ' . $post_ID . ' to the NPR Story API because it came from the API'); } } }
function wcff_post_listing($column, $post_id) { global $post; switch ($column) { case 'fields': $count = 0; $keys = get_post_custom_keys($post_id); if ($keys) { foreach ($keys as $key) { if ((strpos($key, 'wccpf_') !== false || strpos($key, 'wccaf_') !== false) && (strpos($key, 'group_rules') === false && strpos($key, 'condition_rules') === false && strpos($key, 'location_rules') === false)) { $count++; } } } echo $count; break; } }
/** * Modifies the output of the post content. * * This method is called in the single page of this class post type. * * Alternatively, you may use the 'content_{instantiated class name}' method, */ public function content($sContent) { // 1. To retrieve the meta box data - get_post_meta( $post->ID ) will return an array of all the meta field values. // or if you know the field id of the value you want, you can do $value = get_post_meta( $post->ID, $field_id, true ); $_iPostID = $GLOBALS['post']->ID; $_aPostData = array(); foreach ((array) get_post_custom_keys($_iPostID) as $sKey) { // This way, array will be unserialized; easier to view. $_aPostData[$sKey] = get_post_meta($_iPostID, $sKey, true); } // Or you may do this but the nested elements will be a serialized array. // $_aPostData = get_post_custom( $_iPostID ) ; // 2. To retrieve the saved options in the setting pages created by the framework - use the get_option() function. // The key name is the class name by default. The key can be changed by passing an arbitrary string // to the first parameter of the constructor of the AdminPageFramework class. $_aSavedOptions = get_option('APF_Demo'); return "<h3>" . __('Saved Meta Field Values', 'admin-page-framework-demo') . "</h3>" . $this->oDebug->getArray($_aPostData) . "<h3>" . __('Saved Setting Options', 'admin-page-framework-demo') . "</h3>" . $this->oDebug->getArray($_aSavedOptions); }
private function _fillOptionsArrayFromPostMeta(array &$aOptions, $iPostID, array $aFields) { $_aMetaKeys = $this->oUtil->getAsArray(get_post_custom_keys($iPostID)); foreach ($aFields as $_sSectionID => $_aFields) { if ('_default' == $_sSectionID) { foreach ($_aFields as $_aField) { if (!in_array($_aField['field_id'], $_aMetaKeys)) { continue; } $aOptions[$_aField['field_id']] = get_post_meta($iPostID, $_aField['field_id'], true); } } if (!in_array($_sSectionID, $_aMetaKeys)) { continue; } $aOptions[$_sSectionID] = get_post_meta($iPostID, $_sSectionID, true); } }
/** * グラフページを表示 */ public function index() { $post_type = $this->formkey; // form_posts $default_args = array('posts_per_page' => -1); $_args = apply_filters('mwform_get_inquiry_data_args-' . $post_type, $default_args); $args = array('post_type' => $post_type); if (!empty($_args) && is_array($_args)) { $args = array_merge($_args, $args); } else { $args = array_merge($_args, $default_args); } $form_posts = get_posts($args); // custom_keys $custom_keys = array(); foreach ($form_posts as $post) { $post_custom_keys = get_post_custom_keys($post->ID); if (is_array($post_custom_keys)) { foreach ($post_custom_keys as $post_custom_key) { if (preg_match('/^_/', $post_custom_key)) { continue; } $post_meta = get_post_meta($post->ID, $post_custom_key, true); $custom_keys[$post_custom_key][$post_meta][] = $post->ID; } } } // postdata $postdata = array(); $option = get_option(MWF_Config::NAME . '-chart-' . $post_type); if (is_array($option) && isset($option['chart']) && is_array($option['chart'])) { $postdata = $option['chart']; } $default_keys = array('target' => '', 'separator' => '', 'chart' => ''); // 空の隠れフィールド(コピー元)を挿入 array_unshift($postdata, $default_keys); $this->assign('post_type', $post_type); $this->assign('option_group', $this->option_group); $this->assign('form_posts', $form_posts); $this->assign('custom_keys', $custom_keys); $this->assign('postdata', $postdata); $this->render('chart/index'); }
public function save($post_id) { // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times $nonce = $this->get_nonce_field(); if (!isset($_POST[$nonce]) || !wp_verify_nonce($_POST[$nonce], $this->cpt)) { return; } // OK, we're authenticated: we need to find and save the data foreach ($_POST as $key => $value) { if (strpos($key, $this->field) !== false && $key != $this->get_nonce_field()) { //Get the field type $field_name = str_replace($this->field . '_', '', $key); $field_type = ''; foreach ($this->args['fields'] as $field) { if ($field_name == $field['name']) { $field_type = $field['type']; } } //apply filters based on field type if ($field_type == 'date') { $value = strtotime($value); } update_post_meta($post_id, $key, $value); } } // now we need to delete any values that aren't in the POST $keys = get_post_custom_keys($post_id); if (!count($keys)) { return; } foreach ($keys as $key) { if (strpos($key, $this->field) !== false && !isset($_POST[$key])) { delete_post_meta($post_id, $key); } } }
private function _getSavedDataFromFieldsets($iPostID, $aFieldsets) { $_aMetaKeys = $this->getAsArray(get_post_custom_keys($iPostID)); $_aMetaData = array(); foreach ($aFieldsets as $_sSectionID => $_aFieldsets) { if ('_default' == $_sSectionID) { foreach ($_aFieldsets as $_aFieldset) { if (!in_array($_aFieldset['field_id'], $_aMetaKeys)) { continue; } $_aMetaData[$_aFieldset['field_id']] = get_post_meta($iPostID, $_aFieldset['field_id'], true); } } if (!in_array($_sSectionID, $_aMetaKeys)) { continue; } $_aMetaData[$_sSectionID] = get_post_meta($iPostID, $_sSectionID, true); } return $_aMetaData; }
/** * * push the contents and fields for a post to the NPR API * @param unknown_type $post_ID * @param unknown_type $post */ function npr_push($post_ID, $post) { $push_post_type = get_option('ds_npr_push_post_type'); if (empty($push_post_type)) { $push_post_type = 'post'; } //if the push url isn't set, don't even try to push. $push_url = get_option('ds_npr_api_push_url'); if (!empty($push_url)) { // For now, only submit regular posts, and only on publish. if ($post->post_type != $push_post_type || $post->post_status != 'publish') { return; } //we may be able to have a custom body, so we need to check for that. $content = $post->post_content; $use_custom = get_option('dp_npr_push_use_custom_map'); $body_field = 'Body'; if ($use_custom) { //get the list of metas available for this post $post_metas = get_post_custom_keys($post->ID); $custom_content_meta = get_option('ds_npr_api_mapping_body'); $body_field = $custom_content_meta; if (!empty($custom_content_meta) && $custom_content_meta != '#NONE#' && in_array($custom_content_meta, $post_metas)) { $content = get_post_meta($post->ID, $custom_content_meta, true); } } if (empty($content)) { update_post_meta($post_ID, NPR_PUSH_STORY_ERROR, $body_field . ' is required for a post to be pushed to the NPR API.'); return; } else { delete_post_meta($post_ID, NPR_PUSH_STORY_ERROR, $body_field . ' is required for a post to be pushed to the NPR API.'); } $api = new NPRAPIWordpress(); $retrieved = get_post_meta($post_ID, NPR_RETRIEVED_STORY_META_KEY, true); if (empty($retrieved) || $retrieved == 0) { $api->send_request($api->create_NPRML($post), $post_ID); } else { //error_log('Not pushing the story because it came from the API'); } } }
protected function setUnitOptionsForEdit($arrUnitOptions) { // If the user comes from the eidt page, the post query key is set. if (!isset($_GET['post'])) { return $arrUnitOptions; } $arrPostData = array(); // Stored Data // $arrMeta = get_post_meta( $_GET['post'], '', true ); // this creates 0 indexes and unserialized values if ($_GET['post']) { // there is a case that the post id is 0 or not set like ...&post&post_type= foreach (get_post_custom_keys($_GET['post']) as $strKey) { $arrPostData[$strKey] = get_post_meta($_GET['post'], $strKey, true); } // this way, array will be unserialized } $arrPostData['mode'] = 0; $arrPostData['bounce_url'] = add_query_arg(array('post_type' => AmazonAutoLinks_Commons::PostTypeSlug, 'post' => $_GET['post'], 'action' => 'edit'), admin_url('post.php')); // AmazonAutoLinks_Debug::logArray( $arrPostData, dirname( __FILE__ ) . '/meta.txt' ); return $arrUnitOptions + $arrPostData + AmazonAutoLinks_Unit_Category::$arrStructure_Args; }
public static function get_all_custom_field_names() { $custom_fields = array(); // Loop through all Records, adding custom fields to array $args = array('post_type' => 'prsp-record', 'posts_per_page' => -1); $loop = new WP_Query($args); if ($loop->have_posts()) { foreach ($loop->posts as $rec) { $record_id = $rec->ID; $rec_fields = get_post_custom_keys($record_id); foreach ($rec_fields as $key => $value) { $trimmed = trim($value); // exclude WP internal fields if ($trimmed[0] == '_') { continue; } ProspectAttribute::sorted_insert($trimmed, $custom_fields); } } } return $custom_fields; }
function jobpost_applicants_detail_page_content() { global $post; if (!empty($post) and $post->post_type == 'jobpost_applicants') { $keys = get_post_custom_keys($post->ID); ?> <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" >Resume</a></small> <?php } ?> </h3> <table class="widefat striped"> <?php foreach ($keys as $key) { if (substr($key, 0, 7) == 'jobapp_') { echo '<tr><td>' . str_replace('_', ' ', substr($key, 7)) . '</td><td>' . get_post_meta($post->ID, $key, true) . '</td></tr>'; } } ?> </table> </div> <h2>Application Notes</h2> <?php } }
/** * Copy the meta information of a post to another post */ function duplicate_post_copy_post_meta_info($new_id, $post) { global $ai1ec_events_controller; $ai1ec_events_controller->save_post($new_id, $post); $post_meta_keys = get_post_custom_keys($post->ID); if (empty($post_meta_keys)) { return; } //$meta_blacklist = explode(",",get_option('duplicate_post_blacklist')); //if ( $meta_blacklist == "" ) $meta_blacklist = array(); $meta_keys = array_diff($post_meta_keys, $meta_blacklist); foreach ($meta_keys as $meta_key) { $meta_values = get_post_custom_values($meta_key, $post->ID); foreach ($meta_values as $meta_value) { $meta_value = maybe_unserialize($meta_value); add_post_meta($new_id, $meta_key, $meta_value); } } }
/** * Display list of post custom fields. * * @since 1.2.0 * * @internal This will probably change at some point... * */ function the_meta() { if ($keys = get_post_custom_keys()) { echo "<ul class='post-meta'>\n"; foreach ((array) $keys as $key) { $keyt = trim($key); if (is_protected_meta($keyt, 'post')) { continue; } $values = array_map('trim', get_post_custom_values($key)); $value = implode($values, ', '); /** * Filters the HTML output of the li element in the post custom fields list. * * @since 2.2.0 * * @param string $html The HTML output for the li element. * @param string $key Meta key. * @param string $value Meta value. */ echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>{$key}:</span> {$value}</li>\n", $key, $value); } echo "</ul>\n"; } }
function acf_columns_display($column, $post_id) { // vars switch ($column) { case "fields": // vars $count = 0; $keys = get_post_custom_keys($post_id); if ($keys) { foreach ($keys as $key) { if (strpos($key, 'field_') !== false) { $count++; } } } echo $count; break; } }