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

✨ No profiles template if no plugin #277

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions inc/profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,18 @@ function after_setup_theme() {
add_image_size( 'responsive_profile_large', $width, $height, $crop );
}
add_action( 'after_setup_theme', __NAMESPACE__ . '\after_setup_theme' );

if ( ! defined( 'BU_PROFILES_PLUGIN_ACTIVE' ) || ! BU_PROFILES_PLUGIN_ACTIVE ) {
/**
* Removes the profile template if BU profiles is not active.
*
* @param array $page_templates list of registered page templates.
* @return array $page_templates list of registered page templates.
*/
function remove_profile_template( $page_templates ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

While it is legal to define a function inside an IF statement, I'd recommend moving the function declaration outside of the IF statement for clarity and consistency.

unset( $page_templates['profiles.php'] );

return $page_templates;
}
add_filter( 'theme_page_templates', __NAMESPACE__ . '\remove_profile_template' );
}