nlemoine / wp-cli-fixtures Goto Github PK
View Code? Open in Web Editor NEWEasily generate custom fake data for WordPress
License: GNU General Public License v3.0
Easily generate custom fake data for WordPress
License: GNU General Public License v3.0
Is there a way to export actual data to a yml file?
It's been quite a while since you've published a new release (0.3.0...master) worth a 0.4.0
?
We run wp package install hellonico/wp-cli-fixtures
as part of our setup and would be good to be able to use wp package install hellonico/wp-cli-fixtures:@stable
with the new features now in master.
Just FYI. If it's trivial, I'll do a PR. Greets
Please See this yml File:
Hellonico\Fixtures\Entity\User:
user{1..10}:
user_login (unique): <username()> # '(unique)' is required
user_pass: 123
user_email: <freeEmail()>
user_url: <url()>
user_registered: <dateTimeThisDecade()>
first_name: <firstName()>
last_name: <lastName()>
description: <sentence()>
role: <randomElement(['subscriber', 'editor'])>
meta:
show_admin_bar_front: 'false'
billing_phone: <phoneNumber()>
billing_country: 'IR'
billing_state: <randomElement(['ABZ','ADL','EAZ','WAZ','BHR','CHB','FRS','GIL','GLS','HDN','HRZ','ILM','ESF','KRN','KRH','NKH','RKH','SKH','KHZ','KBD','KRD','LRS','MKZ','MZN','GZN','QHM','SMN','SBN','THR','YZD','ZJN'])>
billing_city: <city()>
billing_address_1: <streetAddress()>
billing_postcode: <postcode()>
billing_email: <freeEmail()>
billing_first_name: <firstName()>
billing_last_name: <lastName()>
I want to billing_first_name
= first_name
when creating this user in any loop?
#
# POSTS
#
Hellonico\Fixtures\Entity\Post:
# TEMPLATE
defaultpost (template):
post_title: <words(5, true)>
post_date: <dateTimeThisDecade()>
post_content: <paragraphs(5, true)>
post_excerpt: <paragraphs(1, true)>
# CUSTOM POST TYPE
product{1..15} (extends defaultpost):
post_type: product
meta:
_thumbnail_id: '@custom_images*->ID'
meta_input:
_sku: <numberBetween(1000, 2000)>
_regular_price: <numberBetween(10000, 20000)>
_price: <numberBetween(10000, 20000)>
_sale_price: <numberBetween(10000, 20000)>
_stock_status: 'instock'
_manage_stock: 'yes'
_stock: <numberBetween(1, 10)>
I Want to _sale_price
= _price
. how to use before value in YAML?
thanks
Hi, first of all thank you for this awesome package.
My company is considering to adopt it for our local WP development and we'd like to have these features discussed:
On October 12 #13 was merged into the main
-branch with the following fixes :
Could be useful to have these changes tagged for a new release
Currently, the Composer package has these changes only available on the dev-main
version
Hi,
I have an ACF flexible content field to add "components", groups of acf fields, to a custom post type. All the fixtures I have made so far are working well. How would I add a flexible content field?
This is what I am trying so far:
Hellonico\Fixtures\Entity\Post:
post{1..2}:
post_type: 'blog'
post_title (unique): '<words(4, true)>'
post_date: '<dateTimeThisDecade()>'
acf:
byline: '<firstName()> <lastName()>'
intro: '<words(20, true)>'
add_image: 'true'
featured_image: '@featured_images*->ID'
featured_image_alt_text: '<words(4, true)>'
components:
- 'text'
- 'image'
components_0_header: '<words(4, true)>'
components_0_rich_text: <paragraphs(2, true)>
components_0_add_image: 'true'
components_0_image: '@pics*->ID'
components_0_image_alt_text: '<words(4, true)>'
components_0_placement: 'right'
components_0_size: 'half'
components_1_image: '@pics*->ID'
components_1_image_alt_text: '<words(4, true)>'
and this is what a dump of the $post looks like:
+ImageClass: "Timber\Image"
+PostClass: "Timber\Post"
+TermClass: "Timber\Term"
+object_type: "post"
+custom: array:32 [▼
"_fake" => "1"
"_wp_old_date" => "2021-10-28"
"byline" => "Allison Runolfsson"
"_byline" => "field_blog_byline"
"intro" => "sed a nam et sint autem inventore aut officia aut aut blanditiis et ducimus eos odit amet et est ut"
"_intro" => "field_blog_intro"
"add_image" => "1"
"_add_image" => "field_blog_add_image"
"featured_image" => "76"
"_featured_image" => "field_blog_featured_image"
"featured_image_alt_text" => "nisi molestiae quidem ut"
"_featured_image_alt_text" => "field_blog_featured_image_alt_text"
"components" => array:2 [▼
0 => "text"
1 => "image"
]
"_components" => "field_blog_components"
"_edit_lock" => "1635428232:1"
"_edit_last" => "1"
"featured_image_caption" => ""
"_featured_image_caption" => "field_blog_featured_image_caption"
"components_0_header" => "header"
"_components_0_header" => "field_blog_components_text_header"
"components_0_hide_header" => "0"
"_components_0_hide_header" => "field_blog_components_text_hide_header"
"components_0_rich_text" => "rich text"
"_components_0_rich_text" => "field_blog_components_text_rich_text"
"components_0_add_image" => "0"
"_components_0_add_image" => "field_blog_components_text_add_image"
"components_1_image" => "76"
"_components_1_image" => "field_blog_components_image_image"
"components_1_image_alt_text" => "field"
"_components_1_image_alt_text" => "field_blog_components_image_image_alt_text"
"components_1_image_caption" => ""
"_components_1_image_caption" => "field_blog_components_image_image_caption"
]```
Any guidance would be appreciated.
Hello, when I run wp fixtures load
I am hitting the following error:
PHP Fatal error: Declaration of Hellonico\Fixtures\Provider\Picsum::imageUrl($width = 640, $height = 480, $filters = [], $format = 'jpg', $unused = false, $unused_ = false) must be compatible with Faker\Provider\Image::imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false, $format = 'png') in /var/www/html/sites/test/vendor/hellonico/wp-cli-fixtures/src/Provider/Picsum.php on line 19
Have you given any thought to how you might handle translations of fixtures?
For example how to handle fixtures on sites using WPML?
Given the following:
#
# TERMS
#
Hellonico\Fixtures\Entity\Term:
focus_areas{1..4}: # custom taxonomy
name (unique): <words(3, true)> # '(unique)' is required
description: <sentences(1, true)>
taxonomy: focus_area
#
# POSTS
#
Hellonico\Fixtures\Entity\Post:
default (template):
post_title: <words(2, true)>
post_date: <dateTimeThisDecade()>
post_content: <paragraphs(5, true)>
post_excerpt: <paragraphs(1, true)>
projects_with_focus_area_1_{1..5}:
__construct: [<postId(post_type=projects&post_status=publish)>]
tax_input:
focus_area: '@focus_areas1->term_id'
I can relate the generated terms just fine to the existing posts, but the <postID()>
function does not stick to fetching posts in the default language. It randomly fetches posts regardless of their language. Would you be interested in a fix for this?
I imagine checking if WPML is running, and if so, limit the post query to only fetch posts in the default language.
Example use case:
Say I have an existing post, and I add a new ACF field to it.
I then populate the new field with fixtures during development.
Prior to deploying the new field, I remove the fixtures for the new field.
Would this be possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.