[英]Override arguments of public function in Wordpress
我正在嘗試修改公共函數的變量。 我正在使用Listify WordPress主題,並試圖覆蓋子主題中的變量。 這是函數:
public function user_contactmethods( $methods, $user ) {
$methods[ 'twitter' ] = __( 'Twitter URL', 'listify' );
$methods[ 'facebook' ] = __( 'Facebook URL', 'listify' );
$methods[ 'googleplus' ] = __( 'Google+ URL', 'listify' );
$methods[ 'pinterest' ] = __( 'Pinterest URL', 'listify' );
$methods[ 'linkedin' ] = __( 'LinkedIn URL', 'listify' );
$methods[ 'github' ] = __( 'GitHub URL', 'listify' );
return $methods;
}
我想將“ GitHub URL”更改為其他名稱,例如google.url。 是否可以不修改核心文件?
您可以使用過濾器-大致如下所示
add_filter( 'user_contactmethods', 'my_user_contactmethods', 11, 2 );
public function my_user_contactmethods( $methods, $user ) {
/**
* Modify $methods as you wish
*
*/
return $methods;
}
您應該將此代碼放在WordPress主題functions.php
文件中或單獨的插件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.