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
Add new utility function #1739
Add new utility function #1739
Conversation
Add function to see if we are on the home of events similar to is_home in WordPress. Ticket: https://central.tri.be/issues/42195
As on the file majority of instances uses 'bool' in the return statment it might be a good idea to be consistent.
* Utility function to test if we are on the home of events, it makes test the case when the page is set to be on | ||
* the frontpage of the site and if the user is on that page is on the homepage or if the user is on the events page | ||
* where the eventDisplay is set to default. | ||
* |
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.
add @since
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.
Thanks, changes has been updated.
This new Utility function allow to test if we are on the front page of the events page as sometimes tribe_is_events_home is not enought and and both can be used in different locations such as #1748.
|
||
/** | ||
* Function to test if we are on the front page of the events, as WordPress language front page is different from | ||
* is_home, if we have a front page on the reading options and if the uzer is on that page, this function will |
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.
* User
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.
Thanks.
@@ -1669,4 +1669,60 @@ function tribe_separated_field( $body, $separator, $field ) { | |||
|
|||
return $field ? $body_and_separator . $field : $body; | |||
} | |||
|
|||
/** | |||
* Function to test if we are on the front page of the events, as WordPress language front page is different from |
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.
This is good - but sometimes the information is easier to digest if we start with a nice and short sentence explaining very briefly what the function does - with any further explanations, notes or examples into additional paragraphs. For instance:
/**
* Tests if we are on the site homepage and if it is set to display the main events page.
*
* <notes about the differences with WordPress's definition of front page, examples of
* real usage etc>
*
* @since TBD
*
* @return bool
*/
Note also the line break between 'meta' information such as @since
and the @return
tag.
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.
Thanks for the heads up.
@mitogh - I like these functions but there's a possible bear-trap we ought to warn users of: if code within an events template calls We should also add a changelog entry noting the addition of these new template tags. |
Thanks for the feedback @barryhughes. However I'm not really sure about the changelog. just a couple of questions there:
Thanks. |
Yes 👍
The date should generally be TBD at this stage, but the new version number can be found at the top of the readme file (though, if in doubt, TBD is fine for this, too). In this case, you can add your entry within this block. |
Changes has been added diff is not able to pick the changes, on the missing changes. |
👍 |
Diff is not correct changes has been introduced correctly.
Add
tribe_is_home_events
function similar tois_home
in WP to test if we are on the homepage of the events.See Ticket: https://central.tri.be/issues/42195