From 429c836ff1f27e2f44163bbacfeeb1f53e37262e Mon Sep 17 00:00:00 2001 From: mxmehl Date: Wed, 7 Sep 2016 20:59:59 +0200 Subject: [PATCH] initial commit --- better-twitter-widget.php | 713 +++++++++++++++++++++++ img/like.png | Bin 0 -> 941 bytes img/reply.png | Bin 0 -> 1052 bytes img/retweet.png | Bin 0 -> 838 bytes img/view.png | Bin 0 -> 1339 bytes includes/better-twitter-widget-admin.css | 94 +++ includes/settings.php | 120 ++++ includes/widget-form.php | 129 ++++ js/better-twitter-widget.js | 45 ++ lang/better-twitter-widget.pot | 427 ++++++++++++++ readme.txt | 263 +++++++++ 11 files changed, 1791 insertions(+) create mode 100644 better-twitter-widget.php create mode 100644 img/like.png create mode 100644 img/reply.png create mode 100644 img/retweet.png create mode 100644 img/view.png create mode 100644 includes/better-twitter-widget-admin.css create mode 100644 includes/settings.php create mode 100644 includes/widget-form.php create mode 100644 js/better-twitter-widget.js create mode 100644 lang/better-twitter-widget.pot create mode 100644 readme.txt diff --git a/better-twitter-widget.php b/better-twitter-widget.php new file mode 100644 index 0000000..364344d --- /dev/null +++ b/better-twitter-widget.php @@ -0,0 +1,713 @@ +. + + * ************************************************************************* + + */ + +/* Class Declaration */ + +class better_twitter_widget extends WP_Widget { + + var $version = '2.7.1'; + + /* Plugin settings */ + var $optionsName = 'better-twitter-widget-options'; + var $menuName = 'better-twitter-widget-settings'; + var $pluginName = 'Better Twitter Widget'; + var $options = array(); + var $make_link = false; + + /** + * Plugin Constructor Method + */ + function better_twitter_widget() { + add_action('init', array($this, 'init')); + + /* Set the plugin name to use the selected language. */ + $this->pluginName = __('Better Twitter Widget', 'better-twitter-widget'); + + $widget_ops = array('description' => __('Enhancement of Better RSS Widget, focussed on plain Twitter feeds', 'better-twitter-widget')); + $control_ops = array('width' => 500, 'height' => 350); + parent::WP_Widget(false, $this->pluginName, $widget_ops, $control_ops); + + /* Plugin paths */ + $this->pluginPath = WP_PLUGIN_DIR . '/' . basename(dirname(__FILE__)); + $this->pluginURL = WP_PLUGIN_URL . '/' . basename(dirname(__FILE__)); + + /* Load the plugin settings */ + $this->load_settings(); + + /* WordPress Actions */ + add_action('admin_menu', array(&$this, 'admin_menu')); + add_action('admin_init', array(&$this, 'admin_init')); + add_action('update_option_' . $this->optionsName, array(&$this, 'update_option'), 10); + + /* WordPress FIlters */ + add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2); + + /* Add shortcode_handlers */ + add_shortcode('better-rss', array($this, 'shortcode_handler')); + } + + /** + * Load the plugin settings. + */ + function load_settings() { + $options = get_option($this->optionsName); + + $defaults = array( + 'link_target' => '_blank', + 'allow_intro' => (is_array($options)) ? isset($options['allow_intro']) : true, + 'show_summary' => false, + 'show_author' => false, + 'show_date' => false, + 'show_time' => false, + 'nofollow' => false, + 'enable_cache' => (is_array($options)) ? isset($options['enable_cache']) : true, + 'cache_duration' => 3600, + 'items' => 10, + 'title_length' => (is_array($options) && !empty($options['title_length'])) ? isset($options['title_length']) : 0, + 'excerpt' => 360, + 'suffix' => ' […]' + ); + + $this->options = (object) wp_parse_args($options, $defaults); + } + + /** + * Load the language file during WordPress init. + */ + function init() { + /* Load Langague Files */ + $langDir = dirname(plugin_basename(__FILE__)) . '/lang'; + load_plugin_textdomain('better-twitter-widget', false, $langDir, $langDir); + } + + /** + * Add the admin page for the settings panel. + * + * @global string $wp_version + */ + function admin_menu() { + $page = add_options_page($this->pluginName . __(' Settings', 'better-twitter-widget'), $this->pluginName, 'manage_options', $this->menuName, array(&$this, 'options_panel')); + + add_action('admin_print_styles-' . $page, array(&$this, 'admin_print_styles')); + add_action('admin_print_scripts-' . $page, array(&$this, 'admin_print_scripts')); + } + + /** + * Register the options for Wordpress MU Support + */ + function admin_init() { + register_setting($this->optionsName, $this->optionsName); + wp_register_style('better-twitter-widget-admin-css', $this->pluginURL . '/includes/better-twitter-widget-admin.css'); + wp_register_script('better-twitter-widget-js', $this->pluginURL . '/js/better-twitter-widget.js'); + } + + /** + * Print the administration styles. + */ + function admin_print_styles() { + wp_enqueue_style('better-twitter-widget-admin-css'); + } + + /** + * Print the scripts needed for the admin. + */ + function admin_print_scripts() { + wp_enqueue_script('better-twitter-widget-js'); + } + + /** + * Add a configuration link to the plugins list. + * + * @staticvar object $this_plugin + * @param array $links + * @param array $file + * @return array + */ + function plugin_action_links($links, $file) { + static $this_plugin; + + if (!$this_plugin) { + $this_plugin = plugin_basename(__FILE__); + } + + if ($file == $this_plugin) { + $settings_link = '' . __('Settings', 'better-twitter-widget') . ''; + array_unshift($links, $settings_link); + } + + return $links; + } + + /** + * Check on update option to see if we need to reset the options. + * @param $input + * @return + */ + function update_option($input) { + if ($_REQUEST['confirm-reset-options']) { + delete_option($this->optionsName); + wp_redirect(admin_url('options-general.php?page=' . $this->menuName . '&tab=' . $_POST['active_tab'] . '&reset=true')); + exit(); + } else { + wp_redirect(admin_url('options-general.php?page=' . $this->menuName . '&tab=' . $_POST['active_tab'] . '&updated=true')); + exit(); + } + } + + /** + * Settings management panel. + */ + function options_panel() { + include($this->pluginPath . '/includes/settings.php'); + } + + /** + * Method to create the widget. + * + * @param array $args + * @param array $instance + * @return false + */ + function widget($args, $instance) { + $instance = $this->defaults($instance); + + if (isset($instance['error']) && $instance['error']) + return; + + extract($args, EXTR_SKIP); + + $url = $instance['rss_url']; + while (stristr($url, 'http') != $url) + $url = substr($url, 1); + + if (empty($url)) { + return; + } + + $rss = fetch_feed($url); + $desc = ''; + $link = ''; + + if (!is_wp_error($rss)) { + $desc = esc_attr(strip_tags(@html_entity_decode($rss->get_description(), ENT_QUOTES, get_option('blog_charset')))); + + if (empty($instance['title'])) { + $instance['title'] = esc_html(strip_tags($rss->get_title())); + } + $link = esc_url(strip_tags($rss->get_permalink())); + while (stristr($link, 'http') != $link) { + $link = substr($link, 1); + } + } + + if (empty($instance['title'])) { + $instance['title'] = empty($desc) ? __('Unknown Feed', 'better-twitter-widget') : $desc; + } + + $instance['title'] = apply_filters('widget_title', $instance['title']); + $url = esc_url(strip_tags($url)); + $icon = includes_url('images/rss.png'); + + if ($instance['title_url']) { + $url = $link = $instance['title_url']; + } + + $target = ''; + + if ($instance['link_target'] != 'none') { + $target = 'target="' . $instance['link_target'] . '"'; + } + + if ($instance['title']) { + if (!$instance['no_link_title']) { + $instance['title'] = '' . $instance['title'] . ''; + } + + if ($instance['show_icon']) { + $instance['title'] = "RSS " . $instance['title']; + } + } + + print $before_widget; + if ($instance['title']) { + print $before_title . $instance['title'] . $after_title; + } + + if (true == $this->options->allow_intro && !empty($instance['intro_text'])) { + print '
' . $instance['intro_text'] . '
'; + } + + $this->rss_output($rss, $instance); + print $after_widget; + } + + /** + * Method to output the RSS for the widget and shortcode_handler + * + * @param string $rss + * @param array $args + * @return blank + */ + function rss_output($rss, $args = array()) { + if (is_string($rss)) { + $rss = fetch_feed($rss); + } elseif (is_array($rss) && isset($rss['url'])) { + $args = $rss; + $rss = fetch_feed($rss['url']); + } elseif (!is_object($rss)) { + return; + } + + if (is_wp_error($rss)) { + if (is_admin() || current_user_can('manage_options')) { + print '

' . sprintf(__('RSS Error: %s', 'better-twitter-widget'), $rss->get_error_message()) . '

'; + } + + return; + } + + $args = wp_parse_args($args, $this->defaults_args()); + extract($args, EXTR_SKIP); + + $items = (int) $items; + if ($items < 1 || 20 < $items) { + $items = 10; + } + $show_summary = (int) $show_summary; + $show_author = (int) $show_author; + $show_date = (int) $show_date; + + // Set the cache duration + $rss->enable_cache($enable_cache); + $rss->set_cache_duration($cache_duration); + $rss->init(); + + if (!$rss->get_item_quantity()) { + print '
  • ' . __('An error has occurred; the feed is probably down. Try again later.', 'better-twitter-widget') . '
'; + return; + } + + if (strtolower($link_target) != 'none') { + $target = 'target="' . $link_target . '"'; + } else { + $target = ''; + } + + print '<' . $args['html_parent'] . '>'; + + foreach ($rss->get_items(0, $items) as $item) { + $link = $item->get_link(); + while (stristr($link, 'http') != $link) { + $link = substr($link, 1); + } + $link = esc_url(strip_tags($link)); + $title = esc_attr(strip_tags($item->get_title())); + + if (empty($title)) { + $title = __('Untitled', 'better-twitter-widget'); + } + + $desc = str_replace(array("\n", "\r"), ' ', esc_attr(strip_tags(@html_entity_decode($item->get_description(), ENT_QUOTES, get_option('blog_charset'))))); + + + // BUG -- CUSTOM comment out + /*if (!$hide_title) { + $desc = wp_html_excerpt($desc, $excerpt) . $this->options->suffix; + $desc = esc_html($desc); + }*/ + $desc = esc_html($desc); + + if ($show_summary) { + $summary = "
$desc
"; + } else { + $summary = ''; + } + + $date = ''; + if ($show_date) { + $date = $item->get_date(); + + if ($date) { + if ($date_stamp = strtotime($date)) + $date = ' ' . date_i18n(get_option('date_format'), $date_stamp) . ''; + else + $date = ''; + } + } + + $time = ''; + if ($show_time) { + $time = $item->get_date(); + + if ($time) { + if ($date_stamp = strtotime($time)) { + $time = ' ' . date_i18n(get_option('time_format'), $date_stamp) . ''; + } else { + $time = ''; + } + } + } + + $author = ''; + if ($show_author) { + $author = $item->get_author(); + if (is_object($author)) { + $author = $author->get_name(); + $author = ' ' . esc_html(strip_tags($author)) . ''; + } + } + + if ($hide_title && $item->get_description()) { + $title = $item->get_description(); + } + + if (true == $args['limit_title_length'] && $args['title_length'] > 0) { + $title = substr($title, 0, $args['title_length']); + } + + if ($args['html_parent'] === 'dl') { + $html_open = '
'; + $html_after_title = '
'; + $html_before_details = '
'; + $html_close = '
'; + } else { + $html_open = '<' . $args['html_item'] . '>'; + $html_after_title = ''; + $html_before_details = ''; + $html_close = ''; + } + + if ($link == '' or $hide_link) { + print $html_open . $title . $html_after_title; + print $html_before_details . $date . $summary . $author . $html_close; + } else { + /* ORIG + print $html_open . '' . $title . '' . $html_after_title; + //print $html_before_details . $date . $time . $summary . $author . $html_close; + print $html_close; + ======================= */ + + $search = array(); + $search[0] = '/([\s>\-\.])#([[:alnum:]öäü]+)/i'; // text #hash text; >#hash text + $search[1] = '/([\s>\-\.])@([[:alnum:]_]+)/'; // @user + $search[2] = '/([\s>\-\.])(https?:[\/[:alnum:]\.\?\&#\=\%\+\-]+)/'; // http... + + $replace = array(); + $replace[0] = '$1#$2'; + $replace[1] = '$1@$2'; + $replace[2] = '$1$2'; + + $extsummary = preg_replace($search, $replace, $summary); + + // get tweet ID + $tid = preg_match('/(\d)+$/', $link, $match); + $tid = $match[0]; + + // li + text + print $html_open . $extsummary ; + + print '' . $date . ''; + + + // Action bar + print ''; + + // reply icon + print ''; + // retweet icon + print ''; + // like icon + print ''; + // view on twitter icon + print ''; + + print ''; // close action bar + + // close li + print $html_close; + } + } + print ''; + } + + /** + * Widget Update method + * @param array $new_instance + * @param array $old_instance + * @return array + */ + function update($new_instance, $old_instance) { + return $new_instance; + } + + /** + * Load the instance defaults. + * + * @param array $instance + * @return array + */ + function defaults($instance) { + + /* Fix any old instances to use new naming convention. */ + if (isset($instance['url'])) { + $instance['rss-url'] = $instance['url']; + $instance['title_url'] = $instance['titleurl']; + $instance['show_icon'] = $instance['showicon']; + $instance['show_summary'] = $instance['showsummary']; + $instance['show_author'] = $instance['showauthor']; + $instance['show_date'] = $instance['showdate']; + $instance['show_time'] = $instance['showtime']; + $instance['link_target'] = $instance['linktarget']; + $instance['title_legnth'] = (isset($instance['title_length']) ? $instance['title_length'] : $this->options->title_length); + } + + /* This is the new naming convention for the form fields */ + $new_defaults = array( + 'rss_url' => '', + 'title' => '', + 'title_url' => '', + 'no_link_title' => false, + 'show_icon' => false, + 'link_icon' => 'rss_url', + 'show_summary' => $this->options->show_summary, + 'show_author' => $this->options->show_author, + 'show_date' => $this->options->show_date, + 'show_time' => $this->options->show_time, + 'link_target' => $this->options->link_target, + 'nofollow' => $this->options->nofollow, + 'enable_cache' => $this->options->enable_cache, + 'cache_duration' => $this->options->cache_duration, + 'is_home' => $this->options->is_home_default, + 'is_front' => $this->options->is_front_default, + 'is_archive' => $this->options->is_archive_default, + 'is_search' => $this->options->is_search_default, + 'is_category' => $this->options->is_category_default, + 'is_tag' => $this->options->is_tag_default, + 'is_single' => $this->options->is_single_default, + 'is_date' => $this->options->is_date_default, + 'title_length' => $this->options->title_length, + 'excerpt' => $this->options->excerpt, + 'items' => $this->options->items + ); + + return wp_parse_args($instance, $new_defaults); + } + + /** + * Widget form. + * + * @param array $instance + */ + function form($instance) { + if (count($instance) < 1) { + $instance = $this->defaults($instance); + } + include( $this->pluginPath . '/includes/widget-form.php'); + } + + /** + * Method for the [better-rss] short code. + * + * @param array $atts + * @return string + */ + function shortcode_handler($atts) { + global $post; + + $atts = (object) wp_parse_args($atts, $this->defaults_args()); + + if (!$atts->feed) { + return false; + } + + if ($atts->use_title) { + $add_url[] = str_replace(' ', '+', $post->post_title); + } + + if ($atts->use_tags) { + foreach (get_the_tags() as $tag) { + $add_url[] = str_replace(' ', '+', $tag->name); + } + } + + if (isset($add_url) and is_array($add_url)) { + $atts->feed = $atts->feed . implode('+', $add_url); + } + + ob_start(); + $this->rss_output($atts->feed, $atts); + $output.= ob_get_contents(); + ob_end_clean(); + + return $output; + } + + function defaults_args() { + return array( + // Query Attributes + 'feed' => NULL, + 'use_title' => false, + 'use_tags' => false, + 'use_category' => false, + 'items' => 10, + 'hide_title' => false, + 'hide_link' => false, + 'show_author' => $this->options->show_author, + 'show_date' => $this->options->show_author, + 'show_time' => $this->options->show_time, + 'show_summary' => $this->options->show_summary, + 'link_target' => $this->options->link_target, + 'nofollow' => $this->options->nofollow, + 'cache_duration' => $this->options->cache_duration, + 'excerpt' => $this->options->excerpt, + 'html_parent' => 'ul', + 'html_item' => 'li' + ); + } + + /** + * Get an object with all of the post types. + * + * @return object + */ + function get_post_types($args = array()) { + if (function_exists('get_post_types')) { + $post_types = get_post_types(array('public' => true)); + unset($post_types['attachment']); + } else { + $post_types = array('post', 'page'); + } + + $defaults = array( + 'output' => 'object', + 'name' => 'post_type', + 'id' => 'post_type' + ); + + $args = (object) wp_parse_args($args, $defaults); + + switch ($args->output) { + case 'dropdown': + $results = ''; + break; + default: + $results = (object) $post_types; + } + + return $results; + } + + /** + * Display the list of contributors. + * @return boolean + */ + function contributor_list() { + if (function_exists('simplexml_load_file')) { + $this->showFields = array('NAME', 'LOCATION', 'COUNTRY'); + print '
    '; + + $items = simplexml_load_file('http://cdn.grandslambert.com/xml/better-rss-widget.xml'); + + foreach ($items as $item) { + print '
  • '; + if (empty($item->url)) { + print $item->name; + } else { + print '' . $item->name . ''; + } + + if (!empty($item->location)) { + print ' from ' . $item->location; + } + + if (!empty($item->country)) { + print ', ' . $item->country; + } + + print ' contributed ' . $item->item . ' on ' . date('F jS, Y', strtotime($item->date)) . '
  • '; + } + print '
'; + } else { + _e('PHP 5 Required to see a list of contributors.', 'pretty-sidebar-categories'); + } + } + + /** + * Displayes any data sent in textareas. + * + * @param $input + */ + function debug($input) { + $contents = func_get_args(); + + foreach ($contents as $content) { + print ''; + } + + echo '
'; + } + +} + +/** + * Add the widget code to the initialization action + */ +add_action('widgets_init', create_function('', 'return register_widget("better_twitter_widget");')); +register_activation_hook(__FILE__, 'better_twitter_activate'); + +function better_twitter_activate() { + /* Compile old options into new options Array */ + $new_options = ''; + $options = array('link_target', 'items', 'show_summary', 'show_author', 'show_date', 'show_time', 'enable_cache', 'cache_duration', 'is_home_default', 'is_front_default', 'is_archive_default', 'is_search_default', 'is_category_default', 'is_tag_default', 'is_single_default', 'is_date_default'); + + foreach ($options as $option) { + if ($old_option = get_option('better_twitter_' . $option)) { + $new_options[$option] = $old_option; + delete_option('better_twitter_' . $option); + } + } + + if (is_array($new_options) and ! add_option('better-twitter-widget-options', $new_options)) { + update_option('better-twitter-widget-options', $new_options); + } +} diff --git a/img/like.png b/img/like.png new file mode 100644 index 0000000000000000000000000000000000000000..116081f028c874fa160eb1800bcbdfc9d60d799a GIT binary patch literal 941 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx~p(Fs26hgt!8^qkz^Su;CHY6QCXC zB|(0{42(?7EUawo9GqO-ynF(JLc-#bGO`LvYU*0rx_XAjW)?QKcJ>ZV&R*U=e*OW0 zq45dHsTo<>Ie7)eWmPrJEghZRef<-rOr1V={({9zmM&YrVcU*FhmRaPaq9Hh3m327 zxOwmX(`V0LynOxU?Ys9MK7RWA_4l8@|GsR=<_E@kgQtsQh{y4_*RBU03J_p>;2Hu`4Wr6OMfT6X!B%&XuRXsE5t}kltp4)k4(eqjENgK7znl`KzTf#U0 zMOfFy^p>mp4i`3*e_FibMe>K&9sM~UyTl$(?Ow(cBzAmd)Jr$XNcRO%lU)uA_te?~2dFFkr z*K(~qmL&AQu{=iP?=$UWrrB9#GMm!eQaa~-KNu!Fb#+&ae#zX*O-&~%9%x^vZ4_{N t{x0g;vey$HzxZ`4OjnX?V*P{uN7DT>pIcRFNM(bPoTsaw%Q~loCII{}4ZHvV literal 0 HcmV?d00001 diff --git a/img/reply.png b/img/reply.png new file mode 100644 index 0000000000000000000000000000000000000000..910ec1ef40d585e25649baa03c36fecedd27e868 GIT binary patch literal 1052 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx~p(FwO|@32_B-N5LQrf#<*4-vFJ} zQ4-`A%)rRR%)-Xb!O6|T%O@ZxBrGB(E+Z?ips1v*qN=8@p>1GfYT@MK>gM6)?dKm5 z6cQSfl$MoSSX5q7Syf%r(A3)2-q}56>a^*z=Pg*ee8tMuYu0brw0XW!PX?%ch1|G~q@PoF)1@#^in_a8rf{_^$P_a8rh{r>a!pH{%CL%?*i z+SA1`#N+tYYvI9%97I?XgxD z=HF3^!DH8DZZSdK-wfR?5qBR5 zUY;bcqa-q)Sw|@GbA!84n#zWbjY<5gZpO-H>iP<9b@6#FyW-=Vb7o7pr<^F;=bT-0 zypPGSBG~#zVV-PeqtdBw4fmfdv5T3xFH^owK2sx5?Qj)KgQ(@rhqd~@&g_c(H*b}9 zZQ5BC>CLCtpZ0Ons@tNsUG7nC@UtbKJo#bwBdZTrIpW_GI_!#8sDfzF7Pz>CEeYeXol= literal 0 HcmV?d00001 diff --git a/img/retweet.png b/img/retweet.png new file mode 100644 index 0000000000000000000000000000000000000000..7d2adff18e44c28d69a8de2d82326bb06372f358 GIT binary patch literal 838 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx~p(FuDZzgt!8^qkzH?;N4Rp4>TgD zB*-tAfsu)sg_WIylbcsSSWHq%T2@X`Ra4i<+}g&?-NW0*KOiI`DmE@YAvrB4FTbF$ zsHD24wxO}9wY{UWtEYd$#OX8V&Re`>)rO7RcI-KL=~WFXR>FSzy5J?8I+B9HF<9@Z6o zWmf^?&;R#T8S@sHFR%Rmr8=wLGJf`xd&?N?>>_XN{;=u)tPSZwi=RH-%bPDIq3G4K zizV65_@16{>h0W+`yYNR6l)Hhn{=$`XDG*F-+a}IAc-9-4iu;dJ1ms={VDNyszm!I z9*rqmA922!G?z0tbz8|L@2XUj$5Ahq_`USqx!u_I$=Z^-i%$RBY^P4l>`Sfv@FV@0 zP!GGwX>ps+7MUx4eYMy4`n+sf#UDS7KHZMe$2%5Rc*l2%C2-q_cI=RDmSr{Ja)~__ zY577VLf=qtwZnP|cGqLIyaG?FbtWYX+3SUnbu2Xy0<7_|pzQKh3K3MM?86G%WW07k|$E1AETA VUq3FG6s-WI1y5H$mvv4FO#lyU=~@5) literal 0 HcmV?d00001 diff --git a/img/view.png b/img/view.png new file mode 100644 index 0000000000000000000000000000000000000000..ff99e4e006d6da23d4ab5e79b07bfaaf7af63f0f GIT binary patch literal 1339 zcmeAS@N?(olHy`uVBq!ia0vp^Mj*_=3?wxlRx~p(Fun}%32_B-N5M!4fsCxF3xWPz zToU9L%)rRR%)-jX&dJ5i!^_7nASf&%CN3c*Bd?&StfH!}p{1>(YiML*W^Q3=ZDZ%) z=B{w+w{G9N|KQ=H$4{O-V3(|90)J@Md6Oit}`F4DmRgoFHM<&^ft({`BUF8DHn9 zIaYq1TPwTuX5FrwBN-F8GUxB-V0&g()h)E;VE!YekPGjQbcMGUJyqh_VBjy)&-Zto z>kWs!N`A7tE+=;F>Yki5`Lx=B9kHJ*N=|Hd{yQgC?F`S8%^f#I9Gw?MNv!7kmef(Q zmNDp0#8yWZ;f=>8{&w1sZrl=Zc#lZZW=SzwCE0|XIe8@?wKh~(sxK4c-{8~C(bkeA zf1|AUOh_pEq#600N9+7IBuYv=TD95n(NdoqK`b{;PBsYY(D|}x zM%0Z@2ikluIE$ujna3%{e|%a(XnMobWj7S3N6W-LV2CrhFOz-XM8yr@n@r0UefYzwB~+A`FV1+uFP7BZzT201wVa#e{aKj;#o|7ig~H5J#SII# zuY9=b+Y;YcW~V=Mdyhz7JX938+-hT~qPxi+KZQ8{Lvof$UpE~7JK3eiR+gXlb=srb zOgV)Dx=U5I$nQuxsF?5XHM?22 +
+

pluginName; ?>

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ options->allow_intro, 1); ?>> +
+ +
+

+ +

+

+ +

+

+ +

+

+ +

+
options->nofollow, 1); ?> />
: + +
+ + +
+ + +
.
+
+
+
diff --git a/includes/widget-form.php b/includes/widget-form.php new file mode 100644 index 0000000..9a1e4bd --- /dev/null +++ b/includes/widget-form.php @@ -0,0 +1,129 @@ + +

