static function get_all_pages_id_parent($post_type = 'page') { if (!is_array(wp2grav_content_tree::$arr_all_pages_id_parent)) { // get all pages, once, to spare some queries looking for children $all_pages = get_posts(array("numberposts" => -1, "post_type" => $post_type, "post_status" => "any", "fields" => "id=>parent")); //print_r($all_pages);exit; wp2grav_content_tree::$arr_all_pages_id_parent = $all_pages; } return wp2grav_content_tree::$arr_all_pages_id_parent; }
/** * Loops through posts and pages to compile md files for each. * * @since 1.0.0 * * @return void */ protected function export() { // export blog items // page id for exporting blog posts $blogPageId = (int) WP2GRAV_BLOG_MASTER_PAGE_ID; // Load qTranslate settings if available $qt = $this->qt_settings(); if (is_array($qt)) { // found qtranslate_slug global $qtranslate_slug; $qtranslate_slug = isset($qtranslate_slug) ? $qtranslate_slug : null; } else { $qtranslate_slug = false; } // generate tree array of content structure // array( // 'page' => $pageObj, // 'subtree' => $subTreeArray //) $GLOBALS['WP2GRAV_CNT'] = 0; // export authors $this->writeMeta(); // get root items $args = array("echo" => 0, "sort_order" => "ASC", "sort_column" => "menu_order", "parent" => 0); // export pages $contentArray = wp2grav_get_pages($args, 'page'); $this->processExport($contentArray, $qt, $qtranslate_slug, null, 'default'); // reset content tree wp2grav_content_tree::$arr_all_pages_id_parent = null; // export Blog pages $contentArray = wp2grav_get_pages($args, 'post'); $blogPageArray = array(array('page' => get_post($blogPageId), 'subtree' => $contentArray)); //override pageFileName property $blogPageArray[0]['page']->pageFileName = 'blog'; $this->processExport($blogPageArray, $qt, $qtranslate_slug, null, 'item'); $this->addNotice(WP2GravView::notice('admin/export-success') . $this->destination); wp_reset_postdata(); // emulate wp_safe_redirect(); $location = admin_url('admin.php?page=' . $this->plugin . '-export'); $location = wp_sanitize_redirect($location); $location = wp_validate_redirect($location, admin_url()); ?> <script type="text/javascript"> location.href = "<?php echo $location; ?> "; </script> <?php exit; }