Envato_Theme_Setup_Wizard::_parse_gallery_shortcode_content PHP Метод

        private function _parse_gallery_shortcode_content($content)
        {
            // we have to format the post content. rewriting images and gallery stuff
            $replace = $this->_imported_post_id();
            $urls_replace = array();
            foreach ($replace as $key => $val) {
                if ($key && $val && !is_numeric($key) && !is_numeric($val)) {
                    $urls_replace[$key] = $val;
                }
            }
            if ($urls_replace) {
                uksort($urls_replace, array(&$this, 'cmpr_strlen'));
                foreach ($urls_replace as $from_url => $to_url) {
                    $content = str_replace($from_url, $to_url, $content);
                }
            }
            if (preg_match_all('#\\[gallery[^\\]]*\\]#', $content, $matches)) {
                foreach ($matches[0] as $match_id => $string) {
                    if (preg_match('#ids="([^"]+)"#', $string, $ids_matches)) {
                        $ids = explode(',', $ids_matches[1]);
                        foreach ($ids as $key => $val) {
                            $new_id = $val ? $this->_imported_post_id($val) : false;
                            if (!$new_id) {
                                unset($ids[$key]);
                            } else {
                                $ids[$key] = $new_id;
                            }
                        }
                        $new_ids = implode(',', $ids);
                        $content = str_replace($ids_matches[0], 'ids="' . $new_ids . '"', $content);
                    }
                }
            }
            // contact form 7 id fixes.
            if (preg_match_all('#\\[contact-form-7[^\\]]*\\]#', $content, $matches)) {
                foreach ($matches[0] as $match_id => $string) {
                    if (preg_match('#id="(\\d+)"#', $string, $id_match)) {
                        $new_id = $this->_imported_post_id($id_match[1]);
                        if ($new_id) {
                            $content = str_replace($id_match[0], 'id="' . $new_id . '"', $content);
                        } else {
                            // no imported ID found. remove this entry.
                            $content = str_replace($matches[0], '(insert contact form here)', $content);
                        }
                    }
                }
            }
            return $content;
        }