本文整理汇总了PHP中WC_Product_Variation::get_permalink方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product_Variation::get_permalink方法的具体用法?PHP WC_Product_Variation::get_permalink怎么用?PHP WC_Product_Variation::get_permalink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product_Variation
的用法示例。
在下文中一共展示了WC_Product_Variation::get_permalink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post_process
/**
* Post-processes the results
*
* @return array of results
*/
protected function post_process()
{
$pageposts = is_array($this->results) ? $this->results : array();
$options = $this->options;
$searchId = $this->searchId;
$searchData = $this->searchData;
$s = $this->s;
$_s = $this->_s;
// No post processing is needed on non-ajax search
if (isset($options['non_ajax_search'])) {
$this->results = $pageposts;
return $pageposts;
}
if (is_multisite()) {
$home_url = network_home_url();
} else {
$home_url = home_url();
}
foreach ($pageposts as $k => $v) {
$r =& $pageposts[$k];
$r->title = w_isset_def($r->title, null);
$r->content = w_isset_def($r->content, null);
$r->image = w_isset_def($r->image, null);
$r->author = w_isset_def($r->author, null);
$r->date = w_isset_def($r->date, null);
}
aspDebug::start('--searchContent-posptrocess');
/* Images, title, desc */
foreach ($pageposts as $k => $v) {
// Let's simplify things
$r =& $pageposts[$k];
if (isset($options['switch_on_preprocess']) && is_multisite()) {
switch_to_blog($r->blogid);
}
$r = apply_filters('asp_result_before_prostproc', $r, $searchId);
$r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id, $searchId);
$r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id, $searchId);
$r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id, $searchId);
$r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id, $searchId);
$r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id, $searchId);
$r->link = get_permalink($v->id);
// ---- URL FIX for WooCommerce product variations
if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
$wc_prod_var_o = new WC_Product_Variation($r->id);
$r->link = $wc_prod_var_o->get_permalink();
}
$caching_options = w_false_def(get_option('asp_caching'), get_option('asp_caching_def'));
$use_bfi = w_isset_def($caching_options['use_bfi_thumb'], 1);
$image_settings = $searchData['image_options'];
if ($image_settings['show_images'] != 0) {
if ($image_settings['image_cropping'] == 0) {
// Use the BFI parser, but no caching
$im = $this->getBFIimage($r);
if ($im != '') {
$r->image = $im;
}
} else {
if ($use_bfi == 0) {
$im = $this->getCachedImage($r);
if ($im != '') {
$r->image = $im;
}
} else {
$im = $this->getBFIimage($r);
if ($im != '' && strpos($im, "mshots/v1") === false) {
if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
} else {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
}
$r->image = bfi_thumb($im, $bfi_params);
} else {
$r->image = $im;
}
}
}
}
if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
$r->title = get_the_title($r->id);
} else {
if ($searchData['titlefield'] == "1") {
if (strlen($r->excerpt) >= 200) {
$r->title = wd_substr_at_word($r->excerpt, 200);
} else {
$r->title = $r->excerpt;
}
} else {
$mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
if (isset($mykey_values[0])) {
$r->title = $mykey_values[0];
} else {
$r->title = get_the_title($r->id);
}
}
}
//.........这里部分代码省略.........
示例2: post_process
protected function post_process()
{
$pageposts = is_array($this->results) ? $this->results : array();
$options = $this->options;
$searchData = $this->searchData;
$s = $this->s;
$_s = $this->_s;
$performance_options = get_option('asl_performance');
if (is_multisite()) {
$home_url = network_home_url();
} else {
$home_url = home_url();
}
foreach ($pageposts as $k => $v) {
$r =& $pageposts[$k];
$r->title = w_isset_def($r->title, null);
$r->content = w_isset_def($r->content, null);
$r->image = w_isset_def($r->image, null);
$r->author = w_isset_def($r->author, null);
$r->date = w_isset_def($r->date, null);
}
/* Images, title, desc */
foreach ($pageposts as $k => $v) {
// Let's simplify things
$r =& $pageposts[$k];
$r->title = apply_filters('asl_result_title_before_prostproc', $r->title, $r->id);
$r->content = apply_filters('asl_result_content_before_prostproc', $r->content, $r->id);
$r->image = apply_filters('asl_result_image_before_prostproc', $r->image, $r->id);
$r->author = apply_filters('asl_result_author_before_prostproc', $r->author, $r->id);
$r->date = apply_filters('asl_result_date_before_prostproc', $r->date, $r->id);
$r->link = get_permalink($v->id);
$image_settings = $searchData['image_options'];
if ($image_settings['show_images'] != 0) {
$im = $this->getBFIimage($r);
if ($im != '' && strpos($im, "mshots/v1") === false && w_isset_def($performance_options['image_cropping'], 0) == 1) {
if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
} else {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
}
$r->image = bfi_thumb($im, $bfi_params);
} else {
$r->image = $im;
}
}
if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
$r->title = get_the_title($r->id);
} else {
if ($searchData['titlefield'] == "1") {
if (strlen($r->excerpt) >= 200) {
$r->title = wd_substr_at_word($r->excerpt, 200);
} else {
$r->title = $r->excerpt;
}
} else {
$mykey_values = get_post_custom_values($searchData['titlefield'], $r->id);
if (isset($mykey_values[0])) {
$r->title = $mykey_values[0];
} else {
$r->title = get_the_title($r->id);
}
}
}
//remove the search shortcodes properly
add_shortcode('wpdreams_ajaxsearchpro', array($this, 'return_empty_string'));
add_shortcode('wpdreams_ajaxsearchlite', array($this, 'return_empty_string'));
if (!isset($searchData['striptagsexclude'])) {
$searchData['striptagsexclude'] = "<a><span>";
}
if (!isset($searchData['descriptionfield']) || $searchData['descriptionfield'] == "0" || is_array($searchData['descriptionfield'])) {
if (w_isset_def($searchData['strip_shortcodes'], 0) == 1) {
$r->content = strip_shortcodes($r->content);
}
if (function_exists('qtrans_getLanguage')) {
$r->content = apply_filters('the_content', $r->content);
}
$_content = strip_tags($r->content);
} else {
if ($searchData['descriptionfield'] == "1") {
$_content = strip_tags($r->excerpt);
} else {
if ($searchData['descriptionfield'] == "2") {
$_content = strip_tags(get_the_title($r->id));
} else {
$mykey_values = get_post_custom_values($searchData['descriptionfield'], $r->id);
if (isset($mykey_values[0])) {
$_content = strip_tags($mykey_values[0]);
} else {
$_content = strip_tags($r->content);
}
}
}
}
if ($_content == "" && $r->content != '') {
$_content = $r->content;
}
if ($_content != "") {
$_content = str_replace('[wpdreams_ajaxsearchlite]', "", $_content);
}
if ($_content != "") {
//.........这里部分代码省略.........
示例3: post_process
/**
* Post-processes the results
*
* @return array of results
*/
protected function post_process()
{
$pageposts = is_array($this->results) ? $this->results : array();
$options = $this->options;
$searchId = $this->searchId;
$searchData = $this->searchData;
$s = $this->s;
$_s = $this->_s;
// Get multibite or regular functions to variables
extract($this->mb_f);
// No post processing is needed on non-ajax search
if (isset($options['non_ajax_search'])) {
$this->results = $pageposts;
return $pageposts;
}
if (is_multisite()) {
$home_url = network_home_url();
} else {
$home_url = home_url();
}
foreach ($pageposts as $k => $v) {
$r =& $pageposts[$k];
$r->title = w_isset_def($r->title, null);
$r->content = w_isset_def($r->content, null);
$r->image = w_isset_def($r->image, null);
$r->author = w_isset_def($r->author, null);
$r->date = w_isset_def($r->date, null);
}
/*--------------------- For Image Parser -----------------------*/
// Do not select the content field, if it is not used at all
$get_content = $searchData['showdescription'] == 1 || $searchData['resultstype'] == "isotopic" && $searchData['i_ifnoimage'] == 'description' || $searchData['resultstype'] == "polaroid" && ($searchData['pifnoimage'] == 'descinstead' || $searchData['pshowdesc'] == 1) ? false : true;
// Do not select excerpt if its not used at all
$get_excerpt = w_isset_def($searchData['titlefield'], 0) == 1 || w_isset_def($searchData['descriptionfield'], 0) == 1 ? false : true;
/*---------------------------------------------------------------*/
aspDebug::start('--searchContent-posptrocess');
/* Images, title, desc */
foreach ($pageposts as $k => $v) {
// Let's simplify things
$r =& $pageposts[$k];
if (isset($options['switch_on_preprocess']) && is_multisite()) {
switch_to_blog($r->blogid);
}
$r = apply_filters('asp_result_before_prostproc', $r, $searchId);
$r->title = apply_filters('asp_result_title_before_prostproc', $r->title, $r->id, $searchId);
$r->content = apply_filters('asp_result_content_before_prostproc', $r->content, $r->id, $searchId);
$r->image = apply_filters('asp_result_image_before_prostproc', $r->image, $r->id, $searchId);
$r->author = apply_filters('asp_result_author_before_prostproc', $r->author, $r->id, $searchId);
$r->date = apply_filters('asp_result_date_before_prostproc', $r->date, $r->id, $searchId);
$r->link = get_permalink($v->id);
// ---- URL FIX for WooCommerce product variations
if ($r->post_type == 'product_variation' && class_exists('WC_Product_Variation')) {
$wc_prod_var_o = new WC_Product_Variation($r->id);
$r->link = $wc_prod_var_o->get_permalink();
}
$caching_options = w_false_def(get_option('asp_caching'), get_option('asp_caching_def'));
$use_bfi = w_isset_def($caching_options['use_bfi_thumb'], 1);
$image_settings = $searchData['image_options'];
if ($image_settings['show_images'] != 0) {
if ($image_settings['image_cropping'] == 0) {
// Use the BFI parser, but no caching
$im = $this->getBFIimage($r, $get_content, $get_excerpt);
if ($im != '') {
$r->image = $im;
}
} else {
if ($use_bfi == 0) {
$im = $this->getCachedImage($r, $get_content, $get_excerpt);
if ($im != '') {
$r->image = $im;
}
} else {
$im = $this->getBFIimage($r, $get_content, $get_excerpt);
if ($im != '' && strpos($im, "mshots/v1") === false) {
if (w_isset_def($image_settings['image_transparency'], 1) == 1) {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true);
} else {
$bfi_params = array('width' => $image_settings['image_width'], 'height' => $image_settings['image_height'], 'crop' => true, 'color' => wpdreams_rgb2hex($image_settings['image_bg_color']));
}
$r->image = bfi_thumb($im, $bfi_params);
} else {
$r->image = $im;
}
}
}
}
// If no image and defined, remove the result here, to perevent JS confusions
if (empty($r->image) && $searchData['resultstype'] == "isotopic" && $searchData['i_ifnoimage'] == 'removeres') {
unset($pageposts[$k]);
continue;
}
if (!isset($searchData['titlefield']) || $searchData['titlefield'] == "0" || is_array($searchData['titlefield'])) {
$r->title = get_the_title($r->id);
} else {
if ($searchData['titlefield'] == "1") {
if ($fn_strlen($r->excerpt) >= 200) {
//.........这里部分代码省略.........