Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate Child theme #60

Merged
merged 3 commits into from
Dec 13, 2023
Merged

Conversation

nathan-schmidt-viget
Copy link
Contributor

@nathan-schmidt-viget nathan-schmidt-viget commented Dec 8, 2023

Summary

This changes the theme to the goodbid child theme when a new site is created.

Issues

Testing Instructions

  • Create a new site by going to Network Admin -> Sites.
  • Click on Add New Site and fill out the info.
  • Once the new site is created, go to the newly created site dashboard click on Appearance -> Themes
  • Make sure that GoodBids Non-profit is the active theme.

Screenshots

Screenshot 2023-12-08 at 10 15 19 AM

cc @ten1seven for review

Comment on lines 345 to 376

/**
* Activate nonprofit child theme.
*
* @since 1.0.0
*
* @param int $site_id Site ID.
*
* @return void
*/
private function activate_child_theme(): void {
add_action(
'wpmu_new_blog',
function ( $site_id ) {
$stylesheet = 'goodbids-nonprofit';

// Switch to the new site
switch_to_blog( $site_id );

// Check if we the Goodbids child theme exists
if ( ! wp_get_theme( $stylesheet )->exists() ) {
return;
}
switch_theme( $stylesheet );

restore_current_blog();
}
);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bd-viget this seems like the right location in the plugin, but I may be wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

Copy link
Contributor

@bd-viget bd-viget left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very nice work! Thanks for doing this! Just a few suggestions and a note to revert some phpcbf stuff until we can get on the same standards in both our IDEs.

client-mu-plugins/goodbids/src/classes/Core.php Outdated Show resolved Hide resolved
client-mu-plugins/goodbids/src/classes/network/Sites.php Outdated Show resolved Hide resolved
client-mu-plugins/goodbids/src/classes/network/Sites.php Outdated Show resolved Hide resolved
Comment on lines 345 to 376

/**
* Activate nonprofit child theme.
*
* @since 1.0.0
*
* @param int $site_id Site ID.
*
* @return void
*/
private function activate_child_theme(): void {
add_action(
'wpmu_new_blog',
function ( $site_id ) {
$stylesheet = 'goodbids-nonprofit';

// Switch to the new site
switch_to_blog( $site_id );

// Check if we the Goodbids child theme exists
if ( ! wp_get_theme( $stylesheet )->exists() ) {
return;
}
switch_theme( $stylesheet );

restore_current_blog();
}
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

client-mu-plugins/goodbids/src/classes/network/Sites.php Outdated Show resolved Hide resolved
client-mu-plugins/goodbids/src/classes/network/Sites.php Outdated Show resolved Hide resolved
@nathan-schmidt-viget nathan-schmidt-viget force-pushed the ns/15-activate-child-theme branch 4 times, most recently from 40305f7 to bd28dea Compare December 11, 2023 15:37
@nathan-schmidt-viget nathan-schmidt-viget merged commit d2112db into main Dec 13, 2023
1 check passed
@nathan-schmidt-viget nathan-schmidt-viget deleted the ns/15-activate-child-theme branch December 13, 2023 01:43
nathan-schmidt-viget added a commit that referenced this pull request Dec 13, 2023
* [#15] setting the child theme when a new site is created
* Readme update for phpcs
* [#15] updating PR format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants