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

Add ability to filter the source URL in the references #522

merged 2 commits into from Sep 13, 2016


Copy link

@akirk akirk commented Aug 8, 2016

This allows to create a filter that modifies the URLs for the files listed under References.

Example usage:

add_filter( 'gp_reference_source_url', function( $source_url, $project, $file, $line ) {
// Libraries don't reside in our repo but we have them translatable through GlotPress.
if ( preg_match( '#^lib/#', $file ) ) {
     return false; 
return $source_url;
}, 10, 4 );

Possible uses:

  • for projects that include strings from different sources
  • for only partially linkable source texts

This fixes a TODO source line.

I have already used @since 2.2.0 for the docs but this can of course be changed depending on which version this lands with.

@toolstack toolstack added this to the 2.2 milestone Aug 8, 2016
Copy link

ocean90 commented Sep 4, 2016

Why is the filter in the template and not in GP_Project::source_url()?

@akirk akirk force-pushed the filter/reference_source_url branch 2 times, most recently from 87d74c8 to 94105f7 Compare Sep 8, 2016
Copy link
Member Author

akirk commented Sep 8, 2016

@ocean90 Fair point. I've moved it. I didn't think much to put it somewhere else because of the TODO comment.

@akirk akirk force-pushed the filter/reference_source_url branch 2 times, most recently from 459dd45 to 4187974 Compare Sep 8, 2016
@akirk akirk force-pushed the filter/reference_source_url branch from 4187974 to 2abd269 Compare Sep 8, 2016
* @param string $file The referenced file name.
* @param string $line The line number in the referenced file.
* @return string|false
Copy link

@ocean90 ocean90 Sep 8, 2016

Choose a reason for hiding this comment

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

We don't use @return tags for hook docs.

@ocean90 ocean90 merged commit b895ce0 into GlotPress:develop Sep 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

3 participants