bojaghi / seed-objects
Seed objects module.
1.0.0
2024-12-11 11:43 UTC
Requires
- php: >=8.0
- bojaghi/contract: ^1.0
- bojaghi/helper: ^1.0
Requires (Dev)
- bojaghi/wp-tests: ^1.0
- phpunit/phpunit: ^9
- yoast/phpunit-polyfills: ^3.0
README
Seed posts and terms helper
How to use
See example below:
<?php use Bojaghi\SeedObjects\SeedsObjects; $seedObjects = new SeedsObjects( [ 'isPlugin' => true, // 'true' for plugins, 'false' for themes. 'removeOnDeactivation' => false, // 'true' if you want to delete all seed objects after the deactivation. 'mainFile' => '/path/to/plugin/main_file' // Required if isPlugin=true. 'comments' => '', // Path or configuration array for comments/posts/terms/users. 'posts' => '', 'terms' => '', 'users' => '', ], );
Each configuration array is a series of arguments, which should be adapted into wp_insert_*() function call. For example, 'posts' configuration file:
<?php /** * /path/to/posts/configuration/post-seeds.php */ // Prevent direct access. if (!defined('ABSPATH')) { exist; } return array( // #1 array( 'post_title' => 'Foo #1', 'post_type' => 'post', /* ... */ ), // #2 array(/* .. */), // #3 array(/* .. */), // #4 array(/* .. */), );