silbinarywolf / silverstripe-wordpressmigrationtools
2.0.0
2018-09-07 05:29 UTC
Requires
- php: >=5.3.0
- silverstripe/cms: ~3.2
- silverstripe/framework: ~3.2
- symbiote/php-wordpress-database-tools: ~1.0
Replaces
This package is not auto-updated.
Last update: 2022-02-01 13:00:28 UTC
README
一个处理各种操作的Wordpress导入器
- 导入页面(WordpressImportService::importPages)
- 更新导入的页面以匹配Wordpress页面层次结构(WordpressImportService::updatePagesBasedOnHierarchy)
- 修正$Content或Elemental的ElementContent $HTML以指向本地URL或短代码(WordpressImportService::fixPostContentURLs)
- 更新主页以匹配Wordpress主页(WordpressImportService::setHomepageToWordpressPageAndDeleteCurrentHomePage)
- 更新导入的页面以匹配提供的Wordpress菜单层次结构(WordpressImportService::updatePagesBasedOnNavMenu)
- 将Gravity Forms数据导入为用户自定义表单页面(WordpressImportService::importGravityForms)
快速开始
- 在YML中配置WordpressImportBasicTask条目
--- Name: wordpress_import After: - 'framework/*' - 'cms/*' --- WordpressImportBasicTask: default_db: database: 'my-wordpress-db' username: 'root' password: '' table_prefix: 'wp' navigation_slug: 'top-navigation'
- 从/dev/tasks运行"Wordpress Basic Import Task"
修改/扩展导入器
此Wordpress导入器设计为允许您获取特定要使用的功能,然后轻松地在上面添加自己的逻辑。最简单的方法是创建自己的任务,扩展'WordpressImportBasicTask'并重写'runCustom'函数。从这里,您可以选择调用'parent::runCustom()'或复制粘贴单独的导入函数调用,并注释掉不需要的部分。
<?php class WordpressTask extends WordpressImportBasicTask { public function runCustom($request) { /** * Uncomment this or copy-paste the various functions called in the * parent into this and comment out what you don't need. */ //parent::runCustom($request); try { // Overriden to just import a flat list of pages $this->wordpressImportService->importPages(); // ... and fix the content href's/src's $this->wordpressImportService->fixPostContentURLs(); } catch (Exception $e) { throw $e; } }