最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - remove_query_arg on options.php

programmeradmin1浏览0评论

I have a normal WordPress settings page. It POSTs to options.php.

In options.php it uses wp_get_referer to redirect back to the page it came from.

I need to use remove_query_arg to remove an argument from the URL. Example:

.php?page=plugin_settings_page&tab=90

I need to remove the tab=90 part. How can I do this via options.php?

I have a normal WordPress settings page. It POSTs to options.php.

In options.php it uses wp_get_referer to redirect back to the page it came from.

I need to use remove_query_arg to remove an argument from the URL. Example:

https://www.example/wp-admin/admin.php?page=plugin_settings_page&tab=90

I need to remove the tab=90 part. How can I do this via options.php?

Share Improve this question asked Mar 17, 2017 at 20:18 Scott PatersonScott Paterson 234 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

Ended up using jQuery to do this. There might be a better way, but this works:

jQuery("input[name=_wp_http_referer]").val('admin.php?page=plugin_settings_page')

I would create a function that unset the tab parameter, then call that function using add_filter to filter it from the query_vars array. The example value of 20 may need to be changed depending on when the tab parameter is currently being added.

  add_filter('query_vars', 'remove_queryvars_param', 20 );

    function remove_queryvars_param( $qvars )
    {
        unset($qvars['tab']);

        return $qvars;
    }
发布评论

评论列表(0)

  1. 暂无评论