Amazon_S3_And_CloudFront::get_plugin_page_url PHP Method

get_plugin_page_url() public method

Helper method to return the settings page URL for the plugin
public get_plugin_page_url ( array $args = [], string $url_method = 'network', boolean $escape = true ) : string
$args array
$url_method string To prepend to admin_url()
$escape boolean Should we escape the URL
return string
    function get_plugin_page_url($args = array(), $url_method = 'network', $escape = true)
    {
        $default_args = array('page' => self::$plugin_page);
        $args = array_merge($default_args, $args);
        switch ($url_method) {
            case 'self':
                $base_url = self_admin_url('admin.php');
                break;
            case '':
                $base_url = admin_url('admin.php');
                break;
            default:
                $base_url = network_admin_url('admin.php');
        }
        // Add a hash to the URL
        $hash = false;
        if (isset($args['hash'])) {
            $hash = $args['hash'];
            unset($args['hash']);
        } else {
            if ($this->default_tab) {
                $hash = $this->default_tab;
            }
        }
        $url = add_query_arg($args, $base_url);
        if ($hash) {
            $url .= '#' . $hash;
        }
        if ($escape) {
            $url = esc_url_raw($url);
        }
        return $url;
    }

Usage Example

 /**
  * Helper for the above action requests
  *
  * @param int $status
  */
 protected function change_status_request($status)
 {
     $session = $this->get_session();
     $session['status'] = $status;
     $this->save_session($session);
     $url = $this->as3cf->get_plugin_page_url(array(), 'self');
     wp_redirect($url);
     exit;
 }
Amazon_S3_And_CloudFront