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

Pods overrides preview link for post updated message. #4092

Closed
tuanmh opened this issue Mar 29, 2017 · 5 comments
Closed

Pods overrides preview link for post updated message. #4092

tuanmh opened this issue Mar 29, 2017 · 5 comments
Assignees
Milestone

Comments

@tuanmh
Copy link
Contributor

tuanmh commented Mar 29, 2017

Hi there,

We've discovered that Pods overrides the preview link for post updated message:

So in this, WordPress uses preview link as intended:
https://github.com/WordPress/WordPress/blob/master/wp-admin/edit-form-advanced.php#L147

$messages['post'] = array(
	 0 => '', // Unused. Messages start at index 1.
	 1 => __( 'Post updated.' ) . $view_post_link_html,
	 2 => __( 'Custom field updated.' ),
	 3 => __( 'Custom field deleted.' ),
	 4 => __( 'Post updated.' ),
	/* translators: %s: date and time of the revision */
	 5 => isset($_GET['revision']) ? sprintf( __( 'Post restored to revision from %s.' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
	 6 => __( 'Post published.' ) . $view_post_link_html,
	 7 => __( 'Post saved.' ),
	 8 => __( 'Post submitted.' ) . $preview_post_link_html,
	 9 => sprintf( __( 'Post scheduled for: %s.' ), '<strong>' . $scheduled_date . '</strong>' ) . $scheduled_post_link_html,
	10 => __( 'Post draft updated.' ) . $preview_post_link_html,
);

However, in this, Pods uses permalink with preview parameter instead:
https://github.com/pods-framework/pods/blob/2.x/classes/PodsInit.php#L911

$messages[ $post_type['name'] ] = array(
    1  => sprintf( __( '%s updated. <a href="%s">%s</a>', 'pods' ), $labels['singular_name'], esc_url( get_permalink( $post_ID ) ), $labels['view_item'] ),
    2  => __( 'Custom field updated.', 'pods' ),
    3  => __( 'Custom field deleted.', 'pods' ),
    4  => sprintf( __( '%s updated.', 'pods' ), $labels['singular_name'] ),
/* translators: %s: date and time of the revision */
    5  => isset( $_GET['revision'] ) ? sprintf( __( '%s restored to revision from %s', 'pods' ), $labels['singular_name'], wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
    6  => sprintf( __( '%s published. <a href="%s">%s</a>', 'pods' ), $labels['singular_name'], esc_url( get_permalink( $post_ID ) ), $labels['view_item'] ),
    7  => sprintf( __( '%s saved.', 'pods' ), $labels['singular_name'] ),
    8  => sprintf( __( '%s submitted. <a target="_blank" href="%s">Preview %s</a>', 'pods' ), $labels['singular_name'], esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ), $labels['singular_name'] ),
    9  => sprintf( __( '%s scheduled for: <strong>%s</strong>. <a target="_blank" href="%s">Preview %s</a>', 'pods' ), $labels['singular_name'], // translators: Publish box date format, see http://php.net/date
					date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink( $post_ID ) ), $labels['singular_name'] ),
    10 => sprintf( __( '%s draft updated. <a target="_blank" href="%s">Preview %s</a>', 'pods' ), $labels['singular_name'], esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ), $labels['singular_name'] )
);

Although Pods adds preview=true to simulate a preview link, but would it be best to use get_preview_post_link( $post->ID ) to cover the case where people have different preview link structures and they use filter under get_preview_post_link to create the structure as they wanted.

I'm more than happy to submit a PR for this and it would be simple.

tuanmh added a commit to tuanmh/pods that referenced this issue Mar 29, 2017
@JoryHogeveen
Copy link
Member

JoryHogeveen commented Mar 29, 2017

Hi @tuanmh
A PR is always welcome!

@JoryHogeveen JoryHogeveen added this to the Pods 2.6.8.1 milestone Mar 29, 2017
@JoryHogeveen
Copy link
Member

@tuanmh
get_preview_post_link() is WP 4.4+.
https://developer.wordpress.org/reference/functions/get_preview_post_link/

Pods readme currently states WP 3.8+ so this wouldn't be compatible.

@tuanmh
Copy link
Contributor Author

tuanmh commented Mar 29, 2017

Oh, thanks for point out @JoryHogeveen. The way Pods handles this at the moment is exactly in Wordpress 3.8 and there is no filter for preview link so my hands are tied unless you'd be happy to introduce a filter in this?

@sc0ttkclark
Copy link
Member

sc0ttkclark commented Mar 29, 2017 via email

tuanmh added a commit to tuanmh/pods that referenced this issue Mar 29, 2017
tuanmh added a commit to tuanmh/pods that referenced this issue Mar 29, 2017
@tuanmh
Copy link
Contributor Author

tuanmh commented Mar 29, 2017

I am cool with a version check and if it's 4.4 then use the new code. Very
soon we'll be able to let go of some of the older version support.

Cool, I've updated the PR @JoryHogeveen.

tuanmh added a commit to tuanmh/pods that referenced this issue Apr 3, 2017
@ghost ghost assigned sc0ttkclark Apr 6, 2017
@ghost ghost added the Status: In Progress Issue or PR is currently in progress but not yet done label Apr 6, 2017
sc0ttkclark added a commit that referenced this issue Apr 6, 2017
Fixed #4092: build proper preview link for post updated message.
sc0ttkclark pushed a commit that referenced this issue May 10, 2017
sc0ttkclark pushed a commit that referenced this issue May 10, 2017
@ghost ghost removed the Status: In Progress Issue or PR is currently in progress but not yet done label May 10, 2017
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