本文整理汇总了PHP中wp_get_post_parent_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_get_post_parent_id函数的具体用法?PHP wp_get_post_parent_id怎么用?PHP wp_get_post_parent_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_get_post_parent_id函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: dbdb_body_classes
/**
* Custom class for the WP 'body_class()' function
* updated: 4/15/10
*/
function dbdb_body_classes($classes)
{
// source http://darrinb.com/notes/2010/customizing-the-wordpress-body_class-function/
global $post;
global $wp_query;
// if there is no parent ID and it's not a single post page, category page, or 404 page, give it
// a class of "parent-page"
if ($post->post_parent < 1 && !is_single() && !is_archive() && !is_404()) {
$classes[] = 'parent-page';
}
// if the page/post has a parent, it's a child, give it a class of its parent name
if ($post->post_parent > 0) {
/* $parent_title = get_the_title($wp_query->post->post_parent);
$parent_title = preg_replace('#\s#','-', $parent_title);
$parent_title = strtolower($parent_title);
$classes[] = 'parent-pagename-'.$parent_title; */
$parent_id = wp_get_post_parent_id($wp_query->post);
// $parent_id = get_the_ID($wp_query->post->post_parent);
echo "PARENT ID : " . $parent_id;
// $parent_id = preg_replace('#\s#','-', $parent_id);
$parent_id = strtolower($parent_id);
$classes[] = 'parent-id-' . $parent_id;
}
// add a class = to the name of post or page
$classes[] = $wp_query->queried_object->post_name;
return array_unique($classes);
}
开发者ID:aldelpech,项目名称:clea-atouts-c,代码行数:31,代码来源:functions.php
示例2: woocommerce_get_product_thumbnail
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0)
{
global $product;
if ($product->is_type('variable')) {
global $prdctfltr_global;
$pf_activated = isset($prdctfltr_global['active_filters']) ? $prdctfltr_global['active_filters'] : array();
if (!empty($pf_activated)) {
$attrs = array();
foreach ($pf_activated as $k => $v) {
if (substr($k, 0, 3) == 'pa_') {
$attrs = $attrs + array($k => $v[0]);
}
}
if (count($attrs) > 0) {
$curr_var = $product->get_available_variations();
foreach ($curr_var as $key => $var) {
$curr_var_set[$key]['attributes'] = $var['attributes'];
$curr_var_set[$key]['variation_id'] = $var['variation_id'];
}
$found = WC_Prdctfltr::prdctrfltr_search_array($curr_var_set, $attrs);
}
}
}
if (isset($found[0]) && $found[0]['variation_id'] && has_post_thumbnail($found[0]['variation_id'])) {
$image = get_the_post_thumbnail($found[0]['variation_id'], $size);
} elseif (has_post_thumbnail($product->id)) {
$image = get_the_post_thumbnail($product->id, $size);
} elseif (($parent_id = wp_get_post_parent_id($product->id)) && has_post_thumbnail($parent_id)) {
$image = get_the_post_thumbnail($product, $size);
} else {
$image = wc_placeholder_img($size);
}
return $image;
}
开发者ID:arobbins,项目名称:spellestate,代码行数:34,代码来源:pf-variable-override.php
示例3: applegate_get_top_bucket_parent
function applegate_get_top_bucket_parent($ID)
{
if ($parent = wp_get_post_parent_id($ID)) {
$ID = applegate_get_top_bucket_parent($parent);
}
return $ID;
}
开发者ID:realbig,项目名称:TH_APPLEGATE,代码行数:7,代码来源:bucket-menu.php
示例4: getpp_replace_hierarchicals
function getpp_replace_hierarchicals($value)
{
$value = str_replace('this', get_the_ID(), $value);
$value = str_replace('parent', wp_get_post_parent_id(get_the_ID()), $value);
$value = str_replace('top', end(get_post_ancestors(get_the_ID())), $value);
return $value;
}
开发者ID:bristweb,项目名称:codexcodes,代码行数:7,代码来源:index.php
示例5: get_product_addons
/**
* Gets addons assigned to a product by ID
*
* @param int $post_id ID of the product to get addons for
* @param string $prefix for addon field names. Defaults to postid-
* @param bool $inc_parent Set to false to not include parent product addons.
* @param bool $inc_global Set to false to not include global addons.
* @return array array of addons
*/
function get_product_addons($post_id, $prefix = false, $inc_parent = true, $inc_global = true)
{
if (!$post_id) {
return array();
}
$addons = array();
$raw_addons = array();
$product_terms = apply_filters('get_product_addons_product_terms', wp_get_post_terms($post_id, 'product_cat', array('fields' => 'ids')), $post_id);
$exclude = get_post_meta($post_id, '_product_addons_exclude_global', true);
// Product Parent Level Addons
if ($inc_parent && ($parent_id = wp_get_post_parent_id($post_id))) {
$raw_addons[10]['parent'] = apply_filters('get_parent_product_addons_fields', get_product_addons($parent_id, $parent_id . '-', false, false), $post_id, $parent_id);
}
// Product Level Addons
$raw_addons[10]['product'] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($post_id, '_product_addons', true)), $post_id);
// Global level addons (all products)
if ('1' !== $exclude && $inc_global) {
$args = array('posts_per_page' => -1, 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_key' => '_priority', 'post_type' => 'global_product_addon', 'post_status' => 'publish', 'suppress_filters' => true, 'meta_query' => array(array('key' => '_all_products', 'value' => '1')));
$global_addons = get_posts($args);
if ($global_addons) {
foreach ($global_addons as $global_addon) {
$priority = get_post_meta($global_addon->ID, '_priority', true);
$raw_addons[$priority][$global_addon->ID] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($global_addon->ID, '_product_addons', true)), $global_addon->ID);
}
}
// Global level addons (categories)
if ($product_terms) {
$args = apply_filters('get_product_addons_global_query_args', array('posts_per_page' => -1, 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_key' => '_priority', 'post_type' => 'global_product_addon', 'post_status' => 'publish', 'suppress_filters' => true, 'tax_query' => array(array('taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $product_terms, 'include_children' => false))), $product_terms);
$global_addons = get_posts($args);
if ($global_addons) {
foreach ($global_addons as $global_addon) {
$priority = get_post_meta($global_addon->ID, '_priority', true);
$raw_addons[$priority][$global_addon->ID] = apply_filters('get_product_addons_fields', array_filter((array) get_post_meta($global_addon->ID, '_product_addons', true)), $global_addon->ID);
}
}
}
}
ksort($raw_addons);
foreach ($raw_addons as $addon_group) {
if ($addon_group) {
foreach ($addon_group as $addon) {
$addons = array_merge($addons, $addon);
}
}
}
// Generate field names with unqiue prefixes
if (!$prefix) {
$prefix = apply_filters('product_addons_field_prefix', "{$post_id}-", $post_id);
}
foreach ($addons as $addon_key => $addon) {
if (empty($addon['name'])) {
unset($addons[$addon_key]);
continue;
}
if (empty($addons[$addon_key]['field-name'])) {
$addons[$addon_key]['field-name'] = sanitize_title($prefix . $addon['name']);
}
}
return apply_filters('get_product_addons', $addons);
}
开发者ID:pcuervo,项目名称:ur-imprint,代码行数:69,代码来源:woocommerce-product-addons.php
示例6: display_price_in_variation_option_name
function display_price_in_variation_option_name($term)
{
global $wpdb, $product;
$term_temp = $term;
$term = strtolower($term);
$term = str_replace(' ', '-', $term);
$result = $wpdb->get_col("SELECT slug FROM {$wpdb->prefix}terms WHERE name = '{$term}'");
$term_slug = !empty($result) ? $result[0] : $term;
$query = "SELECT postmeta.post_id AS product_id\nFROM {$wpdb->prefix}postmeta AS postmeta\nLEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )\nWHERE postmeta.meta_key LIKE 'attribute_%'\nAND postmeta.meta_value = '{$term_slug}'\nAND products.post_parent = {$product->id}";
$variation_id = $wpdb->get_col($query);
$parent = wp_get_post_parent_id($variation_id[0]);
if ($parent > 0) {
$_product = new WC_Product_Variation($variation_id[0]);
$testVariable = $_product->get_variation_attributes();
$itemPrice = strip_tags(woocommerce_price($_product->get_price()));
$getPrice = $_product->get_price();
$itemPriceInt = (int) $getPrice;
$term = $term_temp;
//this is where you can actually customize how the price is displayed
if ($itemPriceInt > 0) {
return $term . ' (' . $itemPrice . ' incl. GST)';
} else {
return $term . ' (' . $itemPrice . ')';
}
}
return $term;
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:27,代码来源:woo-functions.php
示例7: shortcode_handler
public function shortcode_handler($atts, $content = null, $tag = '')
{
$id = get_the_ID();
$args = ['order' => 'ASC', 'orderby' => 'menu_order', 'post__not_in' => [$id], 'post_parent' => wp_get_post_parent_id($id), 'post_type' => get_post_type(), 'posts_per_page' => 20];
$query = new WP_Query($args);
$r = [];
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$classes = ['hestia-sibling', 'hestia-wrap', sprintf('post-%s', esc_attr(get_the_ID()))];
$has_thumbnail = has_post_thumbnail();
$permalink = get_permalink();
if ($has_thumbnail) {
// Because who doesn't love a properly alphabetized list?
array_unshift($classes, 'has-post-thumbnail');
}
$r[] = sprintf('<div class="%s">', implode(' ', $classes));
$r[] = sprintf('<a href="%s">', esc_attr($permalink));
if ($has_thumbnail) {
$r[] = get_the_post_thumbnail();
}
$r[] = get_the_title();
$r[] = '</a>';
$r[] = '</div>';
}
}
wp_reset_postdata();
return implode("\n", $r);
}
开发者ID:ssnepenthe,项目名称:hestia,代码行数:29,代码来源:Siblings.php
示例8: getParentId
/**
* Displays a list of pages which are either:
* The children of the current page, or
* The children of the parent page with a back to parent link
*/
function getParentId($pageId, $idsArray)
{
$parentId = wp_get_post_parent_id($pageId);
if ($parentId !== 0) {
array_unshift($idsArray, $parentId);
return getParentId($parentId, $idsArray);
}
return $idsArray;
}
开发者ID:mummybot,项目名称:tpbc,代码行数:14,代码来源:navigationSecondary.php
示例9: 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;
}
开发者ID:anurag-singh,项目名称:as-simple-job-board,代码行数:56,代码来源:simple-job-board-notification.php
示例10: storeCanastaAlCorteCliente
function storeCanastaAlCorteCliente($cliente, $variacion, $adicionales)
{
$actualizacionID = getActualizacionCanasta($cliente->club_id);
$producto = wp_get_post_parent_id($cliente->producto_id);
$canasta = getIdCanastaClube($cliente->club_id, $producto);
$actualizacionId = getIdActualizacionCanasta($cliente->club_id, $producto, $actualizacionID);
$arr = ['cliente_id' => $cliente->cliente_id, 'saldo_anterior' => $cliente->saldo, 'costo_canasta' => $variacion->costoSemanal, 'variation_id' => $cliente->producto_id, 'club_id' => $cliente->club_id, 'adicionales' => serialize($adicionales), 'fecha_corte' => date('Y-m-d'), 'actualizacion_id' => $actualizacionId, 'canasta_id' => $canasta];
saveCanastaAlCorteCliente($arr);
destroyAdicionalesCliente($cliente->cliente_id, $adicionales);
}
开发者ID:pcuervo,项目名称:wp-yolcan,代码行数:10,代码来源:functions-update-canastas.php
示例11: wcj_get_product_image_url
/**
* wcj_get_product_image_url.
*
* @version 2.5.7
* @since 2.5.7
* @todo placeholder
*/
function wcj_get_product_image_url($product_id, $image_size = 'shop_thumbnail')
{
if (has_post_thumbnail($product_id)) {
$image_url = get_the_post_thumbnail_url($product_id, $image_size);
} elseif (($parent_id = wp_get_post_parent_id($product_id)) && has_post_thumbnail($parent_id)) {
$image_url = get_the_post_thumbnail_url($parent_id, $image_size);
} else {
$image_url = '';
}
return $image_url;
}
开发者ID:algoritmika,项目名称:woocommerce-jetpack,代码行数:18,代码来源:wcj-functions.php
示例12: set_default_language
public function set_default_language($post_id)
{
if (!$this->model->post->get_language($post_id)) {
if (isset($_GET['new_lang']) && ($lang = $this->model->get_language($_GET['new_lang']))) {
$this->model->post->set_language($post_id, $lang);
} elseif (($parent_id = wp_get_post_parent_id($post_id)) && ($parent_lang = $this->model->post->get_language($parent_id))) {
$this->model->post->set_language($post_id, $parent_lang);
} else {
$this->model->post->set_language($post_id, $this->pref_lang);
}
}
}
开发者ID:iq007,项目名称:MadScape,代码行数:12,代码来源:admin-filters-post-base.php
示例13: meta
/**
* Get meta value
*
* @param int $post_id
* @param bool $saved
* @param array $field
*
* @return mixed
*/
static function meta($post_id, $saved, $field)
{
$parent_id = wp_get_post_parent_id($post_id);
if ($parent_id) {
$post_id = $parent_id;
}
$options = $field['options'];
$meta = wp_get_post_terms($post_id, $options['taxonomy']);
$meta = is_array($meta) ? $meta : (array) $meta;
$meta = wp_list_pluck($meta, 'term_id');
return $meta;
}
开发者ID:Juni4567,项目名称:mycashflow,代码行数:21,代码来源:class-wpp-taxonomy-inherited.php
示例14: getAncestors
function getAncestors($post_id)
{
$a = array();
while (true) {
$parent = (int) wp_get_post_parent_id($post_id);
if ($parent < 1) {
break;
}
$post_id = $parent;
$a[] = array('type' => 'post', 'id' => $post_id);
}
return $a;
}
开发者ID:stevanbarry,项目名称:govsite,代码行数:13,代码来源:breadcrumbs.php
示例15: gpbbp_new_post
function gpbbp_new_post($post_id, $post, $update)
{
$TOPIC_POST_TYPE = bbp_get_topic_post_type();
$REPLY_POST_TYPE = bbp_get_reply_post_type();
$post_type = get_post_type($post);
$forum_id = NULL;
if ($post_type == $TOPIC_POST_TYPE) {
$forum_id = wp_get_post_parent_id($post_id);
gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
}
if ($post_type == $REPLY_POST_TYPE) {
$forum_id = bbp_get_forum_id();
gpbbp_apply_capabilities_from_forum($post_id, $forum_id);
}
gpbbp_new_post_notification($post_id, $post, $post_type);
}
开发者ID:petercorlettwiley,项目名称:bbPress-Groups-Sync-Plugin,代码行数:16,代码来源:gp-bbpress-groups.php
示例16: __construct
/**
* Extends the parent constructor to overwrite with variable data
*
* @param int ID of the product to load
* @return object
*/
public function __construct($ID)
{
// Setup the product
$parent_id = wp_get_post_parent_id($ID);
parent::__construct($parent_id);
// Get the meta & for each meta item overwrite with the variations ID
$meta = get_post_custom($ID);
$variable_stock = 0;
foreach ($meta as $key => $array) {
if ($array[0]) {
$this->meta[$key] = $array;
}
if ($key == 'sku') {
if (empty($array[0])) {
$tempsku = $ID;
}
}
if ($key == 'stock') {
// if no value then parent stock value is used for variation stock tracking
// otherwise the variation stock even if '0' as that is a value, is used
if ($array[0] == '') {
$variable_stock = '-9999999';
} else {
$variable_stock = $array[0];
}
}
}
// Merge with the variation data
$this->variation_id = $ID;
if (isset($this->meta['variation_data'][0])) {
$this->variation_data = maybe_unserialize($this->meta['variation_data'][0]);
}
$sale_from = $this->sale_price_dates_from;
$sale_to = $this->sale_price_dates_to;
parent::__construct($ID);
// Restore the parent ID
$this->ID = $parent_id;
$this->id = $parent_id;
if (!empty($tempsku)) {
$this->sku = $tempsku;
}
$this->sale_price_dates_from = $sale_from;
$this->sale_price_dates_to = $sale_to;
// signal parent stock tracking or variation stock tracking
$this->stock = $variable_stock == '-9999999' ? $variable_stock : $this->stock;
return $this;
}
开发者ID:ashik968,项目名称:digiplot,代码行数:53,代码来源:jigoshop_product_variation.class.php
示例17: widget
/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
// outputs the content of the widget
$sortby = empty($instance['sortby']) ? 'menu_order' : $instance['sortby'];
$exclude = empty($instance['exclude']) ? '' : $instance['exclude'];
$showall = empty($instance['showall']) ? 'off' : $instance['showall'];
$siblings = empty($instance['siblings']) ? 'off' : $instance['siblings'];
$parent_id = empty($instance['parent']) ? -1 : $instance['parent'];
$depth = empty($instance['depth']) ? 0 : $instance['depth'];
if ($showall == 'off' && $siblings == 'off' && $parent_id == -1 && !is_page()) {
return;
}
// If we are not viewing a page AND a parent page has not been specified AND we are not viewing ALL pages, don't show widget at all ...
$exclude_tree = '';
if ($siblings != 'off') {
$parent_id = wp_get_post_parent_id(get_the_ID());
// Add current page id to exclude tree list ...
$exclude_tree .= get_the_ID();
} else {
if ($showall != 'off') {
$parent_id = 0;
} else {
if ($parent_id == -1) {
$parent_id = get_the_ID();
}
}
}
if ($sortby == 'menu_order') {
$sortby = 'menu_order, post_title';
}
$out = wp_list_pages(apply_filters('ccchildpages_widget_pages_args', array('title_li' => '', 'child_of' => $parent_id, 'echo' => 0, 'depth' => $depth, 'sort_column' => $sortby, 'exclude' => $exclude, 'exclude_tree' => $exclude_tree), $args, $instance));
if (empty($out)) {
return;
}
// Give up if the page has no children
$ul_open = apply_filters('ccchildpages_widget_start_ul', '<ul>', $args, $instance);
$ul_close = apply_filters('ccchildpages_widget_end_ul', '</ul>', $args, $instance);
$out = apply_filters('ccchildpages_widget_output', $ul_open . $out . $ul_close, $args, $instance);
echo apply_filters('ccchildpages_before_widget', $args['before_widget'], $args, $instance);
if (!empty($instance['title'])) {
$before_title = apply_filters('ccchildpages_widget_before_title', $args['before_title'], $args, $instance);
$after_title = apply_filters('ccchildpages_widget_after_title', $args['after_title'], $args, $instance);
echo $before_title . apply_filters('widget_title', $instance['title'], $args, $instance) . $after_title;
}
echo $out;
echo apply_filters('ccchildpages_after_widget', $args['after_widget'], $args, $instance);
}
开发者ID:sissisnothere,项目名称:testWeb,代码行数:53,代码来源:ccchildpages_widget.php
示例18: test_bbp_insert_reply
/**
* @group canonical
* @covers ::bbp_insert_reply
*/
public function test_bbp_insert_reply()
{
$f = $this->factory->forum->create();
$t = $this->factory->topic->create(array('post_parent' => $f, 'topic_meta' => array('forum_id' => $f)));
$r = $this->factory->reply->create(array('post_title' => 'Reply To: Topic 1', 'post_content' => 'Content of reply to Topic 1', 'post_parent' => $t, 'reply_meta' => array('forum_id' => $f, 'topic_id' => $t)));
// Get the reply.
$reply = bbp_get_reply($r);
remove_all_filters('bbp_get_reply_content');
// Reply post.
$this->assertSame('Reply To: Topic 1', bbp_get_reply_title($r));
$this->assertSame('Content of reply to Topic 1', bbp_get_reply_content($r));
$this->assertSame('publish', bbp_get_reply_status($r));
$this->assertSame($t, wp_get_post_parent_id($r));
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?reply=' . $reply->post_name, $reply->guid);
// Reply meta.
$this->assertSame($f, bbp_get_reply_forum_id($r));
$this->assertSame($t, bbp_get_reply_topic_id($r));
}
开发者ID:joeyblake,项目名称:bbpress,代码行数:22,代码来源:reply.php
示例19: assign_sale_category
/**
* Assign/unassign the sale category after post meta was updated.
*/
public function assign_sale_category($meta_id, $post_id, $meta_key, $meta_value)
{
if ($meta_key != '_price') {
return;
// do nothing, if the meta key is not _price
}
if (wp_get_post_parent_id($post_id)) {
return;
// bail if this is a variation
}
$product = wc_get_product($post_id);
if ($product->is_on_sale()) {
// product is on sale, let's assign the sale category
wp_set_object_terms($post_id, $this->sale_category, 'product_cat', true);
} else {
// product is not on sale, let's remove the sale category
wp_remove_object_terms($post_id, $this->sale_category, 'product_cat');
}
}
开发者ID:jurajk,项目名称:WooCommerce-Sale-Category,代码行数:22,代码来源:class-wc-integration-sale-category.php
示例20: trigger
/**
* trigger function.
*
* @access public
* @return void
*/
function trigger($order_id)
{
if (!$this->is_enabled() || empty($order_id) || !wp_get_post_parent_id($order_id)) {
return false;
}
$this->object = wc_get_order($order_id);
$this->vendor = yith_get_vendor($this->object->post->post_author, 'user');
if (!$this->vendor->is_valid()) {
return false;
}
$this->find['order-date'] = '{order_date}';
$this->find['order-number'] = '{order_number}';
$this->replace['order-date'] = date_i18n(wc_date_format(), strtotime($this->object->order_date));
$this->replace['order-number'] = $this->object->get_order_number();
$vendor_email = $this->vendor->store_email;
if (empty($vendor_email)) {
$vendor_owner = get_user_by('id', absint($this->vendor->get_owner()));
$vendor_email = $vendor_owner instanceof WP_User ? $vendor_owner->user_email : false;
}
// Send Email to Vendor
$this->send($vendor_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
}
开发者ID:kanhaiyasharma,项目名称:Bestswiss,代码行数:28,代码来源:class-yith-wc-email-new-order.php
注:本文中的wp_get_post_parent_id函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论