コード例 #1
0
function evc_auth_user_authorize($user_vk_id)
{
    $user_wp_id = evc_get_wpid_by_vkid($user_vk_id, 'user');
    if (!$user_wp_id) {
        $user_vk_data = evc_vkapi_get_users(array('user_ids' => $user_vk_id));
        if (!$user_vk_data || !isset($user_vk_data[0])) {
            return false;
        }
        $user_wp_id = evc_add_user($user_vk_data[0]);
    } else {
        $user_wp_id = $user_wp_id[$user_vk_id];
    }
    if (!$user_wp_id) {
        return false;
    }
    wp_set_auth_cookie($user_wp_id, true);
    evc_refresh_vk_img_all();
    return $user_wp_id;
}
コード例 #2
0
ファイル: evc-api.php プロジェクト: prosenjit-itobuz/upages
 function evc_refresh_vk_img_js()
 {
     $r = evc_refresh_vk_img_all();
     if (isset($r['error'])) {
         $out['error'] = 'Error';
     } else {
         $out = $r;
     }
     print json_encode($out);
     exit;
 }
コード例 #3
0
function evc_comments_refresh_comments()
{
    $evc_comments_refresh = get_transient('evc_comments_refresh');
    $options = evc_get_all_options(array('evc_vk_api_widgets', 'evc_comments', 'evc_comments_pro'));
    if (!empty($_POST)) {
        extract($_POST);
    }
    //$out = print_r($_POST, 1);
    //print json_encode($out);
    //exit();
    $options['comments_pro_count'] = !isset($options['comments_pro_count']) ? 10 : $options['comments_pro_count'];
    $args = array('widget_api_id' => $widget_api_id, 'url' => $url, 'count' => $options['comments_pro_count']);
    if (isset($page_id)) {
        $args['page_id'] = $page_id;
        $post_id = $page_id;
        // Be Careful!!!
    }
    if (!isset($post_id) || !$post_id) {
        return false;
    }
    if (isset($evc_comments_refresh) && $evc_comments_refresh) {
        return false;
    }
    set_transient('evc_comments_refresh', sprintf('%.22F', microtime(true)));
    $comments = evc_comments_get_comments($args);
    delete_transient('evc_comments_refresh');
    if (!$comments || !$comments['count']) {
        return false;
    }
    // Add new Comments
    foreach ($comments['posts'] as $comment) {
        unset($comment_wp_id);
        $comment_wp_id = evc_comments_add_comment($comment, $post_id, $widget_api_id);
        //print__r($comment_wp_id);
        if (isset($comment['comments'])) {
            foreach ($comment['comments']['replies'] as $reply) {
                $reply_wp_id = evc_comments_add_comment($reply, $post_id, $widget_api_id, $comment_wp_id);
            }
        }
    }
    //return true;
    evc_refresh_vk_img_all();
    print json_encode($comments['count']);
    exit;
}