Pods: Pods overrides preview link for post updated message.

Created on 29 Mar 2017  ·  5Comments  ·  Source: pods-framework/pods

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.

Bug

All 5 comments

Hi @tuanmh
A PR is always welcome!

@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.

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?

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.

Best Regards,

Scott Kingsley Clark
Developer


E-mail: [email protected]
Website: http://scottkclark.com/
Phone: 214.233.4048

Google / iMessage: [email protected]

Skype: sc0ttkclark

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.

Was this page helpful?
0 / 5 - 0 ratings