function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('PhoenixTeam_Widget_Twitter', $instance['title']);
     $username = $instance['username'] ? $instance['username'] : null;
     $number = isset($instance['qty']) ? $instance['qty'] : null;
     static $counter = 1;
     // IDs for Widget;
     // echo $args['before_widget']; // It's the right way, but doesn't work with VC :(
     echo '<div id="' . THEME_SLUG . '-twitter-' . esc_attr($counter) . '" class="footer-twitter widget_' . THEME_SLUG . '-twitter">';
     if ($title) {
         echo '<h4 class="widget-title">' . esc_html($title) . '</h4>';
     }
     // $tweets = $this->get_tweets($args['widget_id'], $instance); // Good old, but doesn't work with VC
     $tweets = $this->get_tweets(THEME_SLUG . '-twitter-' . $counter, $instance);
     if (!empty($tweets['tweets']) && empty($tweets['tweets']->errors)) {
         $user = current($tweets['tweets']);
         if (is_object($user)) {
             $user = $user->user;
         }
         echo '<ul class="tweet_list">';
         $checker = 0;
         foreach ($tweets['tweets'] as $tweet) {
             if ($checker <= $number) {
                 if (isset($tweet->text)) {
                     if (is_object($tweet)) {
                         $avatar = $user->profile_image_url;
                         $username = $user->screen_name;
                         $user_url = 'https://twitter.com/' . $username;
                         $tweet_text = htmlentities($tweet->text, ENT_QUOTES, 'UTF-8');
                         $tweet_text = make_clickable($tweet_text);
                         $tweet_text = popuplinks($tweet_text);
                         if ($tweet_text) {
                             echo '<li>
                           <a class="tweet_avatar" href="' . esc_url($user_url) . '">
                             <img src="' . esc_url($avatar) . '" alt="' . esc_attr($username) . '" title="' . esc_attr($username) . '">
                           </a>
                           <span class="tweet_text">' . wp_kses_post($tweet_text) . '</span>
                         </li>';
                             $checker++;
                         }
                     }
                 } else {
                     if ($checker == 0) {
                         echo '<li><span class="content">' . __("There's no tweets in your feed...", 'grandway') . '</span></li>';
                         break;
                     }
                     break;
                 }
             }
         }
         echo '</ul>';
     } elseif ($tweets['tweets']->errors) {
         _e('Authentication failed! Please check your Twitter app data.', 'grandway');
     } elseif (!$tweets['tweets']) {
         _e("There's no tweets there", 'grandway');
     }
     echo $args['after_widget'];
     $counter++;
 }
Example #2
0
    $adjust -= 1;
}
$out .= "</div>\n";
$org = get_userdata($event->user_id);
if (!empty($org->organization)) {
    $organization = stripslashes($org->organization);
    $out .= '<div class="presented">' . __('Presented by', AEC_NAME) . ' ';
    if (!empty($org->user_url)) {
        $out .= "<a href='{$org->user_url}' target='_blank'>{$organization}</a>";
    } else {
        $out .= $organization;
    }
    $out .= "</div>\n";
    $adjust -= 1;
}
if (!empty($event->link)) {
    if ($adjust < 1) {
        $adjust = 1;
    }
    $out .= str_repeat("<br>", $adjust);
    $link = "<a href='{$event->link}' class='link round5 cat{$event->category_id}'>";
    $link .= __('Event Link', AEC_NAME);
    $link .= "</a>\n";
    $out .= "{$link}";
}
// make links open in a new window
if ($aec_options['popup_links']) {
    $out = popuplinks($out);
}
$output = array('title' => $event->title, 'content' => $out, 'start' => date('m/d/Y H:i:00', strtotime($event->start)), 'end' => date('m/d/Y H:i:00', strtotime($event->end)), 'allDay' => $event->allDay, 'repeat_f' => $event->repeat_freq, 'repeat_i' => $event->repeat_int, 'repeat_e' => $event->repeat_end);
$this->render_json($output);
Example #3
0
/**
 * 依据给定的地址和规则采集并发表文章
 * @package WordPress
 * @subpackage Auto-Post-News
 * @since 0.0.1
 * @param array $news_args 所有需要用到的参数,参考示例
 * @return bool 成功则返回文章ID,失败则返回具体原因
 */