+ + + +

+

+ + +

+options->allow_intro ) : ?> +

+ +

+

+ +

+ +

+ + + + +

+

+ /> + + + + +

+

+ /> + + + + +

+

+ /> + + + + +

+

+

+ /> + + /> + + /> + + /> + +

+

+ + +

+ +

+

+ /> + +

+

+ + + . +

diff --git a/js/better-twitter-widget.js b/js/better-twitter-widget.js new file mode 100644 index 0000000..a0a3977 --- /dev/null +++ b/js/better-twitter-widget.js @@ -0,0 +1,45 @@ +/** + * better-rss-widget.js - Javascript for the Settings page. + * + * @package Better Twitter Widget + * @subpackage includes + * @author Max Mehl + * @copyright 2016 + * @access public + * @since 2.1 + */ + +/* Function to search for shortcode in post types. */ +function better_rss_widget_search() { + var type = document.getElementById('better_rss_search_type').value; + var url = document.getElementById('better_rss_url').value; + window.location = url + type; +} + +/* Function to submit the form from the save settings tab */ +function better_rss_widget_save_settings () { + document.getElementById('better_rss_widget_settings').submit(); +} +/* Function to change tabs on the settings pages */ +function better_rss_widget_show_tab(tab) { + /* Close Active Tab */ + activeTab = document.getElementById('active_tab').value; + document.getElementById('better_rss_widget_box_' + activeTab).style.display = 'none'; + document.getElementById('better_rss_widget_' + activeTab).removeAttribute('class','better-rss-widget-selected'); + + /* Open new Tab */ + document.getElementById('better_rss_widget_box_' + tab).style.display = 'block'; + document.getElementById('better_rss_widget_' + tab).setAttribute('class','better-rss-widget-selected'); + document.getElementById('active_tab').value = tab; +} + +/* Function to verify selection to reset options */ +function better_rss_widget_reset(element) { + if (element.checked) { + if (prompt('Are you sure you want to reset all of your options? To confirm, type the word "reset" into the box.') == 'reset' ) { + document.getElementById('better_rss_widget_settings').submit(); + } else { + element.checked = false; + } + } +} diff --git a/lang/better-twitter-widget.pot b/lang/better-twitter-widget.pot new file mode 100644 index 0000000..e4bb81f --- /dev/null +++ b/lang/better-twitter-widget.pot @@ -0,0 +1,427 @@ +# Copyright (C) 2012 Better RSS Widget - Twitter Version +# This file is distributed under the same license as the Better RSS Widget - Twitter Version package. +msgid "" +msgstr "" +"Project-Id-Version: Better RSS Widget - Twitter Version 2.6\n" +"Report-Msgid-Bugs-To: http://wordpress.org/tag/better-rss-widget\n" +"POT-Creation-Date: 2012-12-28 21:07:23+00:00\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"PO-Revision-Date: 2012-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" + +#. #-#-#-#-# better-rss-widget.pot (Better RSS Widget - Twitter Version 2.6) #-#-#-#-# +#. Plugin Name of the plugin/theme +#: better-rss-widget.php:51 +msgid "Better RSS Widget - Twitter Version" +msgstr "" + +#: better-rss-widget.php:53 +msgid "Replaces the built in RSS Widget adding more options. By Max Mehl." +msgstr "" + +#: better-rss-widget.php:127 +msgid " Settings" +msgstr "" + +#: better-rss-widget.php:172 +msgid "Settings" +msgstr "" + +#: better-rss-widget.php:255 +msgid "Unknown Feed" +msgstr "" + +#: better-rss-widget.php:278 +msgid "Syndicate this content" +msgstr "" + +#: better-rss-widget.php:314 +msgid "RSS Error: %s" +msgstr "" + +#: better-rss-widget.php:351 +msgid "An error has occurred; the feed is probably down. Try again later." +msgstr "" + +#: better-rss-widget.php:370 +msgid "Untitled" +msgstr "" + +#: includes/footer.php:19 +msgid "Credits" +msgstr "" + +#: includes/footer.php:23 +msgid "" +"Thank you for trying the %1$s plugin - I hope you find it useful. For the " +"latest updates on this plugin, vist the %2$s. If you have problems with this " +"plugin, please use our %3$s or check out the %4$s." +msgstr "" + +#: includes/footer.php:25 +msgid "official site" +msgstr "" + +#: includes/footer.php:26 +msgid "Support Forum" +msgstr "" + +#: includes/footer.php:27 includes/sidebar-frame.php:33 +msgid "Documentation Page" +msgstr "" + +#: includes/footer.php:33 +msgid "This plugin is © %1$s by %2$s and is released under the %3$s" +msgstr "" + +#: includes/footer.php:36 +msgid "GNU General Public License" +msgstr "" + +#: includes/footer.php:43 +msgid "Donate" +msgstr "" + +#: includes/footer.php:46 +msgid "" +"If you find this plugin useful, please consider supporting this and our " +"other great %1$s." +msgstr "" + +#: includes/footer.php:46 +msgid "plugins" +msgstr "" + +#: includes/footer.php:47 +msgid "Donate a few bucks!" +msgstr "" + +#: includes/settings/administration.php:19 includes/settings.php:29 +msgid "Administration" +msgstr "" + +#: includes/settings/administration.php:25 +msgid "Reset to default" +msgstr "" + +#: includes/settings/administration.php:29 +msgid "Shortcode Search" +msgstr "" + +#: includes/settings/administration.php:31 +msgid "Search for instances of the shortcode in" +msgstr "" + +#: includes/settings/administration.php:33 +msgid "Search" +msgstr "" + +#: includes/settings/administration.php:39 +msgid "Back-up Options" +msgstr "" + +#: includes/settings/administration.php:43 +msgid "Restore Options" +msgstr "" + +#: includes/settings/cache.php:20 +msgid "Feed Cache Settings" +msgstr "" + +#: includes/settings/cache.php:25 +msgid "RSS Cache" +msgstr "" + +#: includes/settings/cache.php:27 +msgid "Enabled" +msgstr "" + +#: includes/settings/cache.php:28 +msgid "Disabled" +msgstr "" + +#: includes/settings/cache.php:32 includes/widget-form.php:143 +msgid "" +"Cache Duration (seconds)
ex. 3600 seconds = 60 minutes" +msgstr "" + +#: includes/settings/cache.php:33 includes/widget-form.php:146 +msgid "seconds" +msgstr "" + +#: includes/settings/display.php:19 +msgid "Default Display Settings" +msgstr "" + +#: includes/settings/display.php:30 +msgid "Use Intro Text?" +msgstr "" + +#: includes/settings/display.php:36 +msgid "Default Link Target" +msgstr "" + +#: includes/settings/display.php:40 includes/widget-form.php:111 +msgid "New Window" +msgstr "" + +#: includes/settings/display.php:41 includes/widget-form.php:112 +msgid "Top Window" +msgstr "" + +#: includes/settings/display.php:46 +msgid "Display items" +msgstr "" + +#: includes/settings/display.php:50 +msgid "Item Summary" +msgstr "" + +#: includes/settings/display.php:55 +msgid "Item Author" +msgstr "" + +#: includes/settings/display.php:64 +msgid "Item Date" +msgstr "" + +#: includes/settings/display.php:70 +msgid "Item Time" +msgstr "" + +#: includes/settings/display.php:75 includes/widget-form.php:102 +msgid "Add nofollow to links" +msgstr "" + +#: includes/settings/display.php:79 +msgid "Default Items to Display" +msgstr "" + +#: includes/settings/display.php:89 +msgid "Max Length of Title" +msgstr "" + +#: includes/settings/display.php:92 +msgid "( Enter \"0\" for no limit. )" +msgstr "" + +#: includes/settings/display.php:96 +msgid "Length of Excerpt" +msgstr "" + +#: includes/settings/display.php:100 +msgid "Add after the excerpt" +msgstr "" + +#: includes/settings/page.php:19 +msgid "Default Page Settings" +msgstr "" + +#: includes/settings/page.php:25 +msgid "Decide which boxes will be checked automatically on the widgets form." +msgstr "" + +#: includes/settings/page.php:28 includes/widget-form.php:120 +msgid "Home Page" +msgstr "" + +#: includes/settings/page.php:29 includes/widget-form.php:121 +msgid "Front Page" +msgstr "" + +#: includes/settings/page.php:30 includes/widget-form.php:126 +msgid "Archive Page" +msgstr "" + +#: includes/settings/page.php:31 includes/widget-form.php:127 +msgid "Category Page" +msgstr "" + +#: includes/settings/page.php:34 includes/widget-form.php:128 +msgid "Tag Page" +msgstr "" + +#: includes/settings/page.php:35 includes/widget-form.php:122 +msgid "Search Page" +msgstr "" + +#: includes/settings/page.php:36 +msgid "Post Page" +msgstr "" + +#: includes/settings/page.php:37 includes/widget-form.php:129 +msgid "Date Page" +msgstr "" + +#: includes/settings.php:26 +msgid "Display Settings" +msgstr "" + +#: includes/settings.php:27 +msgid "Page Settings" +msgstr "" + +#: includes/settings.php:28 includes/widget-form.php:134 +msgid "Cache Settings" +msgstr "" + +#: includes/settings.php:38 +msgid "Plugin Settings" +msgstr "" + +#: includes/settings.php:41 +msgid "Better RSS Widget - Twitter Version settings have been reset to defaults." +msgstr "" + +#: includes/settings.php:54 +msgid "Save Settings" +msgstr "" + +#: includes/sidebar-frame.php:19 +msgid "Plugin Information" +msgstr "" + +#: includes/sidebar-frame.php:22 +msgid "" +"This page sets the defaults for the plugin. Each of these settings can be " +"overridden when you add an index to your page." +msgstr "" + +#: includes/sidebar-frame.php:23 +msgid "You are using" +msgstr "" + +#: includes/sidebar-frame.php:28 +msgid "Usage" +msgstr "" + +#: includes/sidebar-frame.php:32 +msgid "" +"See the %1$s for this plugin for more details on what each of these settings " +"does." +msgstr "" + +#: includes/sidebar-frame.php:39 +msgid "Recent Contributors" +msgstr "" + +#: includes/sidebar-frame.php:42 +msgid "" +"GrandSlambert would like to thank these wonderful contributors to this " +"plugin!" +msgstr "" + +#: includes/widget-form.php:18 +msgid "Give the Feed a Title (optional):" +msgstr "" + +#: includes/widget-form.php:23 +msgid "Do not link" +msgstr "" + +#: includes/widget-form.php:28 +msgid "Title URL (blank for RSS feed):" +msgstr "" + +#: includes/widget-form.php:35 +msgid "Text to display above the links:" +msgstr "" + +#: includes/widget-form.php:43 +msgid "Show" +msgstr "" + +#: includes/widget-form.php:51 +msgid "items from" +msgstr "" + +#: includes/widget-form.php:58 +msgid "Show feed icon before title" +msgstr "" + +#: includes/widget-form.php:60 +msgid "and link icon to" +msgstr "" + +#: includes/widget-form.php:61 +msgid "RSS Url" +msgstr "" + +#: includes/widget-form.php:62 +msgid "Title Url" +msgstr "" + +#: includes/widget-form.php:67 +msgid "Limit length of title to" +msgstr "" + +#: includes/widget-form.php:72 includes/widget-form.php:83 +msgid "characters." +msgstr "" + +#: includes/widget-form.php:78 +msgid "Display item summary limited to" +msgstr "" + +#: includes/widget-form.php:86 +msgid "Additional Fields" +msgstr "" + +#: includes/widget-form.php:90 +msgid "Author" +msgstr "" + +#: includes/widget-form.php:94 +msgid "Date" +msgstr "" + +#: includes/widget-form.php:98 +msgid "Time" +msgstr "" + +#: includes/widget-form.php:107 +msgid "Link Target:" +msgstr "" + +#: includes/widget-form.php:110 +msgid "None" +msgstr "" + +#: includes/widget-form.php:115 +msgid "Display this widget on" +msgstr "" + +#: includes/widget-form.php:116 +msgid "" +"To display on Category or Tag pages you must also include the \"Archive\" " +"page." +msgstr "" + +#: includes/widget-form.php:123 +msgid "Single Post" +msgstr "" + +#: includes/widget-form.php:138 +msgid "Enable Cache?" +msgstr "" + +#. Plugin URI of the plugin/theme +msgid "http://grandslambert.tk/plugins/better-rss-widget.html" +msgstr "" + +#. Description of the plugin/theme +msgid "" +"Replacement for the built in RSS widget that adds an optional link target, " +"shortcode_handler, and page conditionals." +msgstr "" + +#. Author of the plugin/theme +msgid "grandslambert" +msgstr "" + +#. Author URI of the plugin/theme +msgid "http://grandslambert.tk/" +msgstr "" diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..fe91dd0 --- /dev/null +++ b/readme.txt @@ -0,0 +1,263 @@ +=== Better RSS Widget - Twitter Version === +Contributors: Max Mehl +Tags: rss, link, list, target, feed, syndicate, shortcode, posts, page, twitter +Requires at least: 2.5 +Tested up to: 4.5.3 +Stable tag: trunk +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Enhanced version of GrandSlamberts Better RSS Widget that specifically supports generated RSS feeds from Twitter (generated by a service like "Rss Bridge") + +== Description == + +Enhanced version of GrandSlamberts Better RSS Widget that specifically supports generated RSS feeds from Twitter (generated by a service like "Rss Bridge") + += Usage Notice = + +This plugin does not, and cannot replace the existing RSS Widget. Once you install, activate, and configure this plugin you must go to your Widgets page and either replace existing RSS widgets with the new widget, or add new Better RSS Widgets. + += Features = + +* Add title or post tags to the feed URL in the shortcode. +* Excerpt length can be set in both the widget and the shortcode. +* Limit the number of characters to display for the title of the post. +* Add text or html before the list of posts on widgets. +* Shortcode to allow embedding RSS feeds into posts and pages. +* Choose whether to cache the RSS feed and set the cache duration per feed, defaults to 3600 seconds (1 hour). +* Option to display the post time. +* Allows multiple widgets each with different settings. +* Adds the link target to both the RSS Title and all articles. +* Default settings screen allows you to decide what defaults will appear when adding a new widget. + += Languages = + +This plugin includes the following translations. Translations listed with no translator were created by the plugin developer using Google Translate. If you can improve these, you can get your name listed here! + +* English +* Spanish +* Italian +* German +* French + +== Installation == + +1. Upload `better-rss-widget` folder to the `/wp-content/plugins/` directory +2. Activate the plugin through the 'Plugins' menu in WordPress +3. Configure the defaults on the options menu screen. +4. Add new "Better RSS Widgets" or replace existing "RSS" widgets to use the new settings. + +== Changelog == + += 2.7.1 - January 11th, 2015 = + +* Emergency release to fix missing widgets. + += 2.7.0 - January 10th, 2016 = + +* Tested and made enhancements to work with the latest version of WordPress (4.4.1) +* Added option to change the HTML tags used for the list. +* Fixed link to support to use the WordPress support area. +* Removed the "Display this widget on" feature. Please use JetPack's Widget Visibility feature for this. + += 2.6.1 - December 28th, 2012 = + +* Quick fix to properly display the list of contributors. + += 2.6 - December 28th, 2012 = + +* Updated links in preparation for new features. +* Fixed errors in language file so all text can be translated. +* Added the ability to include a short description before the list. + += 2.5 - March 1st, 2011 = + +* Changed the language on the widget form to make the page selection more clear. +* Defaulted all display settings to checked for easier installs. +* Fixed a bug that did not keep all settings set when saving widget settings. + += 2.4 - February 27th, 2011 = + +* Changed the plugin options to use an object for cleaner code. +* Turned on the RSS Cache by default. Can be turned off in settings. +* Added default options in settings to the shortcode display - now follows your settings. +* Fixed an error where the link target setting was not used in the shortcode. +* Shortcode now uses the cache if it is enable in the plugin settings. +* Added an option on the administration tab to search for instances of shortcode in all post types. +* Added language translations for Spanish, French, German, and Italian. + += 2.3 - February 24th, 2011 = + +* Changed some code to work with the newly released WordPress 3.1 version. +* Removed some error code during the plugin activation sequence. +* Fixed a couple errors in the langauge settings. +* Fixed the reset and save settings tabs so they do not conflict with other plugins. + += 2.2 - February 15th, 2011 = + +* Fixed an issue where the link target setting was not working. +* Fixed an issue on the widget form that prevented some settings from being unset. +* Fixed an issue where the feed title was not used with the form title was left blank. + += 2.1 - February 11th, 2011 = + +* Cleaned up code to remove extra stuff and reduce load. +* Updated the settings screen to use my standard tabs. +* Fixed a bug that would not allow you to set the target of links to none. +* Fixed a bug that would force default settings over widget settings. +* Added an option to link the RSS Icon to either the RSS URL or the URL entered for the title of the widget. +* Added an option to not link the title of the widget. +* Adjusted the widget form to reduce the height. + += 2.0 - July 22nd, 2010 = + +* Fixed a bug that caused IE8 to display all text after a feed as a link. +* Fixed broken links on the settings page. +* Fixed a few text entries to allow full language translation. + += 1.9 - June 3rd, 2010 = + +* Added the ability to set the number of words for item descriptions. +* Added option to set the link URL for the feed title. +* Added option in sidebar widget to hide the feed icon. + += 1.8.1 - May 11th, 2010 = + +* Fixing a bug created by adding the features in 1.8. + += 1.8 - May 11th, 2010 = + +* Added option for shortcode to use title or tags in the feed URL. + += 1.7 - May 11th, 2010 = + +* Fixed some code issues that were causing problems in 2.9.2. +* Added fields to make it easier to translate the plugin. + += 1.6 - December 18th, 2009 = + +* Fixed a bug where the widget defaults were overridding the instance settings. + += 1.5 - December 18th, 2009 = + +* Added two new global options, excerpt length and exerpt prefix. +* I really SHOULD look at all the suggestions when doing upgrades. :) + += 1.4 - December 17th, 2009 = + +* Added option to add a nofollow tag to all links. +* Converted the options to save in one record instead of multiple records. +* Code cleanup and optimization. + += 1.3 - December 17th, 2009 = + +* Removed a line of debug code that displayed with the shortcode. + += 1.2 - December 17th, 2009 = + +* Removed code that caused the plugin to cause fatal errors on PHP4 servers. + += 1.1 - December 17th, 2009 = + +* Fixed a bug so the plugin works in Wordpress MU. +* Added an option to the shortcode to display only the content, or the title if the content is blank. + += 1.0 - December 11th, 2009 = + +* Added conditionals to the widget to limit display to certain page types. + += 0.9 - November 21st, 2009 = + +* Added a shortcode to allow embedding RSS feeds into posts and pages. + += 0.8.5 - October 27th, 2009 = + +* Removed some debugging code left during the 0.8 upgrade. + += 0.8 - October 26th, 2009 = + +* Added option to disable the feed cache (enabled by default). +* Change the default cache duration from 12 hours, set by Wordpress, to 1 hour. +* Added option to set the cache duration globally and per widget. +* Added option to display the time for items. +* Fixed a bug where the default settings were not being used in the widget form. + += 0.7 - October 24th, 2009 = + +* Fixed an error that prevent the widget form appearing on servers running PHP4. +* Cleaned up the code and fixed a security issue. +* Added a screenshot of the new screen. + += 0.6 - October 16th, 2009 = + +* Fixed a bug that caused a problem on older versions of RSS feeds. + += 0.5 - October 14th, 2009 = + +* First release + +== Upgrade Notice == + += 2.7.1 = +Emergency maintenance release to fix missing widgets. No changes needed. + += 2.7.0 = +If you are using the option to display a widget on specific pages, you must update your widgets as this feature has been removed. + += 2.6.1 = +Maintenance release. + += 2.6 = +Fixes a language issue and adds the ability to include text before links. + += 2.5 = +Fixes issues with the form and checkbox defaults. + += 2.4 = +Fixes the shortcode to use target and cache. + += 2.3 = +Fixes issues in the settings page so reset and save work properly. + += 2.1 = +Code cleanup - nothing new so not required. + += 2.0 = +Fixes bugs that cause issues in Internet Explorer 8. + += 1.9 = +Great new features to customize your feed. + += 1.6 = +Upgrade IMMEDIATELY - version 1.5 is broken. + += 1.4 = +Not required, just adds new features. + += 1.3 = +Required update to remove bug testing output on your site. + += 1.2 = +Required update if running Wordpress on a PHP4 server. + += 1.1 = +This version fixes a bug that prevents saving plugin settings on Wordpress MU. + +== Frequently Asked Questions == + += Why this plugin when there is already an RSS Widget? = + +At the time this plugin was created (Wordpress version 2.8.4), the built in widget did not have an option to force RSS links to open in a new window. The only way to do this was to hack into the core code of Wordpress, which is not recommended. It is hoped that eventually Wordpress will simply add this option to their widget, but until then, this becomes a quick and easy solution. + += Where can I get support? = + +http://wordpress.org/support/plugin/better-rss-widget + +== Screenshots == + +1. Sample output for the sidebar. +2. The form for setting up the widget. +3. Cache Settings page. +4. Page Settings where you can select the default pages to show the widget on. +5. Plugin settings page. +6. Sample output from the shortcode with date and summary.