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

Updated the example file with examples for different include situations. #503

Merged
merged 1 commit into from
Jan 5, 2016

Conversation

jrfnl
Copy link
Contributor

@jrfnl jrfnl commented Jan 4, 2016

Fixes #469.

@jrfnl jrfnl assigned jrfnl and GaryJones and unassigned jrfnl Jan 4, 2016
@GaryJones GaryJones added this to the 2.6.0 milestone Jan 5, 2016
* Depending on your implementation, you may want to change the include call:
*
* Parent Theme:
* require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php';
Copy link
Member

Choose a reason for hiding this comment

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

No need for this - parent themes can call get_stylesheet_directory() too, since template dir = stylesheet dir in parent themes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, however, not applicable in this case.

If no child theme is being loaded, the get_stylesheet_directory() would be fine as WP will detect that there is no child theme and return the parent theme directory.

If a parent theme uses TGMPA and a child theme of that parent is the loaded theme, things would go very wrong with the include call. This is not a url/path which is being passed to a get_template_part() call, after all, but a hard file include.

To demonstrate, take this example set up:

/wp-content/themes/
    - /parent-theme
        - /vendor/tgmpa/tgm-plugin-activation.php
    - /child-theme
        - does not include tgmpa

The get_template_directory() function would return /path/to/wp-content/themes/parent-theme.
The get_stylesheet_directory() function would return /path/to/wp-content/themes/child-theme.

If the parent theme would include the file using get_stylesheet_directory(), this would result in a fatal file not found error.

GaryJones added a commit that referenced this pull request Jan 5, 2016
Updated the example file with examples for different include situations.
@GaryJones GaryJones merged commit 01212ae into develop Jan 5, 2016
@GaryJones GaryJones deleted the feature/issue-469 branch January 5, 2016 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants