テーマフォルダのfunctions.php内のプラグイン関数をオーバーライドする方法は?テーマのfunctions.phpのプラグイン関数をオーバーライドする方法Wordpress
EDIT:以下
私のコードです:
if(!function_exists('userphoto_filter_get_avatar')){
function userphoto_filter_get_avatar($avatar, $id_or_email, $size, $default){
global $userphoto_using_avatar_fallback, $wpdb, $userphoto_prevent_override_avatar;
if($userphoto_using_avatar_fallback)
return $avatar;
if(is_object($id_or_email)){
if($id_or_email->ID)
$id_or_email = $id_or_email->ID;
//Comment
else if($id_or_email->user_id)
$id_or_email = $id_or_email->user_id;
else if($id_or_email->comment_author_email)
$id_or_email = $id_or_email->comment_author_email;
}
if(is_numeric($id_or_email))
$userid = (int)$id_or_email;
else if(is_string($id_or_email))
$userid = (int)$wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_email = '" . mysql_escape_string($id_or_email) . "'");
if(!$userid)
return $avatar;
//Figure out which one is closest to the size that we have for the full or the thumbnail
$full_dimension = get_option('userphoto_maximum_dimension');
$small_dimension = get_option('userphoto_thumb_dimension');
$userphoto_prevent_override_avatar = true;
$img = userphoto__get_userphoto($userid, (abs($full_dimension - $size) < abs($small_dimension - $size)) ? USERPHOTO_FULL_SIZE : USERPHOTO_THUMBNAIL_SIZE, '', '', array(), '');
$userphoto_prevent_override_avatar = false;
if($img)
return $img;
return $avatar;
}
}
と私はプラグインをアクティブにしたとき、それは私に致命的なエラーを与えている:
Cannot redeclare
userphoto_filter_get_avatar()
.
私が間違っているのかを説明してください。
[Pluggable_Functions](https://codex.wordpress.org/Pluggable_Functions)をご覧ください。 –
上記のコードをどこに追加しましたか?プラグインファイルとテーマfunctions.phpファイルの両方からコードを共有します。 –