php - 有人可以在这里解释一下语法吗
问题描述
这是来自 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;
}
解决方案
推荐阅读
- angular - Angular HttpClient 获取请求 URL 删除主题标签/数字符号
- google-analytics - 并非所有尺寸都可用
- ubuntu-18.04 - 无法使用 gnome builder 构建“polari”一个 gnome 应用程序
- keycloak - 如何解决我的 angular7 项目中的 keycloak refresh /#state - 我正在使用 keycloak-angular
- firebase - 为什么我的数组是 NaN 而我无法从 Firebase 数据库中获取价值?
- sass - SASS 用注释编译
- c# - 在 datagridview 中加载大量数据的性能问题
- swift - 调用 Optional Double 上的方法以转换为 String
- c# - 当服务器没有响应时,HttpClient 请求永远不会结束(带有网络链接调节器的 iOS 设备 - 100% 丢失)
- python - 如何在每一行上提取列表的特定部分?