function jd_check_functions()
{
    $message = "<div class='update'><ul>";
    // grab or set necessary variables
    $testurl = get_bloginfo('url');
    $shortener = get_option('jd_shortener');
    $title = urlencode('Your blog home');
    $shrink = jd_shorten_link($testurl, $title, false, 'true');
    $api_url = $jdwp_api_post_status;
    $yourls_URL = "";
    if ($shrink == FALSE) {
        if ($shortener == 1) {
            $error = htmlentities(get_option('wp_supr_error'));
        } else {
            if ($shortener == 2) {
                $error = htmlentities(get_option('wp_bitly_error'));
            } else {
                $error = _('No error information is available for your shortener.', 'wp-to-twitter');
            }
        }
        $message .= __("<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>", 'wp-to-twitter');
        $message .= "<li><code>{$error}</code></li>";
    } else {
        $message .= __("<li><strong>WP to Twitter successfully contacted your selected URL shortening service.</strong>  The following link should point to your blog homepage:", 'wp-to-twitter');
        $message .= " <a href='{$shrink}'>{$shrink}</a></li>";
    }
    //check twitter credentials
    if (wtt_oauth_test()) {
        $rand = rand(1000000, 9999999);
        $testpost = jd_doTwitterAPIPost("This is a test of WP to Twitter. {$shrink} ({$rand})");
        if ($testpost) {
            $message .= __("<li><strong>WP to Twitter successfully submitted a status update to Twitter.</strong></li>", 'wp-to-twitter');
        } else {
            $error = get_option('jd_status_message');
            $message .= __("<li class=\"error\"><strong>WP to Twitter failed to submit an update to Twitter.</strong></li>", 'wp-to-twitter');
            $message .= "<li class=\"error\">{$error}</li>";
        }
    } else {
        $message .= "<strong>" . _e('You have not connected WordPress to Twitter.', 'wp-to-twitter') . "</strong> ";
    }
    // If everything's OK, there's  no reason to do this again.
    if ($testpost == FALSE && $shrink == FALSE) {
        $message .= __("<li class=\"error\"><strong>Your server does not appear to support the required methods for WP to Twitter to function.</strong> You can try it anyway - these tests aren't perfect.</li>", 'wp-to-twitter');
    } else {
    }
    if ($testpost && $shrink) {
        $message .= __("<li><strong>Your server should run WP to Twitter successfully.</strong></li>", 'wp-to-twitter');
    }
    $message .= "</ul>\r\n\t</div>";
    return $message;
}
Exemplo n.º 2
0
function jd_twit_comment($comment_id, $approved)
{
    $_t = get_comment($comment_id);
    $post_ID = $_t->comment_post_ID;
    $commenter = $_t->comment_author;
    $jd_tweet_this = get_post_meta($post_ID, '_jd_tweet_this', TRUE);
    if ($jd_tweet_this != 'no' && $_t->comment_approved == 1) {
        // comments only tweeted on posts which are tweeted
        $post_info = jd_post_info($post_ID);
        $sentence = '';
        $sentence = stripcslashes(get_option('comment-published-text'));
        if ($post_info['shortUrl'] != '') {
            $shrink = $post_info['shortUrl'];
        } else {
            $shrink = jd_shorten_link($post_info['postLink'], $post_info['postTitle'], $post_ID);
            store_url($post_ID, $shrink);
        }
        $sentence = jd_truncate_tweet($sentence, $post_info, $shrink, $post_ID);
        $sentence = str_replace("#commenter#", $commenter, $sentence);
        if ($sentence != '') {
            $sendToTwitter = jd_doTwitterAPIPost($sentence);
        }
    }
    return $post_ID;
}