تابع wc_fix_product_attachment_link جلوگیری از افزودن تصویر ( رسانه ) به محصول

تابع wc_fix_product_attachment_link جلوگیری از افزودن تصویر ( رسانه ) به محصول

تابع ووکامرسی wc_fix_product_attachment_link – جلوگیری از افزودن تصویر ( رسانه ) به محصول زمانی که بازخوانی url پیچیده ای پیاده سازی می شود .

Syntax – سینتکس

(string) wc_fix_product_attachment_link( (string) $link, (id) $post_id ); 

Parameters – پارامتر ها (2)

  • 1- $link (string)
  • 2- $post_id (id)

Usage – نحوه استفاده

if ( !function_exists( 'wc_fix_product_attachment_link' ) ) { 
    require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php'; 
} 
  
// The link. 
$link = ''; 
  
// The post id. 
$post_id = null; 
  
// NOTICE! Understand what this does before running. 
$result = wc_fix_product_attachment_link($link, $post_id); 
    

Defined – محل تعریف

/includes/wc-core-functions.php

function wc_fix_product_attachment_link( $link, $post_id ) { 
    global $wp_rewrite; 
 
    $post = get_post( $post_id ); 
    if ( 'product' === get_post_type( $post->post_parent ) ) { 
        $permalinks = wc_get_permalink_structure(); 
        if ( preg_match( '/\/(.+)(\/%product_cat%)$/', $permalinks['product_rewrite_slug'], $matches ) ) { 
            $link = home_url( '/?attachment_id=' . $post->ID ); 
        } 
    } 
    return $link; 
} 

versions – نسخه ها

از نسخه : 3.0.2

نسخه فعلی : 3.0.6

دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2

ارسال نظر

جهت استفاده از کد حتما از تگ pre استفاده نمایید .

contact us