这是WP插件中的一些代码。我对OOP还是很陌生,实际上我对函数参数中的\并不熟悉,它看起来像是在实例化一个类。有人愿意澄清一下吗?
public function customize_membership_plan_row_actions( $actions, \WP_Post $post ) {
global $typenow;
这是完整的功能参考。
/**
* Customizes membership plan row actions.
*
* @since 1.0.0
*
* @param array $actions array of post actions
* @param \WP_Post $post post object
* @return array
*/
public function customize_membership_plan_row_actions( $actions, \WP_Post $post ) {
global $typenow;
if ( 'wc_membership_plan' !== $typenow ) {
return $actions;
}
// add view as member action
$actions['view_as_member'] = '<a href="' . wp_nonce_url( admin_url( 'edit.php?post_type=wc_membership_plan&action=view_as_member&post=' . $post->ID ), 'wc-memberships-view-as-member-of_' . $post->ID ) . '" title="' . __( 'View site as a member of this plan', 'woocommerce-memberships' ) . '" rel="permalink">' .
__( 'View site as member', 'woocommerce-memberships' ) .
'</a>';
return $actions;
}