bojaghi/seed-objects

Seed objects module.

1.0.0 2024-12-11 11:43 UTC

This package is auto-updated.

Last update: 2024-12-11 11:45:17 UTC


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(/* .. */),
);