function form($instance) { global $tb_refresh_periods; $default = array('title' => __('Favorite Tweets', 'tweetblender'), 'widget_refresh_rate' => 0, 'widget_tweets_num' => 4, 'widget_sources' => ''); $instance = wp_parse_args((array) $instance, $default); // report errors if any if (isset($this->error)) { echo tb_wrap_javascript("function tAuth(url) {var tWin = window.open(url,'tWin','width=800,height=410,toolbar=0,location=1,status=0,menubar=0,resizable=1');}"); echo '<div class="error">' . $this->error . '</div>'; $instance = $this->bad_input; } // report messages if an if (isset($this->message)) { echo '<div class="updated">' . $this->message . '</div>'; } // title $field_id = $this->get_field_id('title'); $field_name = $this->get_field_name('title'); echo "\r\n" . '<p><label for="' . $field_id . '">' . __('Title', 'tweetblender') . ': <input type="text" class="widefat" id="' . $field_id . '" name="' . $field_name . '" value="' . esc_attr($instance['title']) . '" /></label></p>'; // sources $field_id = $this->get_field_id('widget_sources'); $field_name = $this->get_field_name('widget_sources'); echo "\r\n" . '<p><label for="' . $field_id . '">' . __('Sources (one per line)', 'tweetblender') . ': <textarea class="widefat" id="' . $field_id . '" name="' . $field_name . '" rows=4 cols=20 wrap="hard">' . esc_attr($instance['widget_sources']) . '</textarea></label></p>'; // specify refresh $field_id = $this->get_field_id('widget_refresh_rate'); $field_name = $this->get_field_name('widget_refresh_rate'); echo "\r\n" . '<label for="' . $field_id . '">' . __('Refresh', 'tweetblender') . '</label>'; echo "\r\n" . '<select id="' . $field_id . '" name="' . $field_name . '">'; foreach ($tb_refresh_periods as $name => $sec) { echo "\r\n" . '<option value="' . $sec . '"'; if ($sec == $instance['widget_refresh_rate']) { echo ' selected'; } echo '>' . $name . '</option>'; } echo "\r\n" . '</select><br>'; // specify number of tweets $field_id = $this->get_field_id('widget_tweets_num'); $field_name = $this->get_field_name('widget_tweets_num'); echo "\r\n" . '<br/><label for="' . $field_id . '">' . __('Show', 'tweetblender') . ' <select id="' . $field_id . '" name="' . $field_name . '">'; for ($i = 1; $i <= 15; $i++) { echo "\r\n" . '<option value="' . $i . '"'; if ($i == $instance['widget_tweets_num']) { echo ' selected'; } echo '>' . $i . '</option>'; } for ($i = 20; $i <= 100; $i += 10) { echo "\r\n" . '<option value="' . $i . '"'; if ($i == $instance['widget_tweets_num']) { echo ' selected'; } echo '>' . $i . '</option>'; } echo "\r\n" . '</select>' . __('tweets', 'tweetblender') . '</label><br>'; // specify text for "view more" link $field_id = $this->get_field_id('widget_view_more_text'); $field_name = $this->get_field_name('widget_view_more_text'); if (!isset($instance['widget_view_more_text'])) { $instance['widget_view_more_text'] = ''; } echo "\r\n" . '<br/><label for="' . $field_id . '">' . sprintf(__('Text for %s link', 'tweetblender'), '"' . __('view more', 'tweetblender') . '"') . ':</label>'; echo "\r\n" . '<input class="widefat" type="text" id="' . $field_id . '" name="' . $field_name . '" value="' . esc_attr($instance['widget_view_more_text']) . '">'; // specify URL for "view more" link $field_id = $this->get_field_id('widget_view_more_url'); $field_name = $this->get_field_name('widget_view_more_url'); if (!isset($instance['widget_view_more_url'])) { $instance['widget_view_more_url'] = ''; } echo "\r\n" . '<br/><label for="' . $field_id . '">' . sprintf(__('URL for %s link', 'tweetblender'), '"' . __('view more', 'tweetblender') . '"') . ':</label>'; echo "\r\n" . '<input class="widefat" type="text" id="' . $field_id . '" name="' . $field_name . '" value="' . esc_attr($instance['widget_view_more_url']) . '"><br/>'; if ($archive_post = tb_get_archive_post_id()) { echo '<span style="color:#777;font-style:italic;">' . __('Leave blank to use ', 'tweetblender') . '<a href="page.php?action=edit&post=' . $archive_post . '" target="_blank">' . __('existing page', 'tweetblender') . '</a></span>'; } }
function tb_add_archive_page_content($content = '') { global $post; // do nothing if archive page is disabled $tb_o = get_option('tweet-blender'); if (isset($tb_o['archive_is_disabled']) && $tb_o['archive_is_disabled']) { return $content; } else { // work with pages only, ignore blog posts if ($post->post_type != 'page') { return $content; } // if looking at archive page, apend list of tweets to content if ($post->ID == tb_get_archive_post_id()) { return $content . tb_make_archive_html($tb_o); } else { if (preg_match("[TweetBlender Archive]", $content)) { return str_replace("[TweetBlender Archive]", tb_make_archive_html($tb_o), $content); } else { return $content; } } } }
function tb_add_archive_page_content($content = '') { global $post; // do nothing if archive page is disabled $tb_o = get_option('tweet-blender'); if ($tb_o['archive_is_disabled']) { return $content; } else { // work with pages only, ignore blog posts if ($post->post_type != 'page') { return $content; } // if looking at archive page, apend list of tweets to content if ($post->ID == tb_get_archive_post_id()) { $archive_html = '<div id="tweetblender-archive">'; $archive_html .= tb_get_cached_tweets_html('archive', null); $archive_html .= '</div>'; // JavaScript code for mouseovers $archive_html .= tb_wrap_javascript("\n\t\t\t\tTB_mode = 'archive';\n\t\t\t\tjQuery.each(jQuery('#tweetblender-archive').children('div'),function(i,obj){ TB_wireMouseOver(obj.id); });\n\t\t\t"); return $content . $archive_html; } else { return $content; } } }