Wordpress前端产品编辑链接更改为wp管理员编辑产品(编辑按钮来自wc供应商插件)
我正在使用wc供应商专业插件,它为供应商提供了一个简单的仪表板来处理产品-产品可以在那里添加、编辑和删除。 但要求是:点击编辑它应该进入wp管理产品帖子,编辑相同的产品 我有这个过滤器来更改URL,但我不知道如何获得相同的产品ID? 有什么帮助吗Wordpress前端产品编辑链接更改为wp管理员编辑产品(编辑按钮来自wc供应商插件),wordpress,plugins,Wordpress,Plugins,我正在使用wc供应商专业插件,它为供应商提供了一个简单的仪表板来处理产品-产品可以在那里添加、编辑和删除。 但要求是:点击编辑它应该进入wp管理产品帖子,编辑相同的产品 我有这个过滤器来更改URL,但我不知道如何获得相同的产品ID? 有什么帮助吗 add_filter( 'wcv_product_edit_link', 'link_actions_edit', 10, 3); function link_actions_edit($template_url, $product_id) { $
add_filter( 'wcv_product_edit_link', 'link_actions_edit', 10, 3);
function link_actions_edit($template_url, $product_id) {
$template_url = '/wp-admin/post.php?php='. $product_id.'&action=edit';
return $template_url;
}
这是插件代码
/**
* Get the product edit link depending on several different variables
*
* @since 1.4.0
* @access public
* @return array $product_edit_link
*/
public static function get_product_edit_link( $product_id = null, $default = false ){
$default_template = get_option( 'wcvendors_product_form_template' );
$default_template = 'edit' === $default_template ? 'standard' : $default_template;
$default_link = ( 'standard' === $default_template ) ? 'product/edit/' : 'product/' . $default_template . '/edit/';
// Only load a custom template if the product has one
if ( $product_id ){
$template = get_post_meta( $product_id, '_wcv_product_form_template', true );
$template = $template === 'edit' || $template === 'standard' ? '' : $template;
if ( !empty( $template ) ) $template = $template . '/';
}
if ( $default ) $template = $default_link;
$template_url = ( empty( $template ) ) ? $default_link : 'product/' . $template . 'edit/';
return apply_filters( 'wcv_product_edit_link', WCVendors_Pro_Dashboard::get_dashboard_page_url( $template_url . $product_id ) );
}
您可以在筛选函数中传递错误的参数 按照以下步骤更改代码:
function link_actions_edit($param) {
$home_url = get_home_url();
$remove_http = str_replace('http://', '', $param);
$split_url = explode('/', $remove_http);
$get_product_id = $split_url[4];
$product_edit_url = $home_url . '/wp-admin/post.php?post='. $get_product_id.'&action=edit';
return $product_edit_url;
}