function post_news()
{
    $news_args = array('lock_file' => dirname(__FILE__) . '/post.lock', 'news_list_type' => 'rss', 'news_rss' => 'http://feeds.bbci.co.uk/news/business/rss.xml', 'news_max' => 2, 'auto_matche' => FALSE, 'news_pattern' => array(array('<!-- / story-body -->', '|<h1 class="story-header">([\\W\\w]*?)</h1>([\\W\\w]*?)</div><!-- / story-body -->|i'), array('<div id="page-bookmark-links-foot"', '|<h1 class="story-header">([\\W\\w]*?)</h1>([\\W\\w]*?)<div id="page-bookmark-links-foot"|i'), array('<table class="storycontent"', '|<table class="storycontent"[\\W\\w]*?<h1>([\\W\\w]*?)</h1>([\\W\\w]*?)<!-- body - End -->|i')), 'preg_replace' => array('|<noscript>[\\W\\w]*?</noscript>|i', '|<script[\\W\\w]*?</script>|i', '|<form[\\W\\w]*?</form>|i', '|<ul class="related-links-list">[\\W\\w]*?</ul>|i', '|<!--[\\W\\w]*?-->|i', '|<[a-z][^>]*></[^>]*>|i', '|<div class="read-more">[\\W\\w]*?</div>|i'), 'str_replace' => array("\n", "\t", "\r", "", "\v", '  ', 'Continue reading the main story'), 'has_content_post' => 'publish', 'no_content_post' => 'draft', 'author' => '1', 'category_name' => 'Business', 'rss_time' => FALSE, 'add_more' => array(TRUE, 1000, 500), 'publish_time' => TRUE, 'orgin_link' => TRUE);
    if (lock('check', $news_args['lock_file']) == 'locked') {
        return 'Locked';
    }
    ignore_user_abort(TRUE);
    $rss = fetch_feed($news_args['news_rss']);
    if (!is_wp_error($rss)) {
        $items = $rss->get_items();
    } else {
        lock('delete', $news_args['lock_file']);
        return $rss;
    }
    $post_guids = get_guids('numberposts=50&post_status=publish,draft');
    $allowedposttags = array('address' => array(), 'a' => array('href' => array(), 'id' => array(), 'title' => array(), 'rel' => array(), 'rev' => array(), 'name' => array(), 'target' => array()), 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), 'article' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'aside' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'b' => array(), 'big' => array(), 'blockquote' => array('id' => array(), 'cite' => array(), 'lang' => array(), 'xml:lang' => array()), 'br' => array('class' => array()), 'caption' => array('align' => array(), 'class' => array()), 'cite' => array('dir' => array(), 'lang' => array(), 'title' => array()), 'code' => array(), 'col' => array('align' => array(), 'char' => array(), 'charoff' => array(), 'span' => array(), 'dir' => array(), 'valign' => array(), 'width' => array()), 'del' => array('datetime' => array()), 'dd' => array(), 'details' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'open' => array(), 'xml:lang' => array()), 'dl' => array(), 'dt' => array(), 'em' => array(), 'figure' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'figcaption' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'font' => array('color' => array(), 'face' => array(), 'size' => array()), 'footer' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'h1' => array('align' => array(), 'id' => array()), 'h2' => array('align' => array(), 'id' => array()), 'h3' => array('align' => array(), 'id' => array()), 'h4' => array('align' => array(), 'id' => array()), 'h5' => array('align' => array(), 'id' => array()), 'h6' => array('align' => array(), 'id' => array()), 'header' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'hgroup' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'hr' => array('align' => array(), 'noshade' => array(), 'size' => array(), 'width' => array()), 'i' => array(), 'img' => array('alt' => array(), 'align' => array(), 'border' => array(), 'height' => array(), 'hspace' => array(), 'longdesc' => array(), 'vspace' => array(), 'src' => array(), 'width' => array()), 'ins' => array('datetime' => array(), 'cite' => array()), 'kbd' => array(), 'li' => array('align' => array(), 'class' => array()), 'menu' => array('type' => array()), 'p' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'pre' => array('width' => array()), 'q' => array('cite' => array()), 's' => array(), 'span' => array('dir' => array(), 'align' => array(), 'lang' => array(), 'title' => array(), 'xml:lang' => array()), 'section' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'strike' => array(), 'strong' => array(), 'sub' => array(), 'summary' => array('align' => array(), 'dir' => array(), 'lang' => array(), 'xml:lang' => array()), 'sup' => array(), 'table' => array('align' => array(), 'bgcolor' => array(), 'border' => array(), 'cellpadding' => array(), 'cellspacing' => array(), 'dir' => array(), 'id' => array(), 'rules' => array(), 'summary' => array(), 'width' => array()), 'tbody' => array('align' => array(), 'char' => array(), 'charoff' => array(), 'valign' => array()), 'td' => array('abbr' => array(), 'align' => array(), 'axis' => array(), 'bgcolor' => array(), 'char' => array(), 'charoff' => array(), 'colspan' => array(), 'dir' => array(), 'headers' => array(), 'height' => array(), 'nowrap' => array(), 'rowspan' => array(), 'scope' => array(), 'valign' => array(), 'width' => array()), 'tfoot' => array('align' => array(), 'char' => array(), 'charoff' => array(), 'valign' => array()), 'th' => array('abbr' => array(), 'align' => array(), 'axis' => array(), 'bgcolor' => array(), 'char' => array(), 'charoff' => array(), 'colspan' => array(), 'headers' => array(), 'height' => array(), 'nowrap' => array(), 'rowspan' => array(), 'scope' => array(), 'valign' => array(), 'width' => array()), 'thead' => array('align' => array(), 'char' => array(), 'charoff' => array(), 'valign' => array()), 'title' => array(), 'tr' => array('align' => array(), 'bgcolor' => array(), 'char' => array(), 'charoff' => array(), 'valign' => array()), 'tt' => array(), 'u' => array(), 'ul' => array('type' => array()), 'ol' => array('start' => array(), 'type' => array()), 'video' => array('autoplay' => array(), 'controls' => array(), 'height' => array(), 'loop' => array()), 'preload' => array(), 'src' => array(), 'width' => array());
    $count_post = 0;
    foreach ($items as $item) {
        $news_matche = array();
        $post = array();
        if (in_array($item->get_id(), $post_guids)) {
            continue;
        }
        $news = get_news($item->get_id());
        //提取正文
        if ($news == FALSE) {
            $post_content = $item->get_content();
            $post_status = $news_args['no_content_post'];
        } else {
            foreach ($news_args['news_pattern'] as $pattern) {
                if (!$news_args['auto_matche'] && stripos($news, $pattern['0'])) {
                    preg_match($pattern['1'], $news, $news_matche);
                    break;
                } else {
                    preg_match($pattern['1'], $news, $news_matche);
                }
            }
            //	    print_r($news_matche);
            if (!empty($news_matche)) {
                $post_content = $news_matche['2'];
                $post_status = $news_args['has_content_post'];
            } elseif ($item->get_content()) {
                $post_content = $item->get_content();
                $post_status = $news_args['no_content_post'];
            } else {
                continue;
            }
        }
        $post_content = custom_replace($post_content, $news_args['str_replace'], $news_args['preg_replace']);
        $post_content = wp_kses($post_content, $allowedposttags);
        $post_content = wptexturize($post_content);
        $post_content = popuplinks($post_content);
        $post_content = make_link_absolute($post_content, $item->get_id());
        if ($news_args['add_more']['0'] && strlen($post_content) > max(600, $news_args['add_more']['1'])) {
            $post_content = substr_replace($post_content, '<!--more-->', stripos($post_content, '</p>', max(300, $news_args['add_more']['2'])) + 4, 0);
        }
        if ($news_args['publish_time']) {
            $post_content .= '<br />Published at ' . $item->get_date(get_option('date_format') . ' ' . get_option('time_format')) . ' GMT';
        }
        if ($news_args['orgin_link']) {
            $post_content .= '<br />From: <a target="_blank"  title="' . $item->get_title() . '" href="' . $item->get_id() . '">' . $item->get_title() . '</a>';
        }
        //	echo $post_content . '<hr />';
        $post_category = term_exists($news_args['category_name'], 'category');
        if (!$post_category && $news_args['category_name']) {
            $post_category = wp_insert_term($news_args['category_name'], 'category');
        }
        $post = array('post_status' => $post_status, 'post_author' => $news_args['author'], 'post_category' => $post_category ? array($post_category['term_id']) : '', 'post_date' => $news_args['rss_time'] ? $item->get_date() : '', 'post_content' => $post_content, 'post_excerpt' => $item->get_description(), 'post_title' => $item->get_title(), 'tags_input' => '', 'guid' => $item->get_id());
        generic_ping(wp_insert_post($post));
        if (++$count_post >= $news_args['news_max']) {
            break;
        }
        sleep('1');
    }
    lock('delete', $news_args['lock_file']);
}
 public static function parseLinks($string)
 {
     $string = preg_replace("/@(\\w+)/", "<a href=\"https://twitter.com/\$1\">@\$1</a>", $string);
     return popuplinks(make_clickable($string));
 }
