public static function import() { $db = MigratePages::getConnection(); $sql = file_get_contents(ABSPATH . 'wp-content/uploads/pages.sql'); $stmt = $db->prepare($sql); $stmt->execute(); echo $stmt->rowCount() . " posts imported"; }
/** * Move all the children of the entity to the new container_guid * * @param int $new_container_guid the new container_guid * * @return void */ protected function moveSubpages($new_container_guid) { // ignore access for this part $ia = elgg_set_ignore_access(true); $batch = new \ElggBatch('elgg_get_entities_from_metadata', ['type' => 'object', 'subtype' => 'page', 'limit' => false, 'metadata_name_value_pairs' => ['name' => 'parent_guid', 'value' => $this->object->getGUID()]]); /* @var $subpage \ElggObject */ foreach ($batch as $subpage) { $migrate = new MigratePages($subpage); $migrate->changeContainer($new_container_guid); $subpage->save(); } // restore access elgg_set_ignore_access($ia); }