-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
|
||
/** | ||
* 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(); | ||
} | ||
); | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
There was a problem hiding this 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.
|
||
/** | ||
* 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(); | ||
} | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
40305f7
to
bd28dea
Compare
bd28dea
to
8e3ba43
Compare
8e3ba43
to
ce29d97
Compare
Summary
This changes the theme to the goodbid child theme when a new site is created.
Issues
Testing Instructions
Screenshots
cc @ten1seven for review