Example #5
0
 function mess_preg_replace_rcl($mess)
 {
     //$mess = $this->oembed_filter( $mess );
     $mess = popuplinks(make_clickable($mess));
     if (function_exists('wp_oembed_get')) {
         $links = '';
         preg_match_all('/href="([^"]+)"/', $mess, $links);
         foreach ($links[1] as $link) {
             $m_lnk = wp_oembed_get($link, array('width' => 300, 'height' => 250));
             if ($m_lnk) {
                 $mess = str_replace('<a href="' . $link . '" rel="nofollow">' . $link . '</a>', '', $mess);
                 $mess .= $m_lnk;
             }
         }
     }
     //$mess = preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", '<a target="_blank" href="$1://$2">$1://$2</a>$3', $mess);
     if (function_exists('convert_smilies')) {
         $mess = str_replace('style="height: 1em; max-height: 1em;"', '', convert_smilies($mess));
     }
     return $mess;
 }
 /**
  * Get testimonial's url.
  *
  * @since 1.0.2
  */
 public function get_url()
 {
     global $post;
     $post_meta = $this->get_meta();
     if (empty($post_meta['url'])) {
         return;
     }
     if (isset($this->atts['clickable_url']) && true === $this->atts['clickable_url']) {
         $format = '<a href="%1$s">%1$s</a>';
     } else {
         $format = '%s';
     }
     $link = sprintf($format, esc_url($post_meta['url']));
     return apply_filters('cherry_testimonials_url_template_callbacks', popuplinks($link), $post->ID, $this->atts);
 }
    public function widget($args, $instance)
    {
        extract($args);
        $twitter_username = $instance['twitter_username'];
        $tweets_limit = $instance['tweets_limit'];
        $tweets = get_transient('laborator_latest_tweets');
        # Caching
        if (!$tweets) {
            $tweets = $this->fetch_tweets($twitter_username, $tweets_limit);
            set_transient('laborator_latest_tweets', $tweets, $fetch_interval * 60);
        }
        // Before Widget
        echo PHP_EOL . $before_widget;
        // Display Title
        $title = apply_filters('widget_title', empty($instance['title']) ? 'Tweets' : $instance['title'], $instance, $this->id_base);
        echo PHP_EOL . $before_title . $title . $after_title . PHP_EOL;
        // Display Tweets List
        $tweets_swtich_timeout = $instance['tweets_swtich_timeout'];
        ?>
		<!-- tweets -->
		<ul class="tweets"<?php 
        echo $tweets_swtich_timeout > 0 ? ' data-timeout="' . $tweets_swtich_timeout . '"' : '';
        ?>
>
		<?php 
        if (!is_array($tweets)) {
            $tweets = array();
        }
        $tweets = array_splice($tweets, 0, $instance['tweets_limit']);
        foreach ($tweets as $tweet) {
            $tweet_time = strtotime($tweet->created_at);
            $tweet_mo = __(date("M", $tweet_time), TD);
            $tweet_date = strtolower(date('d', $tweet_time) . ' ' . __($tweet_mo, TD));
            if (date('Y', $tweet_time) != date('Y')) {
                $tweet_date .= ', ' . date('Y', $tweet_time);
            }
            $text = popuplinks(make_clickable($tweet->text));
            # Replace @usernames links
            $text = preg_replace("/@([a-z0-9_]+)/i", '<a href="http://twitter.com/$1" target="_blank" title="$1">@$1</a>', $text);
            # Replace #hashtags links
            $text = preg_replace("/#([a-z0-9_]+)/i", '<a href="http://twitter.com/#!search/?q=%23$1&src=hash" target="_blank" title="$1">#$1</a>', $text);
            ?>
			
			<li>
				<!-- tweet item -->
				<div class="tweet">
					<?php 
            echo $text;
            ?>
					<span class="timespan"><?php 
            echo $tweet_date;
            ?>
</span><!-- tweet date -->
				</div>
				<!-- end: tweet item -->
			</li>
			<?php 
        }
        ?>
		</ul>
		<?php 
        // After Widget
        echo $after_widget . PHP_EOL;
    }