-
Notifications
You must be signed in to change notification settings - Fork 132
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
Refactor for the fix_post_row_actions function #442
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1602,7 +1602,7 @@ function fix_get_sample_permalink_html( $return, $post_id, $new_title, $new_slug | |
* | ||
* @since 0.8 | ||
*/ | ||
private function get_preview_link( $post ) { | ||
static function get_preview_link( $post ) { | ||
|
||
if ( 'page' == $post->post_type ) { | ||
$args = array( | ||
|
@@ -1646,22 +1646,7 @@ public function fix_post_row_actions( $actions, $post ) { | |
if ( empty( $actions['view'] ) ) | ||
return $actions; | ||
|
||
if ( 'page' == $post->post_type ) { | ||
$args = array( | ||
'page_id' => $post->ID, | ||
); | ||
} else if ( 'post' == $post->post_type ) { | ||
$args = array( | ||
'p' => $post->ID, | ||
); | ||
} else { | ||
$args = array( | ||
'p' => $post->ID, | ||
'post_type' => $post->post_type, | ||
); | ||
} | ||
$args['preview'] = 'true'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we preserve the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think that it's a good idea. I thought that I already let this arg to |
||
$preview_link = add_query_arg( $args, home_url() ); | ||
$preview_link = $this->get_preview_link($post); | ||
|
||
$actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $post->post_title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; | ||
return $actions; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that the visibility declaration of methods in this file is not uniform, but we, imho, should follow the best practices declared in the WordPress coding standards project, specifically the WordPress-Extra ruleset, which sets up best practices beyond the core WordPress coding standards.
And thus, the
public
visibility declaration should be used here. It would also help to highlight the change, as this method becomes public by removing theprivate
visibility.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review!
I checked the WordPress Coding Standards and I can see that the
Methods: Verify that all methods have visibility declared
. Does this mean that I should usepublic function get_preview_link( $post )
instead of
function get_preview_link( $post )
am I right? I just want to make sure that I follow the Coding Standards and write this the right way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right.
public static function get_preview_link( $post )
to be exact.