CPTP_Module_GetArchives::get_archives_link PHP Метод

    public function get_archives_link($link)
    {
        global $wp_rewrite;
        if (!isset($this->get_archives_where_r['post_type'])) {
            return $link;
        }
        if ('post' == $this->get_archives_where_r['post_type']) {
            return $link;
        }
        $c = isset($this->get_archives_where_r['taxonomy']) && is_array($this->get_archives_where_r['taxonomy']) ? $this->get_archives_where_r['taxonomy'] : '';
        // [steve]
        $t = $this->get_archives_where_r['post_type'];
        $this->get_archives_where_r['post_type'] = isset($this->get_archives_where_r['post_type_slug']) ? $this->get_archives_where_r['post_type_slug'] : $t;
        // [steve] [*** bug fixing]
        if (isset($this->get_archives_where_r['post_type']) and 'postbypost' != $this->get_archives_where_r['type']) {
            $blog_url = rtrim(home_url(), '/');
            // remove front
            $front = substr($wp_rewrite->front, 1);
            $link = str_replace($front, '', $link);
            $blog_url = preg_replace('/https?:\\/\\//', '', $blog_url);
            $ret_link = str_replace($blog_url, $blog_url . '/%link_dir%', $link);
            $post_type = get_post_type_object($this->get_archives_where_r['post_type']);
            if (empty($c)) {
                // [steve]
                if (isset($post_type->rewrite['slug'])) {
                    $link_dir = $post_type->rewrite['slug'];
                } else {
                    $link_dir = $this->get_archives_where_r['post_type'];
                }
            } else {
                // [steve]
                $c['name'] = 'category' == $c['name'] && get_option('category_base') ? get_option('category_base') : $c['name'];
                $link_dir = $post_type->rewrite['slug'] . '/' . $c['name'] . '/' . $c['termslug'];
            }
            if (!strstr($link, '/date/')) {
                $link_dir = $link_dir . CPTP_Util::get_date_front($post_type);
            }
            if ($post_type->rewrite['with_front']) {
                $link_dir = $front . $link_dir;
            }
            $ret_link = str_replace('%link_dir%', $link_dir, $ret_link);
        } else {
            $ret_link = $link;
        }
        $this->get_archives_where_r['post_type'] = $t;
        // [steve] reverting post_type to previous value
        return $ret_link;
    }