Skip to content

Commit

Permalink
Update and bump to 0.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoni committed Apr 26, 2024
1 parent efa0bbd commit c3072f5
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 21 deletions.
2 changes: 1 addition & 1 deletion fakerpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: FakerPress
* Plugin URI: https://fakerpress.com
* Description: FakerPress is a clean way to generate fake data to your WordPress installation, great for developers who need testing
* Version: 0.6.5
* Version: 0.6.6
* Author: Gustavo Bordoni
* Author URI: https://bordoni.me
* Text Domain: fakerpress
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "fakerpress",
"title": "FakerPress",
"version": "0.6.5",
"version": "0.6.6",
"homepage": "https://fakerpress.com/",
"repository": {
"type": "git",
Expand Down
6 changes: 5 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FakerPress is a clean way to generate fake and dummy content to your WordPress,
**Tags:** [generator](http://wordpress.org/plugins/tags/generator), [dummy content](http://wordpress.org/plugins/tags/dummy+content), [lorem ipsun](http://wordpress.org/plugins/tags/lorem+ipsun), [testing](http://wordpress.org/plugins/tags/testing), [developer](http://wordpress.org/plugins/tags/developer)
**Requires at least:** 5.5
**Tested up to:** 6.5.2
**Stable tag:** 0.6.5
**Stable tag:** 0.6.6
**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html)
**Requires PHP:** 7.4
**Donate link:** https://fakerpress.com/r/sponsor
Expand Down Expand Up @@ -97,6 +97,10 @@ Thank you for wanting to make FakerPress better for everyone! [We salute you](ht

## Changelog ##

### 0.6.6 — 26 of April 2024 ###
* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.
* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking

### 0.6.5 — 26 of April 2024 ###
* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking

Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: generator, dummy content, lorem ipsun, testing, developer
Requires at least: 5.5
Tested up to: 6.5.2
Requires PHP: 7.4
Stable tag: 0.6.5
Stable tag: 0.6.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://fakerpress.com/r/sponsor
Expand Down Expand Up @@ -99,6 +99,11 @@ Thank you for wanting to make FakerPress better for everyone! [We salute you](ht

== Changelog ==

= 0.6.6 — 26 of April 2024 =

* Fix - Prevent notices related to deprecated usage of Faker methods that were being called as properties.
* Fix - Prevent fatals related to bad typecasting of Faker methods used for meta generation. props @helgatheviking

= 0.6.5 — 26 of April 2024 =

* Fix - Ensure meta generation for Users, Terms and Comments work since changes made on version `0.6.2`. props @helgatheviking
Expand Down
17 changes: 16 additions & 1 deletion src/FakerPress/Module/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,22 @@ public function parse_request( $qty, $request = [] ) {

if ( $comment_id && is_numeric( $comment_id ) ) {
foreach ( $metas as $meta_index => $meta ) {
make( Meta::class )->object( $comment_id, 'comment' )->with( $meta['type'], $meta['name'], $meta )->generate()->save();
if ( ! isset( $meta['type'], $meta['name'] ) ) {
continue;
}

$type = get( $meta, 'type' );
$name = get( $meta, 'name' );
unset( $meta['type'], $meta['name'] );

if ( isset( $meta['weight'] ) ) {
$meta['weight'] = absint( $meta['weight'] );
$meta['weight'] = $meta['weight'] > 0 ? $meta['weight'] : 100;
} else {
$meta['weight'] = 100;
}

make( Meta::class )->object( $comment_id, 'comment' )->with( $type, $name, $meta )->generate()->save();
}
}
$results[] = $comment_id;
Expand Down
13 changes: 12 additions & 1 deletion src/FakerPress/Module/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,18 @@ public function parse_request( $qty, $request = [] ) {
continue;
}

make( Meta::class )->object( $post_id )->with( $meta['type'], $meta['name'], $meta )->generate()->save();
$type = get( $meta, 'type' );
$name = get( $meta, 'name' );
unset( $meta['type'], $meta['name'] );

if ( isset( $meta['weight'] ) ) {
$meta['weight'] = absint( $meta['weight'] );
$meta['weight'] = $meta['weight'] > 0 ? $meta['weight'] : 100;
} else {
$meta['weight'] = 100;
}

make( Meta::class )->object( $post_id )->with( $type, $name, $meta )->generate()->save();
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/FakerPress/Module/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,18 @@ public function parse_request( $qty, $request = [] ) {
continue;
}

make( Meta::class )->object( $term_id, 'term' )->with( $meta['type'], $meta['name'], $meta )->generate()->save();
$type = get( $meta, 'type' );
$name = get( $meta, 'name' );
unset( $meta['type'], $meta['name'] );

if ( isset( $meta['weight'] ) ) {
$meta['weight'] = absint( $meta['weight'] );
$meta['weight'] = $meta['weight'] > 0 ? $meta['weight'] : 100;
} else {
$meta['weight'] = 100;
}

make( Meta::class )->object( $term_id, 'term' )->with( $type, $name, $meta )->generate()->save();
}
}

Expand Down
13 changes: 12 additions & 1 deletion src/FakerPress/Module/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,18 @@ public function parse_request( $qty, $request = [] ) {
continue;
}

make( Meta::class )->object( $user_id, 'user' )->with( $meta['type'], $meta['name'], $meta )->generate()->save();
$type = get( $meta, 'type' );
$name = get( $meta, 'name' );
unset( $meta['type'], $meta['name'] );

if ( isset( $meta['weight'] ) ) {
$meta['weight'] = absint( $meta['weight'] );
$meta['weight'] = $meta['weight'] > 0 ? $meta['weight'] : 100;
} else {
$meta['weight'] = 100;
}

make( Meta::class )->object( $user_id, 'user' )->with( $type, $name, $meta )->generate()->save();
}
}
$results[] = $user_id;
Expand Down
2 changes: 1 addition & 1 deletion src/FakerPress/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Plugin {
*
* @var string
*/
public const VERSION = '0.6.5';
public const VERSION = '0.6.6';

/**
* @since 0.6.0
Expand Down
6 changes: 4 additions & 2 deletions src/FakerPress/Provider/WP_Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ private function meta_parse_separator( $separator ) {
* @return string|int
*/
public function meta_type_numbers( $number = [ 0, 9 ], $weight = 50 ) {
$number = array_values( array_map( 'absint', (array) $number ) );

// If the number is an array, then we assume it's a range.
if ( is_array( $number ) && count( $number ) > 1 ) {
$this->generator->numberBetween( ...$number );
if ( count( $number ) > 1 ) {
$number = $this->generator->numberBetween( ...$number );
}

return $this->generator->optional( $weight / 100, null )->randomElement( (array) $number );
Expand Down
14 changes: 7 additions & 7 deletions src/FakerPress/Provider/WP_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function first_name( ?string $first_name = null, array $gender = [ 'male'
* @return string|null
*/
public function last_name( ?string $last_name = null ): ?string {
return $last_name ?? $this->generator->lastName;
return $last_name ?? $this->generator->lastName();
}

/**
Expand All @@ -48,7 +48,7 @@ public function last_name( ?string $last_name = null ): ?string {
* @return string|null
*/
public function user_login( ?string $login = null ): ?string {
return $login ?? $this->generator->userName;
return $login ?? $this->generator->userName();
}

/**
Expand All @@ -62,7 +62,7 @@ public function user_login( ?string $login = null ): ?string {
* @return string|null
*/
public function user_nicename( ?string $nicename = null ): ?string {
return $nicename ?? $this->generator->userName;
return $nicename ?? $this->generator->userName();
}

/**
Expand All @@ -76,7 +76,7 @@ public function user_nicename( ?string $nicename = null ): ?string {
* @return string|null
*/
public function user_url( ?string $url = null ): ?string {
return $url ?? $this->generator->url;
return $url ?? $this->generator->url();
}

/**
Expand All @@ -90,7 +90,7 @@ public function user_url( ?string $url = null ): ?string {
* @return string|null
*/
public function user_email( ?string $email = null ): ?string {
return $email ?? $this->generator->safeEmail;
return $email ?? $this->generator->safeEmail();
}

/**
Expand Down Expand Up @@ -119,7 +119,7 @@ public function display_name( ?string $display_name = null, array $gender = [ 'm
* @return string|null
*/
public function nickname( ?string $nickname = null ): ?string {
return $nickname ?? $this->generator->userName;
return $nickname ?? $this->generator->userName();
}

/**
Expand Down Expand Up @@ -180,7 +180,7 @@ public function description( $html = true, $args = [] ): ?string {
*
* @return string
*/
public function role( array $role = [] ): string {
public function role( ?array $role = [] ): ?string {
return $this->generator->randomElement( $role ?? array_keys( get_editable_roles() ) );
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/readme.php

Large diffs are not rendered by default.

0 comments on commit c3072f5

Please sign in to comment.