Exemple #1
0
function mystique_list_comments($comment, $args, $depth)
{
    $GLOBALS['comment'] = $comment;
    global $commentcount;
    if (!$commentcount) {
        $commentcount = 0;
    }
    ?>

  <!-- comment entry -->
  <li class="<?php 
    mystique_comment_class();
    ?>
" id="comment-<?php 
    comment_ID();
    ?>
">
    <div class="comment-head <?php 
    mystique_comment_class();
    ?>
">

      <?php 
    if (get_option('show_avatars')) {
        ?>
<div class="avatar-box"><?php 
        echo mystique_get_avatar($comment->comment_author_email, 48);
        ?>
</div><?php 
    }
    ?>
      <div class="author">
       <?php 
    if (get_comment_author_url()) {
        $authorlink = '<a class="comment-author" id="comment-author-' . get_comment_ID() . '" href="' . get_comment_author_url() . '" rel="nofollow">' . get_comment_author() . '</a>';
    } else {
        $authorlink = '<b class="comment-author" id="comment-author-' . get_comment_ID() . '">' . get_comment_author() . '</b>';
    }
    $authorlink = apply_filters("mystique_comment_author_link", $authorlink);
    ?>

        <span class="by"><?php 
    printf(__('%1$s written by %2$s', 'mystique'), '<a class="comment-id" href="#comment-' . get_comment_ID() . '">#' . ++$commentcount . '</a>', $authorlink);
    ?>
 </span>
        <br />
        <?php 
    echo mystique_timeSince(abs(strtotime($comment->comment_date . " GMT")));
    ?>
      </div>

      <div class="controls bubble">
        <?php 
    if (get_mystique_option('jquery') && comments_open()) {
        ?>
           <?php 
        if (get_option('thread_comments')) {
            ?>
           <a class="reply" id="reply-to-<?php 
            echo get_comment_ID();
            ?>
" href="<?php 
            echo esc_url(add_query_arg('replytocom', $comment->comment_ID));
            ?>
#respond"><?php 
            _e("Reply", "mystique");
            ?>
</a>
           <?php 
        }
        ?>
           <a class="quote" title="<?php 
        _e('Quote', 'mystique');
        ?>
" href="#respond"><?php 
        _e('Quote', 'mystique');
        ?>
</a>
        <?php 
    }
    ?>
        <?php 
    edit_comment_link('Edit', '', '');
    ?>
      </div>
    </div>
    <div class="comment-body clear-block" id="comment-body-<?php 
    comment_ID();
    ?>
">
      <?php 
    if ($comment->comment_approved == '0') {
        ?>
<p class="error"><?php 
        _e('Your comment is awaiting moderation.', 'mystique');
        ?>
</p><?php 
    }
    ?>
      <div class="comment-text"><?php 
    comment_text();
    ?>
</div>
      <a id="comment-reply-<?php 
    comment_ID();
    ?>
"></a>
    </div>
<?php 
}
Exemple #2
0
function display_twitter_data($id, $twituser, $twitcount, $twitdata = false)
{
    $error = false;
    if (!$twitdata) {
        if (false === ($twitdata = get_transient('mystique_twitter_' . $id))) {
            require_once ABSPATH . 'wp-includes/class-snoopy.php';
            $snoopy = new Snoopy();
            $response = @$snoopy->fetch("http://twitter.com/users/show/" . $twituser . ".json");
            if ($response) {
                $userdata = json_decode($snoopy->results, true);
            } else {
                $error = true;
            }
            $response = @$snoopy->fetch("http://twitter.com/statuses/user_timeline/" . $twituser . ".json");
            if ($response) {
                $tweets = json_decode($snoopy->results, true);
            } else {
                $error = true;
            }
            if (!$error) {
                // for php < 5 (included JSON returns object)
                $userdata = mystique_objectToArray($userdata);
                $tweets = mystique_objectToArray($tweets);
                $twitdata = array();
                $twitdata['user']['profile_image_url'] = $userdata['profile_image_url'];
                $twitdata['user']['name'] = $userdata['name'];
                $twitdata['user']['screen_name'] = $userdata['screen_name'];
                $twitdata['user']['followers_count'] = $userdata['followers_count'];
                $i = 0;
                foreach ($tweets as $tweet) {
                    $twitdata['tweets'][$i]['text'] = $tweet['text'];
                    $twitdata['tweets'][$i]['created_at'] = $tweet['created_at'];
                    $twitdata['tweets'][$i]['id'] = $tweet['id'];
                    $i++;
                }
                set_transient('mystique_twitter_' . $id, $twitdata, 60);
                // keep the data cached 60 seconds
            }
        }
    }
    // only show if the twitter data from the database is newer than 6 hours
    if (!$error && is_array($twitdata['tweets'])) {
        ?>
   <div class="clear-block">
     <div class="avatar"><img src="<?php 
        echo $twitdata['user']['profile_image_url'];
        ?>
" alt="<?php 
        echo $twitdata['user']['name'];
        ?>
" /></div>
     <div class="info"><a href="http://www.twitter.com/<?php 
        echo $twituser;
        ?>
"><?php 
        echo $twitdata['user']['name'];
        ?>
 </a><br /><span class="followers"> <?php 
        printf(__("%s followers", "mystique"), $twitdata['user']['followers_count']);
        ?>
</span></div>
   </div>

   <ul>
    <?php 
        $i = 0;
        foreach ($twitdata['tweets'] as $tweet) {
            $pattern = '/\\@(\\w+)/';
            $replace = '<a rel="nofollow" href="http://twitter.com/$1">@$1</a>';
            $tweet['text'] = preg_replace($pattern, $replace, $tweet['text']);
            $tweet['text'] = make_clickable($tweet['text']);
            // remove +XXXX
            $tweettime = substr_replace($tweet['created_at'], '', strpos($tweet['created_at'], "+"), 5);
            $link = "http://twitter.com/" . $twitdata['user']['screen_name'] . "/statuses/" . $tweet['id'];
            echo '<li><span class="entry">' . $tweet['text'] . '<a class="date" href="' . $link . '" rel="nofollow">' . mystique_timeSince(abs(strtotime($tweettime . " GMT")), time()) . '</a></span></li>';
            $i++;
            if ($i == $twitcount) {
                break;
            }
        }
        ?>
   </ul>

  <?php 
    } else {
        ?>
   <p class="error"><?php 
        _e("Error while retrieving tweets (Twitter down?)", "mystique");
        ?>
</p>
  <?php 
    }
}