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
merged 2 commits into from Sep 13, 2016

Conversation

Projects
None yet
3 participants
@akirk
Contributor

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

@ocean90 ocean90 removed the ready for merge label Sep 4, 2016

@ocean90

This comment has been minimized.

Show comment
Hide comment
@ocean90

ocean90 Sep 4, 2016

Member

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

Member

ocean90 commented Sep 4, 2016

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

@akirk

This comment has been minimized.

Show comment
Hide comment
@akirk

akirk Sep 8, 2016

Contributor

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

Contributor

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.

Show outdated Hide outdated gp-includes/things/project.php
* @param string $file The referenced file name.
* @param string $line The line number in the referenced file.
*
* @return string|false

This comment has been minimized.

@ocean90

ocean90 Sep 8, 2016

Member

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

@ocean90

ocean90 Sep 8, 2016

Member

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

Show outdated Hide outdated gp-includes/things/project.php
* @param string $source_url The originally generated source URL.
* @param GP_Project $project The current project.
* @param string $file The referenced file name.
* @param string $line The line number in the referenced file.

This comment has been minimized.

@ocean90

ocean90 Sep 8, 2016

Member

There should be only one space between GP_Project and $project. Same for $source_url and its descriptions. The other parameters should be aligned accordingly.

$source_url can be false too:
@param string|false $source_url The originally generated source URL, or false if no URL is available.

@ocean90

ocean90 Sep 8, 2016

Member

There should be only one space between GP_Project and $project. Same for $source_url and its descriptions. The other parameters should be aligned accordingly.

$source_url can be false too:
@param string|false $source_url The originally generated source URL, or false if no URL is available.

@ocean90 ocean90 merged commit b895ce0 into GlotPress:develop Sep 13, 2016

1 of 2 checks passed

codecov/project 35.64% (-0.01%) compared to e06e768
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment