Wordpress WP Woo-保存Woo设置后,将删除自定义端点
我已经在我的WP插件中添加了一个端点(用于管理woocommerce->my points中我的帐户部分的额外信息)-我的帐户/moje punkty 我是根据一系列教程完成的,端点从插件激活开始,然后是重写刷新 我的同事向我报告说,当一个用户被添加到数据库中时,这会突然停止工作(返回404错误),尽管我在测试时添加了大量用户,但从未遇到过这个问题 但是今天我注意到,在保存Woo设置后,我的自定义端点也被删除。 有人知道我如何确保自定义端点始终保持与pluing处于活动状态一样长的时间吗 代码参考:Wordpress WP Woo-保存Woo设置后,将删除自定义端点,wordpress,woocommerce,endpoint,Wordpress,Woocommerce,Endpoint,我已经在我的WP插件中添加了一个端点(用于管理woocommerce->my points中我的帐户部分的额外信息)-我的帐户/moje punkty 我是根据一系列教程完成的,端点从插件激活开始,然后是重写刷新 我的同事向我报告说,当一个用户被添加到数据库中时,这会突然停止工作(返回404错误),尽管我在测试时添加了大量用户,但从未遇到过这个问题 但是今天我注意到,在保存Woo设置后,我的自定义端点也被删除。 有人知道我如何确保自定义端点始终保持与pluing处于活动状态一样长的时间吗 代码参
function __construct()
{
register_activation_hook( __FILE__, array( $this, 'foc_points_moje_punkty_endpoints' ) );
register_deactivation_hook( __FILE__, array( $this, 'foc_points_flush_rewrite_rules' ) );
}
add_filter( 'query_vars', array ( $this, 'my_custom_query_vars'), 0 );
function my_custom_query_vars( $vars ) {
$vars[] = 'moje-punkty';
return $vars;
}
add_filter ( 'woocommerce_account_menu_items', array ( $this, 'foc_front_account_menu_points_info') );
function foc_front_account_menu_points_info( $items ) {
echo '<div class="points_dropdown_area">' . esc_html__( 'Your points', 'foc-lang' ) . ': <em>' . $punkty_meta_value . '</em></div>';
$items['moje-punkty'] = esc_html__( 'Points history', 'foc-lang' );
return $items;
}
add_action( 'woocommerce_account_moje-punkty_endpoint', array ( $this, 'foc_front_punkty_endpoint_content' ) );
function foc_front_punkty_endpoint_content() {
// my code
}
/**
* Flush rewrite rules on plugin activation.
*/
function foc_points_moje_punkty_endpoints() {
add_rewrite_endpoint( 'moje-punkty', EP_ROOT | EP_PAGES );
$this->foc_points_flush_rewrite_rules();
}
/**
* Flush rewrite rules on plugin de-activation.
*/
function foc_points_flush_rewrite_rules() {
flush_rewrite_rules();
}
函数uuu构造()
{
注册激活钩子(uuu文件,数组($this,'foc_points_moje_punkty_endpoints'));
寄存器\停用\挂钩(\文件\数组($this,'foc\点\刷新\重写\规则');
}
添加过滤器('query\u vars',array('this,'my\u custom\u query\u vars'),0);
函数my\u custom\u query\u vars($vars){
$vars[]=“moje punkty”;
返回$VAR;
}
添加过滤器('woocommerce\u account\u menu\u items',数组($this,'foc\u front\u account\u menu\u points\u info');
功能焦点\前台\账户\菜单\积分\信息($items){
回显“.esc_html_uuuuu”(“您的点”,“foc lang”):”.$punkty_meta_value.”;
$items['moje-punkty']=esc_html_uuu('Points history','foc lang');
退回$items;
}
添加操作('woocommerce\u account\u moje-punkty\u endpoint',数组('foc\u front\u punkty\u endpoint\u content');
函数foc_front_punkty_endpoint_content(){
//我的代码
}
/**
*刷新插件激活的重写规则。
*/
函数foc_points_moje_punkty_endpoints(){
添加重写端点('moje punkty',EP|u根| EP|u页);
$this->foc_points_flush_rewrite_rules();
}
/**
*刷新插件取消激活时的重写规则。
*/
函数焦点\u点\u刷新\u重写\u规则(){
刷新或重写规则();
}
谢谢大家!