Skip to content

Commit

Permalink
Add support for WordPress.org favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjmead committed Sep 6, 2024
1 parent 137d7d6 commit 7bd8b9d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,11 @@ Default: `'UTC'`
The timezone for the site. Examples include `America/New_York`, `America/Denver`, and `Europe/Berlin`.

Take a look at the return value for `DateTimeZone::listIdentifiers()` to see supported timezones.

### Wordpress.org favorites username

Option: `wordpress_org_favorites_username`

Default: `null`

WordPress.org lets logged-in users favorite plugins and themes. You can provide your WordPress.org username here to have your favorites show up under the "Favorites" tab when adding a new plugin or theme.
4 changes: 4 additions & 0 deletions app/Commands/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ public function handle()
$site->execute_alt('Setting timezone...', 'wp option update timezone_string ' . $template->get_timezone(), []);
}

if (is_string($template->get_wordpress_org_favorites_username())) {
$site->execute_alt('Setting WordPress.org favorites username...', 'wp user meta add 1 wporg_favorites ' . $template->get_wordpress_org_favorites_username(), []);
}

if ($template->enable_automatic_login()) {
info('Enabling automatic login...');
try {
Expand Down
2 changes: 2 additions & 0 deletions app/Domain/ConfigTypes/Defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public function __construct(
public readonly ?bool $enable_multisite = null,
/** @var ?string */
public readonly ?string $timezone = null,
/** @var ?string */
public readonly ?string $wordpress_org_favorites_username = null,
) {
if(is_string($this->timezone) && !in_array($this->timezone, DateTimeZone::listIdentifiers())) {
throw new Error("Invalid timezone \"{$this->timezone}\" in config file");
Expand Down
14 changes: 14 additions & 0 deletions app/Domain/ConfigTypes/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function __construct(
public readonly ?bool $enable_multisite = null,
/** @var ?string */
public readonly ?string $timezone = null,
/** @var ?string */
public readonly ?string $wordpress_org_favorites_username = null,
) {
$this->defaults = new Defaults;

Expand Down Expand Up @@ -269,4 +271,16 @@ public function get_timezone(): ?string {

return null;
}

public function get_wordpress_org_favorites_username(): ?string {
if (is_string($this->wordpress_org_favorites_username)) {
return $this->wordpress_org_favorites_username;
}

if (is_string($this->defaults->wordpress_org_favorites_username)) {
return $this->defaults->wordpress_org_favorites_username;
}

return null;
}
}
Binary file modified builds/wpsites
Binary file not shown.

0 comments on commit 7bd8b9d

Please sign in to comment.