Wordpress - 功能无法正常关闭

时间:2016-01-07 20:53:09

标签: php wordpress

所以我有一个我想在wordpress网站上使用的功能。我正在尝试将其添加到PHP文件中,但在我的编辑器中突出显示语法似乎表明它没有正确打开和关闭...

这就是我想要使用的:

function friends_get_list($tmp_uid, $friend_status=1) {

    global $wpdb;

    $friend_status = intval($friend_status);
    if (($friend_status != 1) && ($friend_status != 0))
    $friend_status = 1;

    if ( $friends_list = get_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status ) ) {
    return $friends_list;
    }

    $query = $wpdb->prepare("SELECT friend_user_ID FROM " . $wpdb->base_prefix . "friends WHERE user_ID = %d AND friend_approved = %d",
    $tmp_uid, $friend_status);
    //echo "query=[". $query ."]
    ";
    $friends_list = $wpdb->get_col($query);
    set_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status, $friends_list, 60 );

    return $friends_list;
    }

但该功能似乎没有正确关闭。有什么帮助吗?

1 个答案:

答案 0 :(得分:1)

function friends_get_list($tmp_uid, $friend_status=1)
{
    global $wpdb;

    $friend_status = intval($friend_status);
    if (($friend_status != 1) && ($friend_status != 0))
    $friend_status = 1;

    if ( $friends_list = get_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status ) ) {
    return $friends_list;
    }

    $query = $wpdb->prepare("SELECT friend_user_ID FROM " . $wpdb->base_prefix . "friends WHERE user_ID = %d AND friend_approved = %d",
    $tmp_uid, $friend_status);
    //echo "query=[". $query ."]
    "; // <-loose double-quote
    $friends_list = $wpdb->get_col($query);
    set_transient( 'wpmudev-friends-'. $tmp_uid .'-'. $friend_status, $friends_list, 60 );

    return $friends_list;
}

第16行有一个松散的双引号。我在上面添加了评论。