function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function (&$fields) {
         $fields->merge(array(new TextField('Query', _t('SearchTwitterWidget.FIELD_QUERY', 'Query'), null, 255)));
     });
     return parent::getCMSFields();
 }
 public function getCMSFields()
 {
     $this->beforeUpdateCMSFields(function (&$fields) {
         $fields->merge(array(new TextField('User', _t('UserTwitterWidget.FIELD_USER', 'User'), null, 255)));
     });
     return parent::getCMSFields();
 }
 function __construct()
 {
     self::$assets_path = plugins_url('/assets', dirname(__FILE__));
     // initialize wordpress widget
     parent::__construct(static::WIDGET_ID, static::WIDGET_NAME, array('description' => 'Twitter Feed'));
     add_action('wp_enqueue_scripts', array($this, 'register_assets'));
 }
Example #4
0
function king_ajax()
{
    global $king;
    $task = !empty($_POST['task']) ? $_POST['task'] : '';
    $id = $king->vars('id');
    $amount = $king->vars('amount');
    switch ($task) {
        case 'twitter':
            TwitterWidget::returnTweet($id, $amount);
            exit;
            break;
        case 'flickr':
            $link = "http://api.flickr.com/services/feeds/photos_public.gne?id=" . $id . "&lang=en-us&format=rss_200";
            $connect = $king->ext['ci']();
            curl_setopt_array($connect, array(CURLOPT_URL => $link, CURLOPT_RETURNTRANSFER => true));
            $photos = $king->ext['ce']($connect);
            curl_close($connect);
            if (!empty($photos)) {
                $photos = simplexml_load_string($photos);
                if (count($photos->entry) > 1) {
                    for ($i = 0; $i < $amount; $i++) {
                        $image_url = $photos->entry[$i]->link[1]['href'];
                        //find and switch to small image
                        $image_url = str_replace("_b.", "_s.", $image_url);
                        echo '<a href="' . $photos->entry[$i]->link['href'] . '" target=_blank><img src="' . $image_url . '" /></a>';
                    }
                }
            } else {
                echo 'Error: Can not load photos at this moment.';
            }
            exit;
            break;
    }
}