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

Allow sites to change the "this article first appeared" text #74

Open
7 tasks
benlk opened this issue Feb 12, 2020 · 5 comments
Open
7 tasks

Allow sites to change the "this article first appeared" text #74

benlk opened this issue Feb 12, 2020 · 5 comments

Comments

@benlk
Copy link
Collaborator

benlk commented Feb 12, 2020

Requested in https://secure.helpscout.net/conversation/1016863827/4711/ :

Can we make this line (with all its %2$ses and HTML) editable by the site owner?

https://github.com/INN/republication-tracker-tool/blob/d256d725bded14cf4f9c8ec2fc6658ef977621fe/includes/shareable-content.php#L75-L81

The present text is:

This <a target="_blank" href="%1$s">article</a> first appeared on <a target="_blank" href="%2$s">%3$s</a> and is republished here under a Creative Commons license.

where:

  • %1$s is the original URL of the article being shared
  • %2$s is the site URL
  • %3$s is the site name

We'll need to:

  • add a field where people can change this text
  • explain what parts are necessary and what the various merge tags are
  • validate the input to make sure that it contains at least the %1$s merge tag and maybe 2 and 3
  • validate the input to make sure it's valid HTML
  • sanitize the input to remove unwanted HTML and unclosed tags
  • save the input text
  • output in the shareable content that text
@joshdarby
Copy link

Can we make this line (with all its %2$ses and HTML) editable by the site owner?

@MirandaEcho Do we need to make this line editable, or just replaceable? If we're just adding a text field that allows them to replace that text, I don't think we need to go through the hassle of all of the tags.

@benlk
Copy link
Collaborator Author

benlk commented Feb 12, 2020

How would we allow them to replace the text of the line without also requiring them to edit the HTML of the two a tags that are part of the line?

@joshdarby
Copy link

I may be a little confused, but here's how I imagined it (forgive the pseudo code)

if( ! empty( get_field(  'repub_attribution_statement' ) ) ) {
   $attribution_statement = get_field( 'repub_attribution_statement);
} else {
   $attribution_statement = sprintf( 
 	// translators: %1$s is a URL, %2$s is the site home URL, and %3$s is the site title. 
 	esc_html__( 'This <a target="_blank" href="%1$s">article</a> first appeared on <a target="_blank" href="%2$s">%3$s</a> and is republished here under a Creative Commons license.', 'republication-tracker-tool' ), 
 	get_permalink( $post ), 
 	home_url(), 
 	esc_html( get_bloginfo() ) 
 ); 
}

That way they're not editing the statement, they're just replacing the entire thing with their own custom statement.

@benlk
Copy link
Collaborator Author

benlk commented Feb 12, 2020

They'll lose the ability to link to the original article which is being shared, unless we wrap the whole thing as a link to the article being shared. Doing so removes the need for educating people about merge tags, and removes the need to validate them.

if ( ! empty( get_field(  'repub_attribution_statement' ) ) ) {
	$attribution_statement = sprintf(
		esc_html( '<a target="_blank" href=%1$s">%2$s</a>' ),
		get_permalin( $post ),
		get_field( 'repub_attribution_statement' )
	);
} else {
	$attribution_statement = sprintf( 
		// translators: %1$s is a URL, %2$s is the site home URL, and %3$s is the site title. 
		esc_html__( 'This <a target="_blank" href="%1$s">article</a> first appeared on <a target="_blank" href="%2$s">%3$s</a> and is republished here under a Creative Commons license.', 'republication-tracker-tool' ),
		get_permalink( $post ),
		home_url(),
		esc_html( get_bloginfo() )
	);
}

@jonahshai
Copy link

Hi! I see this issue is more than 3 years old. Just wanted to check if there's any active development on this or if the attribution line language can be changed somewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants