本文整理汇总了PHP中get_post_field函数的典型用法代码示例。如果您正苦于以下问题:PHP get_post_field函数的具体用法?PHP get_post_field怎么用?PHP get_post_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_post_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: avfr_change_status
/**
*
* Change status of votes
*
*/
function avfr_change_status()
{
global $avfr_db;
$post_id = $_POST['post_id'];
$current_status = get_post_meta($post_id, '_avfr_status', true);
$new_status = $_POST['new_status'];
if ($new_status != $current_status && current_user_can('manage_options')) {
update_post_meta($post_id, '_avfr_status', $new_status);
echo 'success';
}
// for email
$post_author_id = get_post_field('post_author', $post_id);
$reciever_info = get_userdata($post_author_id);
$entry = get_post($post_id);
$search = array('{{writer-name}}', '{{avfr-title}}', '{{votes}}');
$replace = array($reciever_info->user_login, $entry->post_title, avfr_get_votes($post_id));
if ('on' == avfr_get_option('avfr_send_mail_' . $new_status . '_writer', 'avfr_settings_mail')) {
$reciever_email = get_the_author_meta('user_email', $post_author_id);
$content = avfr_get_option('avfr_mail_content_' . $new_status . '_writer', 'avfr_settings_mail');
$mail_content = str_replace($search, $replace, $content);
wp_mail($reciever_email, 'Feature Request ' . $entry->post_title . ' ' . $new_status . '.', $mail_content);
}
if ('on' == avfr_get_option('avfr_send_mail_' . $new_status . '_voters', 'avfr_settings_mail')) {
$reciever_emails = $avfr_db->avfr_get_voters_email($post_id);
$content = avfr_get_option('avfr_mail_content_' . $new_status . '_voters', 'avfr_settings_mail');
$mail_content = str_replace($search, $replace, $content);
wp_mail($reciever_emails, 'Request ' . $entry->post_title . ' ' . $new_status . '.', $mail_content);
}
exit;
// Ajax
}
示例2: column_default
function column_default($item, $column_name)
{
switch ($column_name) {
case 'rate':
$download = get_post_meta($item['ID'], '_download_id', true);
$type = eddc_get_commission_type($download);
if ('percentage' == $type) {
return $item[$column_name] . '%';
} else {
return edd_currency_filter(edd_sanitize_amount($item[$column_name]));
}
case 'status':
return $item[$column_name];
case 'amount':
return edd_currency_filter(edd_format_amount($item[$column_name]));
case 'date':
return date_i18n(get_option('date_format'), strtotime(get_post_field('post_date', $item['ID'])));
case 'download':
$download = !empty($item['download']) ? $item['download'] : false;
return $download ? '<a href="' . esc_url(add_query_arg('download', $download)) . '" title="' . __('View all commissions for this item', 'eddc') . '">' . get_the_title($download) . '</a>' . (!empty($item['variation']) ? ' - ' . $item['variation'] : '') : '';
case 'payment':
$payment = get_post_meta($item['ID'], '_edd_commission_payment_id', true);
return $payment ? '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '" title="' . __('View payment details', 'eddc') . '">#' . $payment . '</a> - ' . edd_get_payment_status(get_post($payment), true) : '';
default:
return print_r($item, true);
//Show the whole array for troubleshooting purposes
}
}
示例3: get_data
/**
* Get the data being exported
*
* @access public
* @since 1.2
* @return array
*/
public function get_data()
{
global $edd_logs;
$data = array();
$args = array('nopaging' => true, 'post_type' => 'edd_payment', 'meta_key' => '_edd_payment_shipping_status', 'meta_value' => '1', 'fields' => 'ids');
$payments = get_posts($args);
if ($payments) {
foreach ($payments as $payment) {
$user_info = edd_get_payment_meta_user_info($payment);
$downloads = edd_get_payment_meta_cart_details($payment);
$products = '';
if ($downloads) {
foreach ($downloads as $key => $download) {
// Display the Downoad Name
$products .= get_the_title($download['id']);
if ($key != count($downloads) - 1) {
$products .= ' / ';
}
}
}
$data[] = array('id' => $payment, 'date' => get_post_field('post_date', $payment), 'first_name' => $user_info['first_name'], 'last_name' => $user_info['last_name'], 'email' => $user_info['email'], 'address' => $user_info['shipping_info']['address'], 'address2' => !empty($user_info['shipping_info']['address2']) ? $user_info['shipping_info']['address2'] : '', 'city' => $user_info['shipping_info']['city'], 'state' => $user_info['shipping_info']['state'], 'zip' => $user_info['shipping_info']['zip'], 'country' => $user_info['shipping_info']['country'], 'amount' => edd_get_payment_amount($payment), 'tax' => edd_get_payment_tax($payment), 'gateway' => edd_get_payment_gateway($payment), 'key' => edd_get_payment_key($payment), 'products' => $products, 'status' => get_post_field('post_status', $payment));
}
}
$data = apply_filters('edd_export_get_data', $data);
$data = apply_filters('edd_export_get_data_' . $this->export_type, $data);
return $data;
}
示例4: wpdt_wpas_before_tickets_list
function wpdt_wpas_before_tickets_list()
{
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array('post_type' => 'ticket', 'post_status' => 'any', 'order' => 'DESC', 'orderby' => 'date', 'posts_per_page' => 20, 'paged' => $paged, 'no_found_rows' => false, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false);
if (isset($_REQUEST['searchString']) && $_REQUEST['searchString'] != '') {
$results = array();
$args['post_title_like'] = $_REQUEST['searchString'];
$args['order'] = 'ASC';
$args['orderby'] = 'title';
global $wpas_tickets;
$wpas_tickets = new WP_Query($args);
if ($wpas_tickets->have_posts()) {
while ($wpas_tickets->have_posts()) {
$wpas_tickets->the_post();
$url = site_url() . "/ticket/" . get_post_field('post_name', get_post());
$return_value = get_the_title();
$results[] = array('value' => $return_value, 'slug' => get_the_permalink(), 'url' => $url, 'tokens' => explode(' ', get_the_title()), 'css_class' => 'no_class');
}
} else {
$results['value'] = 'No results found.';
}
wp_reset_postdata();
echo json_encode($results);
exit;
}
global $wpas_tickets;
$wpas_tickets = new WP_Query($args);
}
示例5: displayPatreonCampaignBanner
public function displayPatreonCampaignBanner($patreon_level)
{
/* patreon banner when user patronage not high enough */
/* TODO: get marketing collateral */
//return '<img src="http://placehold.it/500x150?text=PATREON MARKETING COLLATERAL"/>';
//TAO get the patreon pitch page and display it
//TAO this is the patreon pitch page
$TAO_patreon_pitch_page_url = get_option('tao-patreon-pitch-page', '');
//if options comes back with something, then replace the $content
if ($TAO_patreon_pitch_page_url) {
//I have a full url from the options page, convert that into an DI
$TAO_patreon_pitch_page_id = url_to_postid($TAO_patreon_pitch_page_url);
//the id was found, get the content of that post now
if ($TAO_patreon_pitch_page_id) {
//Display a message for the viewer to usnderstand why they cannot see the content if the option is filled out
$TAO_patreon_pitch_reason = get_option('tao-patreon-pitch-reason', '');
if ($TAO_patreon_pitch_reason) {
//check to see if $patreon_level exists in string and replace it with $patreon_level var
$TAO_patreon_pitch_reason = str_replace('$patreon_level', '$' . $patreon_level, $TAO_patreon_pitch_reason);
//$content = '[message_box type="note" icon="yes"]' . $TAO_patreon_pitch_reason . '[/message_box][hr]';
$content = $TAO_patreon_pitch_reason;
}
//get the content from a post ID, which is the patreon pitch page
$content .= get_post_field('post_content', $TAO_patreon_pitch_page_id);
return $content;
}
}
}
示例6: displayContactBySubsidiary
function displayContactBySubsidiary()
{
$obj = get_post_type_object('contact_subsidiary');
echo "<h2>";
echo $obj->labels->singular_name;
echo "</h2>";
echo "<div style='width:400px; float:left;'>";
$loop2 = new WP_Query(array('post_type' => 'contact_subsidiary', 'posts_per_page' => -1));
while ($loop2->have_posts()) {
$loop2->the_post();
$postid = get_the_ID();
echo "Title: " . ($title_contact_subsidiary = get_the_title());
echo "</br>";
$meta_value_internal = get_post_meta($postid, 'subsidiaries_internal', true);
if ($meta_value_internal !== "") {
foreach ($meta_value_internal as $value_internal) {
//print_r($value_internal);
echo $title_internal = $value_internal['internal-subsidiary-title'];
echo $description_internal = $value_internal['internal-subsidiary-description'];
}
} else {
echo "Content: " . ($content_contact_subsidiary = get_post_field('post_content', $post->ID));
}
echo "<hr>";
echo "</br>";
}
echo "</div>";
}
示例7: charitable_is_current_campaign_creator
/**
* Returns whether the current user is the creator of the given campaign.
*
* @param int $campaign_id
* @return boolean
* @since 1.0.0
*/
function charitable_is_current_campaign_creator($campaign_id = null)
{
if (is_null($campaign_id)) {
$campaign_id = charitable_get_current_campaign_id();
}
return get_post_field('post_author', $campaign_id) == get_current_user_id();
}
示例8: helpers_calculate_read_time
/**
* Updates post_meta with number of words
* @author Eric Wennerberg
* @since 0.0.7
* @version 0.2.0
* @param str $post_id
* @return int $words;
*/
function helpers_calculate_read_time($post_id)
{
$content = apply_filters('the_content', get_post_field('post_content', $post_id, 'raw'));
$words = str_word_count($content);
update_post_meta($post_id, 'flavour_num_words', $words);
return $words;
}
示例9: dwqa_get_latest_action_date
function dwqa_get_latest_action_date($question = false, $before = '<span>', $after = '</span>')
{
if (!$question) {
$question = get_the_ID();
}
global $post;
$message = '';
$latest_answer = dwqa_get_latest_answer($question);
$last_activity_date = $latest_answer ? $latest_answer->post_date : get_post_field('post_date', $question);
$post_id = $latest_answer ? $latest_answer->ID : $question;
$author_id = $post->post_author;
if ($author_id == 0 || dwqa_is_anonymous($post_id)) {
$anonymous_name = get_post_meta($post_id, '_dwqa_anonymous_name', true);
if ($anonymous_name) {
$author_link = $anonymous_name . ' ';
} else {
$author_link = __('Anonymous', 'dwqa') . ' ';
}
} else {
$display_name = get_the_author_meta('display_name', $author_id);
$author_url = get_author_posts_url($author_id);
$author_avatar = wp_cache_get('avatar_of_' . $author_id, 'dwqa');
if (false === $author_avatar) {
$author_avatar = get_avatar($author_id, 12);
wp_cache_set('avatar_of_' . $author_id, $author_avatar, 'dwqa', 60 * 60 * 24 * 7);
}
$author_link = sprintf('<span class="dwqa-author">%3$s</span>', $author_url, esc_attr(sprintf(__('Posts by %s'), $display_name)), $display_name, $author_avatar);
}
if ($last_activity_date && $post->last_activity_type == 'answer') {
$date = dwqa_human_time_diff(strtotime($last_activity_date), false, get_option('date_format'));
return sprintf(__('%s respondida <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, $date);
}
return sprintf(__('%s perguntou <span class="dwqa-date">%s</span>', 'dwqa'), $author_link, get_the_date());
}
示例10: olr_custom_column_date
function olr_custom_column_date($column_name, $id)
{
$meta_key = 'olr_custom_column';
$column = get_post_meta($id, $meta_key, true);
if ($column_name == 'Phone') {
echo $column['Phone'];
}
if ($column_name == 'Email') {
echo $column['Email'];
}
if ($column_name == 'editor') {
echo nl2br(get_post_field('post_content', $id));
}
if ($column_name == 'Tables') {
$type_tables = '';
if ($column['Type_of_Tables'] != '') {
$type_tables = ' ( ' . $column['Type_of_Tables'] . ' )';
}
echo $column['Tables'] . $type_tables;
}
if ($column_name == 'Persons') {
echo $column['Persons'];
}
if ($column_name == 'Booking Date') {
echo $column['Booking_Date'] . ', ' . $column['Booking_Time'];
}
if ($column_name == 'Confirmation Key') {
echo $column['Confirmation_Key'];
}
if ($column_name == 'status') {
$status = get_post_status($id);
echo '<span class="' . $status . '">' . ucfirst($status) . '</span>';
}
}
示例11: get_flexslider
function get_flexslider()
{
//get attachments
$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'order' => 'ASC'));
//open slider
$slider .= '
<!-- Start Flexslider -->
<div class="flexslider">
<ul class="slides">
';
//get conditional slider
if ($attachments) {
foreach ($attachments as $attachment_id => $attachment) {
$theUrl = wp_get_attachment_url($attachment_id);
$theCaption = get_post_field('post_excerpt', $attachment->ID);
$slider .= '
<li data-thumb="' . $theUrl . '">
<img src="' . $theUrl . '" alt="slider1"/>
</li>
';
}
}
//end slider
$slider .= '
</ul>
</div>
<!-- End Flexslider -->
';
//return slider
return $slider;
}
示例12: save_inquiry
function save_inquiry($post_id)
{
if (!wp_is_post_revision($post_id)) {
$forms = get_field('forms', 'option');
$post_type = get_post_field('post_type', $post_id);
foreach ($forms as $form) {
if ($post_type == $form['post_type']) {
$title = $form['title'];
$title = str_replace('newpost', $post_id, $title);
$title = do_shortcode($title);
$slug = str_replace(' ', '-', strtolower($title));
$post = array("post_title" => $title, 'ID' => $post_id, 'post_name' => $slug);
wp_update_post($post);
$headers = array('Content-Type: text/html; charset=UTF-8');
$subject = $title . ' (' . $post_id . ')';
$email_html = site_url() . '?acf-cf-email=' . $post_id;
if (!empty($form['template'])) {
$email_html = $email_html . '&template=' . $form['template'];
}
$message = file_get_contents($email_html);
if ($form['no_email'] == false) {
$recipient = $form['email'];
$mail = wp_mail($recipient, $subject, $message, $headers);
}
}
}
return $post_id;
}
}
示例13: display_sales_logs
/**
* Displaying Prodcuts
*
* Does prepare the data for displaying the products in the table.
*
* @package Social Deals Engine
* @since 1.0.0
*/
function display_sales_logs()
{
$prefix = WPS_DEALS_META_PREFIX;
$logs_data = array();
$paged = $this->get_paged();
$sale = empty($_GET['s']) ? $this->get_sorted_sales_log() : null;
$log_query = array('post_parent' => $sale, 'log_type' => 'sales', 'meta_query' => $this->get_meta_query());
$logsdata = $this->logs->get_connected_logs($log_query);
if ($logsdata) {
foreach ($logsdata as $log) {
$order_id = get_post_meta($log->ID, $prefix . 'log_payment_id', true);
// Make sure this payment hasn't been deleted
if (get_post($order_id)) {
$user_info = $this->model->wps_deals_get_ordered_user_details($order_id);
$cart_items = $this->model->wps_deals_get_post_meta_ordered($order_id);
$cart_items = $cart_items['deals_details'];
$date = $this->model->wps_deals_get_date_format(strtotime(get_post_field('post_date', $order_id)), true);
$amount = 0;
if (is_array($cart_items) && is_array($user_info)) {
foreach ($cart_items as $item) {
$price_override = isset($item['deal_sale_price']) ? $item['deal_sale_price'] : null;
if (isset($item['deal_id']) && $item['deal_id'] == $log->post_parent) {
$amount = $item['deal_sale_price'];
$qty = $item['deal_quantity'];
}
}
$amount = $this->currency->wps_deals_formatted_value($amount);
$logs_data[] = array('ID' => $log->ID, 'order_id' => $order_id, 'deals' => $log->post_parent, 'amount' => $amount, 'quantity' => $qty, 'user_id' => $user_info['user_id'], 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], 'date' => $date);
}
}
}
}
return $logs_data;
}
示例14: add_media_to_collection
function add_media_to_collection($mediaId, $collectionId, $isRemove = false)
{
$id = get_post_meta($collectionId, 'lrid_to_id', true);
$content = get_post_field('post_content', $id);
preg_match_all('/\\[gallery.*ids="([0-9,]*)"\\]/', $content, $results);
if (!empty($results) && !empty($results[1])) {
$str = $results[1][0];
$ids = !empty($str) ? explode(',', $str) : array();
$index = array_search($mediaId, $ids, false);
if ($isRemove) {
if ($index !== FALSE) {
unset($ids[$index]);
}
} else {
// If mediaId already there then exit.
if ($index !== FALSE) {
return;
}
array_push($ids, $mediaId);
}
// Replace the array within the gallery shortcode.
$content = str_replace('ids="' . $str, 'ids="' . implode(',', $ids), $content);
$post = array('ID' => $id, 'post_content' => $content);
wp_update_post($post);
}
}
示例15: shortcode
public function shortcode($atts, $content = null)
{
$this->content = $this->sanitize_content($content);
$this->atts = $this->sanitize_attributes($atts);
// override shortcode atts for uploaded image
if ($this->is_uploaded_image()) {
$image_id = $this->atts['image_id'];
$image_src = wp_get_attachment_image_src($image_id, 'full');
if (!$image_src) {
return '';
}
if (get_post_meta($image_id, 'dt-img-hide-title', true)) {
$this->atts['image_title'] = '';
} else {
$this->atts['image_title'] = get_the_title($image_id);
}
$this->atts['image'] = $image_src[0];
$this->atts['hd_image'] = '';
$this->atts['image_alt'] = esc_attr(get_post_meta($image_id, '_wp_attachment_image_alt', true));
$this->atts['media'] = esc_url(get_post_meta($image_id, 'dt-video-url', true));
$post_content = get_post_field('post_content', $image_id);
$this->content = $this->sanitize_content($post_content);
}
$output = '';
$output .= '<div ' . $this->get_container_html_class('shortcode-single-image-wrap') . $this->get_container_inline_style() . '>';
$output .= $this->get_media();
$output .= $this->get_caption();
$output .= '</div>';
return $output;
}