WordPress.org

Plugin Directory

Changeset 348497


Ignore:
Timestamp:
02/21/11 06:33:21 (3 years ago)
Author:
kirilln
Message:
  • New feature: ability to get Cache Manager addon ($) that allows to backup/restore cache and delete individual tweets
  • New feature: if you use custom field "tb_tags" for a post its value overrides actual tags and gets used by Tweet Blender for Tags widget (requested by Thomas P via GetSatisfaction)
  • Bug fix: multiple escapes for filter phrases in quotes broke searches (thanks to @drtanz for reporting via WP Forums)
  • Bug fix: problem retrieving cached tweets for hashtags when API limit is reached
  • Bug fix: filters now support words in any lanugage, not just in English (thanks to Dmitry Sh for reporting via Facebook)
  • Bug fix: Twitter default number of search results (15) was returned even when widget was configured to show more (thanks to Brent S for reporting via GetSatisfaction)
  • Bug fix: non-English hashtags support (thanks to Esben R for reporting via GetSatisfaction)
  • Bug fix: jQuery conflict with CadabraPress theme (thanks to Dave G for reporting via GetSatisfaction)
  • Bug fix: multiple tweets created at the same second by the same user had only the first one show up in the stream
  • Improvement: switched to new Twitter API endpoint for user timelines
  • Improvement: "Loading tweets" message now hides if Twitter had an error and loading is done
  • Improvement: Made admin section use the latest jquery shipping with WP and stopped bundling local copy with plugin
  • Tested with WordPress 3.0.3, 3.0.4, 3.0.5
Location:
tweet-blender/trunk
Files:
11 added
11 edited

Legend:

Unmodified
Added
Removed
  • tweet-blender/trunk/admin-page.php

    r317884 r348497  
    11<?php 
    22 
    3 // Version 3.2.3 
     3// Version 3.3.0 
     4 
     5$tb_installed_addons = array(); 
     6$tb_active_addons = array(); 
     7 
     8// check for addons 
     9function tb_check_addons() { 
     10 
     11    global $tb_installed_addons, $tb_active_addons, $tb_addons; 
     12     
     13    foreach($tb_addons as $addon_id => $addon) { 
     14        $addon_file = $addon['slug'] . '/' . $addon['slug'] . '.php'; 
     15        if (file_exists(WP_PLUGIN_DIR . '/' . $addon_file)) {  
     16            $tb_installed_addons[$addon_id] = true; 
     17            if(is_plugin_active($addon_file)) { 
     18                $tb_active_addons[$addon_id] = true; 
     19            } 
     20            else { 
     21                $tb_active_addons[$addon_id] = false; 
     22            } 
     23        } 
     24        else { 
     25            $tb_installed_addons[$addon_id] = false; 
     26        } 
     27    } 
     28     
     29    return false; 
     30} 
    431 
    532function tb_admin_load_scripts() { 
    6     wp_enqueue_script('jq', '/' . PLUGINDIR . '/tweet-blender/js/jquery-1.3.2.min.js'); 
    7     wp_enqueue_script('jq-ui', '/' . PLUGINDIR . '/tweet-blender/js/jquery-ui.js',array('jq')); 
    8     wp_enqueue_script('jq-ui-tabs', '/' . PLUGINDIR . '/tweet-blender/js/ui.tabs.js',array('jq','jq-ui')); 
    9     wp_enqueue_script('tweet-blender-admin', '/' . PLUGINDIR . '/tweet-blender/js/admin.js',array('jq','jq-ui','jq-ui-tabs')); 
     33 
     34    wp_enqueue_script('jquery'); 
     35    wp_enqueue_script('jquery-ui-core'); 
     36    wp_enqueue_script('jquery-ui-tabs'); 
     37    wp_enqueue_script('jquery-lightbox', '/' . PLUGINDIR . '/tweet-blender/js/jquery.lightbox-0.5.min.js',array('jquery')); 
     38    wp_enqueue_script('tb-admin', '/' . PLUGINDIR . '/tweet-blender/js/admin.js',array('jquery','jquery-ui-core','jquery-ui-tabs','jquery-lightbox')); 
    1039} 
    1140 
    1241function tb_admin_load_styles() { 
     42 
    1343    wp_enqueue_style('tweet-blender-css', '/' . PLUGINDIR .'/tweet-blender/css/admin.css'); 
    1444    wp_enqueue_style('jquery-ui-css', '/' . PLUGINDIR . '/tweet-blender/css/jquery-ui/jquery-ui.css'); 
    1545    wp_enqueue_style('jquery-tabs-css', '/' . PLUGINDIR . '/tweet-blender/css/jquery-ui/ui.tabs.css'); 
     46    wp_enqueue_style('jquery-lightbox-css', '/' . PLUGINDIR . '/tweet-blender/css/jquery.lightbox-0.5.css'); 
    1647} 
    1748 
     
    1950add_action('admin_menu', 'tb_admin_menu'); 
    2051function tb_admin_menu() { 
     52 
     53    global $tb_installed_addons, $tb_active_addons, $tb_addons; 
     54 
     55    // add hooks for Tweet Blender admin 
    2156    $pagehook = add_options_page('Tweet Blender Settings', 'Tweet Blender', 'manage_options', __FILE__, 'tb_admin_page'); 
    2257    add_action( 'admin_print_scripts-' . $pagehook, 'tb_admin_load_scripts' ); 
    2358    add_action( 'admin_print_styles-' . $pagehook, 'tb_admin_load_styles' ); 
     59 
     60    // add hooks for addons 
     61    tb_check_addons(); 
     62    foreach($tb_addons as $addon_id => $addon) { 
     63        $addon_file = $addon['slug'] . '/' . $addon['slug'] . '.php'; 
     64         
     65        if ($tb_installed_addons[$addon_id] && $tb_active_addons[$addon_id]) { 
     66            include_once(WP_PLUGIN_DIR . '/' . $addon_file); 
     67             
     68            add_action( 'admin_print_scripts-' . $pagehook, 'tb_admin_load_scripts_addon' . $addon_id ); 
     69            add_action( 'admin_print_styles-' . $pagehook, 'tb_admin_load_styles_addon' . $addon_id ); 
     70        } 
     71    } 
    2472} 
    2573 
    2674function tb_admin_page() { 
    27   
    28     global $tb_option_names, $tb_option_names_system, $tb_keep_tweets_options, $tb_languages, $cache_clear_results, $tb_throttle_time_options; 
     75 
     76    global $tb_option_names, $tb_option_names_system, $tb_keep_tweets_options, $tb_languages, $cache_clear_results, $tb_throttle_time_options, $tb_installed_addons, $tb_active_addons, $tb_package_names; 
     77 
     78    $upgrade_message = ''; 
     79 
     80    // if add-on installation is requested, perform it 
     81    if (isset($_GET['install_addon'])) { 
     82         
     83        // get item number 
     84        if (isset($_POST['item_number'])) { 
     85            $item_number = $_POST['item_number']; 
     86        } 
     87        elseif (isset($_GET['item_number'])) { 
     88            $item_number = $_GET['item_number']; 
     89        } 
     90        else { 
     91            echo 'Error: addon ID was not specified'; 
     92        } 
     93 
     94        // store transaction ID to prefs for future auto updates 
     95        if (isset($_POST['txn_id']) && $item_number) { 
     96            tb_save_txn_id($item_number, $_POST['txn_id']); 
     97        } 
     98 
     99        // perform installation 
     100        tb_download_package($item_number);       
     101         
     102        return; 
     103    } 
     104    // check for new versions of addons if we haven't checked recently 
     105    elseif (!get_transient('tb_addon_checked_upgrade')) { 
     106 
     107        foreach($tb_package_names as $item_number => $name) { 
     108             
     109            // if user purchased the addon 
     110            if ($txn_id = tb_get_txn_id($item_number)) { 
     111 
     112                $response = wp_remote_get('http://tweetblender.com/check_upgrade.php?item_number=' . $item_number . '&blog_url=' . urlencode(get_bloginfo('url')) . '&txn_id=' . $txn_id); 
     113                 
     114                if(!is_wp_error($response)) { 
     115                    if (isset($response['headers']['have-newer-version']) && $response['headers']['have-newer-version'] == 1) { 
     116                        $upgrade_message .= 'Newer version of ' . $name . ' is available - <a href="' . tb_get_current_page_url() . '&install_addon=1&item_number=' . $item_number . '">upgrade</a>. '; 
     117                    } 
     118                } 
     119            } 
     120        } 
     121 
     122        // don't check again for 24 hours 
     123        set_transient('tb_addon_checked_upgrade', true, 60*60*24); 
     124    } 
    29125 
    30126    // Read in existing option values from database 
     
    48144    } 
    49145                     
    50         // See if the user has posted us some information 
     146    // See if the user has posted us some information 
    51147    if( isset($_POST['tb_new_data']) && $_POST['tb_new_data'] == 'Y' ) { 
    52148 
    53149        // check nonce 
    54         check_admin_referer('tweet-blender_settings-save'); 
     150        check_admin_referer('tweet_blender_settings_save','tb_nonce'); 
    55151 
    56152        // if we are disabling cache - clear it 
     
    128224 
    129225    } 
     226     
     227    // if addon installation was cancelled by user, show message 
     228    if (isset($_GET['install_addon']) && $_GET['install_addon'] == 0) { 
     229        $message = '<div class="updated"><p><strong>Addon installation was cancelled.</strong> If you have any questions, please use one of the links under the Help tab.</p></div>'; 
     230    } 
     231 
    130232?> 
    131233 
    132234<script type="text/javascript"> 
    133     var lastUsedTabId = <?php if (isset($_POST['tb_tab_index'])) { echo $_POST['tb_tab_index']; } else { echo 0; } ?>; 
     235    var lastUsedTabId = <?php if (isset($_POST['tb_tab_index'])) { echo $_POST['tb_tab_index']; } else { echo 0; } ?>, 
     236    TB_pluginPath = '/<?php echo(PLUGINDIR); ?>/tweet-blender', 
     237    TB_CM_pluginPath = '/<?php echo(PLUGINDIR); ?>/tweet-blender-cache-manager', 
     238    TB_cacheManagerAvailable = <?php if ($tb_installed_addons[1] && $tb_active_addons[1]) { echo 'true'; } else { echo 'false'; } ?>; 
    134239</script> 
    135240 
     
    137242    <div id="icon-tweetblender" class="icon32"><br/></div><h2><?php _e('Tweet Blender', 'mt_trans_domain' ); ?></h2> 
    138243 
    139     <?php if (!empty($message)) { echo $message; }  if (!empty($log_msg)) { echo "<!-- $log_msg -->"; } ?> 
     244    <?php  
     245        if (!empty($upgrade_message)) { echo '<div class="updated"><p>' . $upgrade_message . '</p></div>'; } 
     246        if (!empty($message)) { echo $message; }  if (!empty($log_msg)) { echo "<!-- $log_msg -->"; }  
     247    ?> 
    140248      
    141     <form name="form1" id="form1" method="post" action="<?php echo str_replace( '%7E', '~', esc_attr($_SERVER['REQUEST_URI'])); ?>"> 
    142     <input type="hidden" id="tb_new_data" name="tb_new_data" value="Y"> 
    143     <input type="hidden" id="tb_tab_index" name="tb_tab_index" value=""> 
    144     <?php 
    145     if ( function_exists('wp_nonce_field') ) 
    146         wp_nonce_field('tweet-blender_settings-save'); 
    147     ?> 
    148  
    149249    <div id="tabs"> 
    150     <ul style="height:35px;"> 
     250    <ul> 
    151251        <li><a href="#tab-1"><span>General</span></a></li> 
    152252        <li><a href="#tab-2"><span>Widgets</span></a></li> 
     
    155255        <li><a href="#tab-5"><span>Advanced</span></a></li> 
    156256        <li id="statustab"><a href="#tab-6"><span>Status</span></a></li> 
    157         <li><a href="#tab-7"><span>Help</span></a></li> 
     257        <li id="cache-manager-tab"><a href="#tab-7"><span>Cache</span></a></li> 
     258        <li><a href="#tab-8"><span>Help</span></a></li> 
    158259    </ul> 
     260 
     261    <form name="settings_form" id="settings_form" method="post" action="<?php echo str_replace( '%7E', '~', esc_attr($_SERVER['REQUEST_URI'])); ?>"> 
     262    <input type="hidden" id="tb_new_data" name="tb_new_data" value="Y" /> 
     263    <input type="hidden" id="tb_tab_index" name="tb_tab_index" value="" /> 
     264    <?php 
     265    if ( function_exists('wp_nonce_field') ) 
     266        wp_nonce_field('tweet_blender_settings_save','tb_nonce'); 
     267    ?> 
    159268 
    160269    <div id="tab-1"> 
     
    164273            <th class="th-full" colspan="2" scope="row"> 
    165274            <label for="general_link_urls"> 
    166             <input type="checkbox" name="general_link_urls" <?php checked('on', $tb_o['general_link_urls']); ?>> 
     275            <input type="checkbox" name="general_link_urls" <?php checked('on', $tb_o['general_link_urls']); ?>/> 
    167276            <?php _e("Link http &amp; https URLs insde tweet text", 'mt_trans_domain' ); ?> 
    168277            </label> 
     
    172281            <th class="th-full" colspan="2" scope="row"> 
    173282            <label for="general_link_screen_names"> 
    174             <input type="checkbox" name="general_link_screen_names" <?php checked('on', $tb_o['general_link_screen_names']); ?>> 
     283            <input type="checkbox" name="general_link_screen_names" <?php checked('on', $tb_o['general_link_screen_names']); ?>/> 
    175284            <?php _e('Link @screenname inside tweet text', 'mt_trans_domain' ); ?> 
    176285            </label> 
     
    180289            <th class="th-full" colspan="2" scope="row"> 
    181290            <label for="general_link_hash_tags"> 
    182             <input type="checkbox" name="general_link_hash_tags" <?php checked('on', $tb_o['general_link_hash_tags']); ?>> 
     291            <input type="checkbox" name="general_link_hash_tags" <?php checked('on', $tb_o['general_link_hash_tags']); ?>/> 
    183292            <?php _e("Link #hashtags insde tweet text", 'mt_trans_domain' ); ?> 
    184293            </label> 
     
    189298            <h3>SEO</h3> 
    190299            <label for="general_seo_tweets_googleoff"> 
    191             <input type="checkbox" name="general_seo_tweets_googleoff" <?php checked('on', $tb_o['general_seo_tweets_googleoff']); ?>> 
     300            <input type="checkbox" name="general_seo_tweets_googleoff" <?php checked('on', $tb_o['general_seo_tweets_googleoff']); ?>/> 
    192301            <?php _e('Wrap all tweets with googleoff/googleon tags to prevent indexing', 'mt_trans_domain' ); ?> 
    193302            </label> 
     
    197306            <th class="th-full" colspan="2" scope="row"> 
    198307            <label for="general_seo_footer_googleoff"> 
    199             <input type="checkbox" name="general_seo_footer_googleoff" <?php checked('on', $tb_o['general_seo_footer_googleoff']); ?>> 
     308            <input type="checkbox" name="general_seo_footer_googleoff" <?php checked('on', $tb_o['general_seo_footer_googleoff']); ?>/> 
    200309            <?php _e('Wrap footer with date and time in all tweets with googleoff/googleon tags to prevent indexing', 'mt_trans_domain' ); ?> 
    201310            </label> 
     
    211320            <th class="th-full" colspan="2" scope="row"> 
    212321            <label for="widget_check_sources"> 
    213             <input type="checkbox" name="widget_check_sources" <?php checked('on', $tb_o['widget_check_sources']); ?>> 
     322            <input type="checkbox" name="widget_check_sources" <?php checked('on', $tb_o['widget_check_sources']); ?>/> 
    214323            <?php _e("Check and verify sources when widget settings are saved", 'mt_trans_domain' ); ?> 
    215324            </label> 
     
    219328            <th class="th-full" colspan="2" scope="row"> 
    220329            <label for="widget_show_header"> 
    221             <input type="checkbox" name="widget_show_header" <?php checked('on', $tb_o['widget_show_header']); ?>> 
     330            <input type="checkbox" name="widget_show_header" <?php checked('on', $tb_o['widget_show_header']); ?>/> 
    222331            <?php _e("Show header with Twitter logo and refresh link for each widget", 'mt_trans_domain' ); ?> 
    223332            </label> 
     
    227336            <th class="th-full" colspan="2" scope="row"> 
    228337            <label for="widget_show_photos"> 
    229             <input type="checkbox" name="widget_show_photos" <?php checked('on', $tb_o['widget_show_photos']); ?>> 
     338            <input type="checkbox" name="widget_show_photos" <?php checked('on', $tb_o['widget_show_photos']); ?>/> 
    230339            <?php _e("Show user's photo for each tweet", 'mt_trans_domain' ); ?> 
    231340            </label> 
     
    235344            <th class="th-full" colspan="2" scope="row"> 
    236345            <label for="widget_show_user"> 
    237             <input type="checkbox" name="widget_show_user" <?php checked('on', $tb_o['widget_show_user']); ?>> 
     346            <input type="checkbox" name="widget_show_user" <?php checked('on', $tb_o['widget_show_user']); ?>/> 
    238347            <?php _e("Show author's username for each tweet", 'mt_trans_domain' ); ?> 
    239348            </label> 
     
    243352            <th class="th-full" colspan="2" scope="row"> 
    244353            <label for="widget_show_source"> 
    245             <input type="checkbox" name="widget_show_source" <?php checked('on', $tb_o['widget_show_source']); ?>> 
     354            <input type="checkbox" name="widget_show_source" <?php checked('on', $tb_o['widget_show_source']); ?>/> 
    246355            <?php _e("Show tweet source for each tweet", 'mt_trans_domain' ); ?> 
    247356            </label> 
     
    251360            <th class="th-full" colspan="2" scope="row"> 
    252361            <label for="widget_show_reply_link"> 
    253             <input type="checkbox" name="widget_show_reply_link" <?php checked('on', $tb_o['widget_show_reply_link']); ?>> 
     362            <input type="checkbox" name="widget_show_reply_link" <?php checked('on', $tb_o['widget_show_reply_link']); ?>/> 
    254363            <?php _e("Show reply link for each tweet (on mouse over)", 'mt_trans_domain' ); ?> 
    255364            </label> 
     
    259368            <th class="th-full" colspan="2" scope="row"> 
    260369            <label for="widget_show_follow_link"> 
    261             <input type="checkbox" name="widget_show_follow_link" <?php checked('on', $tb_o['widget_show_follow_link']); ?>> 
     370            <input type="checkbox" name="widget_show_follow_link" <?php checked('on', $tb_o['widget_show_follow_link']); ?>/> 
    262371            <?php _e("Show follow link for each tweet (on mouse over)", 'mt_trans_domain' ); ?> 
    263372            </label> 
     
    273382            <th class="th-full" colspan="2" scope="row"> 
    274383            <label for="archive_is_disabled"> 
    275             <input type="checkbox" id="archive_is_disabled" name="archive_is_disabled" <?php checked('on', $tb_o['archive_is_disabled']); ?>> 
     384            <input type="checkbox" id="archive_is_disabled" name="archive_is_disabled" <?php checked('on', $tb_o['archive_is_disabled']); ?>/> 
    276385            <?php _e('Disable archive page', 'mt_trans_domain' ); ?>  
    277386            </label> 
     
    281390            <th class="th-full" colspan="2" scope="row"> 
    282391            <label for="archive_auto_page"> 
    283             <input type="checkbox" id="archive_auto_page" name="archive_auto_page" <?php checked('on', $tb_o['archive_auto_page']); ?>> 
     392            <input type="checkbox" id="archive_auto_page" name="archive_auto_page" <?php checked('on', $tb_o['archive_auto_page']); ?>/> 
    284393            <?php _e('Create archive page automatically', 'mt_trans_domain' ); ?>  
    285394            </label> 
     
    326435            <th class="th-full" colspan="2" scope="row"> 
    327436            <label for="archive_show_photos"> 
    328             <input type="checkbox" name="archive_show_photos" <?php checked('on', $tb_o['archive_show_photos']); ?>> 
     437            <input type="checkbox" name="archive_show_photos" <?php checked('on', $tb_o['archive_show_photos']); ?>/> 
    329438            <?php _e("Show user's photo for each tweet", 'mt_trans_domain' ); ?> 
    330439            </label> 
     
    334443            <th class="th-full" colspan="2" scope="row"> 
    335444            <label for="archive_show_user"> 
    336             <input type="checkbox" name="archive_show_user" <?php checked('on', $tb_o['archive_show_user']); ?>> 
     445            <input type="checkbox" name="archive_show_user" <?php checked('on', $tb_o['archive_show_user']); ?>/> 
    337446            <?php _e("Show author's username for each tweet", 'mt_trans_domain' ); ?> 
    338447            </label> 
     
    342451            <th class="th-full" colspan="2" scope="row"> 
    343452            <label for="archive_show_source"> 
    344             <input type="checkbox" name="archive_show_source" <?php checked('on', $tb_o['archive_show_source']); ?>> 
     453            <input type="checkbox" name="archive_show_source" <?php checked('on', $tb_o['archive_show_source']); ?>/> 
    345454            <?php _e("Show tweet source", 'mt_trans_domain' ); ?> 
    346455            </label> 
     
    350459            <th class="th-full" colspan="2" scope="row"> 
    351460            <label for="archive_show_reply_link"> 
    352             <input type="checkbox" name="archive_show_reply_link" <?php checked('on', $tb_o['archive_show_reply_link']); ?>> 
     461            <input type="checkbox" name="archive_show_reply_link" <?php checked('on', $tb_o['archive_show_reply_link']); ?>/> 
    353462            <?php _e("Show reply link for each tweet (on mouse over)", 'mt_trans_domain' ); ?> 
    354463            </label> 
     
    358467            <th class="th-full" colspan="2" scope="row"> 
    359468            <label for="archive_show_follow_link"> 
    360             <input type="checkbox" name="archive_show_follow_link" <?php checked('on', $tb_o['archive_show_follow_link']); ?>> 
     469            <input type="checkbox" name="archive_show_follow_link" <?php checked('on', $tb_o['archive_show_follow_link']); ?>/> 
    361470            <?php _e("Show follow link for each tweet (on mouse over)", 'mt_trans_domain' ); ?> 
    362471            </label> 
     
    411520        <tr valign="top"> 
    412521            <th class="th-full" colspan="2" scope="row"> 
    413             <input type="checkbox" name="filter_hide_same_text" <?php checked('on', $tb_o['filter_hide_same_text']); ?>> 
     522            <input type="checkbox" name="filter_hide_same_text" <?php checked('on', $tb_o['filter_hide_same_text']); ?>/> 
    414523            <label for="filter_hide_same_text"><?php _e("Hide tweets that come from different users but have exactly the same text", 'mt_trans_domain' ); ?></label> 
    415524            </th> 
     
    417526        <tr valign="top"> 
    418527            <th class="th-full" colspan="2" scope="row"> 
    419             <input type="checkbox" name="filter_hide_replies" <?php checked('on', $tb_o['filter_hide_replies']); ?>> 
     528            <input type="checkbox" name="filter_hide_replies" <?php checked('on', $tb_o['filter_hide_replies']); ?>/> 
    420529            <label for="filter_hide_replies"><?php _e("Hide tweets that are in reply to other tweets", 'mt_trans_domain' ); ?></label> 
    421530            </th> 
     
    423532        <tr valign="top"> 
    424533            <th class="th-full" colspan="2" scope="row"> 
    425             <input type="checkbox" name="filter_hide_not_replies" <?php checked('on', $tb_o['filter_hide_not_replies']); ?>> 
     534            <input type="checkbox" name="filter_hide_not_replies" <?php checked('on', $tb_o['filter_hide_not_replies']); ?>/> 
    426535            <label for="filter_hide_not_replies"><?php _e("Hide tweets that are NOT replies to other tweets", 'mt_trans_domain' ); ?></label> 
    427536            </th> 
     
    429538        <tr valign="top"> 
    430539            <th class="th-full" colspan="2" scope="row"> 
    431             <input type="checkbox" name="filter_hide_mentions" <?php checked('on', $tb_o['filter_hide_mentions']); ?>> 
     540            <input type="checkbox" name="filter_hide_mentions" <?php checked('on', $tb_o['filter_hide_mentions']); ?>/> 
    432541            <label for="filter_hide_mentions"><?php _e("Hide mentions of users, only show tweets from users themselves", 'mt_trans_domain' ); ?></label> 
    433542            </th> 
     
    465574            </th> 
    466575            <td valign="top"> 
    467             <textarea id="filter_bad_strings" name="filter_bad_strings" rows=2 cols=60 wrap="soft"><?php if (isset($tb_o['filter_bad_strings'])) { echo $tb_o['filter_bad_strings']; } ?></textarea>  
     576            <textarea id="filter_bad_strings" name="filter_bad_strings" rows=2 cols=60><?php if (isset($tb_o['filter_bad_strings'])) { echo stripslashes($tb_o['filter_bad_strings']); } ?></textarea>  
    468577                <br/> 
    469578                <span class="setting-description">You can use single keywords, usernames, or phrases. Enclose phrases in quotes. Do not use @ for screen names. Separate with commas. Example: #spam,badword,"entire bad phrase",badUser,anotherBadUser,#badHashTag</span> 
     
    479588            <th class="th-full" colspan="2" scope="row"> 
    480589            <label for="advanced_reroute_on"> 
    481             <input type="checkbox" name="advanced_reroute_on" <?php checked('on', $tb_o['advanced_reroute_on']); ?>> 
     590            <input type="checkbox" name="advanced_reroute_on" <?php checked('on', $tb_o['advanced_reroute_on']); ?>/> 
    482591            <?php _e('Re-route Twitter traffic through this server', 'mt_trans_domain' ); ?>  
    483             </label> (<input type="radio" value="oauth" name="advanced_reroute_type" <?php checked('oauth', $tb_o['advanced_reroute_type']); ?>> user account based with oAuth <input type="radio" value="direct" name="advanced_reroute_type" <?php checked('direct', $tb_o['advanced_reroute_type']); ?>> IP based)<br/> 
     592            </label> (<input type="radio" value="oauth" name="advanced_reroute_type" <?php checked('oauth', $tb_o['advanced_reroute_type']); ?>/> user account based with oAuth <input type="radio" value="direct" name="advanced_reroute_type" <?php checked('direct', $tb_o['advanced_reroute_type']); ?>/> IP based)<br/> 
    484593            <span class="setting-description">This option allows you to reroute all API calls to Twitter via your server. This is to be used ONLY if your server is a white-listed server that has higher connection allowance than each individual user.  Each user can make up to 150 Twitter API connections per hour. Each visitor to your site will have their own limit i.e. their own 150. Checking the box will make all visitors to the site use your server's connection limit, not their own limit. If you did not prearranged with Twitter to have that limit increased that means that it will be 150 for ALL visitors - be careful.</span> 
    485594            </th> 
     
    488597            <th class="th-full" colspan="2" scope="row"> 
    489598            <label for="advanced_show_limit_msg"> 
    490             <input type="checkbox" name="advanced_show_limit_msg" <?php checked('on', $tb_o['advanced_show_limit_msg']); ?>> 
     599            <input type="checkbox" name="advanced_show_limit_msg" <?php checked('on', $tb_o['advanced_show_limit_msg']); ?>/> 
    491600            <?php _e('Notify user when Twitter API connection limit is reached', 'mt_trans_domain' ); ?>  
    492601            </label><br/> 
     
    499608            <th class="th-full" colspan="2" scope="row"> 
    500609            <label for="advanced_disable_cache"> 
    501             <input type="checkbox" name="advanced_disable_cache" <?php checked('on', $tb_o['advanced_disable_cache']); ?>> 
     610            <input type="checkbox" name="advanced_disable_cache" <?php checked('on', $tb_o['advanced_disable_cache']); ?>/> 
    502611            <?php _e('Disable data caching', 'mt_trans_domain' ); ?>  
    503612            </label><br/> 
     
    510619            <th scope="row"><label for="general_timestamp_format"><?php _e('Timestamp Format', 'mt_trans_domain' ); ?>: 
    511620            </label></th> 
    512             <td><input type="text" name="general_timestamp_format" value="<?php if (isset($tb_o['general_timestamp_format'])) { echo $tb_o['general_timestamp_format']; } ?>"> <span class="setting-description"><br/> 
     621            <td><input type="text" name="general_timestamp_format" value="<?php if (isset($tb_o['general_timestamp_format'])) { echo $tb_o['general_timestamp_format']; } ?>"/> <span class="setting-description"><br/> 
    513622                leave blank = verbose from now ("4 minutes ago")<br/> 
    514623                h = 12-hour format of an hour with leading zeros ("08")<br/> 
     
    534643            <th class="th-full" colspan="2" scope="row"> 
    535644            <label for="advanced_no_search_api"> 
    536             <input type="checkbox" name="advanced_no_search_api" <?php checked('on', $tb_o['advanced_no_search_api']); ?>> 
     645            <input type="checkbox" name="advanced_no_search_api" <?php checked('on', $tb_o['advanced_no_search_api']); ?>/> 
    537646            <?php _e('Do not use search API for screen names', 'mt_trans_domain' ); ?>  
    538647            </label><br/> 
     
    623732    </div> 
    624733 
     734    </form> 
     735 
    625736    <div id="tab-7"> 
     737 
     738    <?php  
     739        // if Cache Manager is not installed 
     740        if (!$tb_installed_addons[1]) {  
     741    ?> 
     742     
     743    <h2>Cache Manager Is Not Installed</h2> 
     744    <div class="box-left"> 
     745    <p>Install Cache Manager add-on for Tweet Blender and instantly take advantage of the following features:</p> 
     746    <ol class="feature-set"> 
     747        <li>See all the tweets stored in your cache database</li> 
     748        <li>Delete individual tweets or groups of tweets</li> 
     749        <li>Backup and restore your cache</li> 
     750    </ol> 
     751    <p>Click the button below to purchase the add-on for a <b>one time flat fee of $2.99</b>. This will perform a one-click install of a new plugin and you will get FREE upgrades with new features in the future.</p> 
     752    <div class="centered"> 
     753        <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
     754        <input type="hidden" name="cmd" value="_xclick" /> 
     755        <input type="hidden" name="business" value="tweetblender@gmail.com"> 
     756        <input type="hidden" name="lc" value="US"> 
     757        <input type="hidden" name="currency_code" value="USD"> 
     758        <input type="hidden" name="no_note" value="1"> 
     759        <input type="hidden" name="amount" value="2.99" /> 
     760        <input type="hidden" name="item_name" value="Cache Manager for Tweet Blender" /> 
     761        <input type="hidden" name="item_number" value="1" /> 
     762        <input type="hidden" name="no_shipping" value="1" /> 
     763        <input type="hidden" name="custom" value="<?php bloginfo('url'); ?>" /> 
     764        <input type="hidden" name="notify_url" value="http://tweetblender.com/ipn.php" /> 
     765        <input type="hidden" name="image_url" value="http://tweetblender.com/tweet-blender-logo_150x50.png" /> 
     766        <input type="hidden" name="return" value="<?php echo tb_get_current_page_url(); ?>&install_addon=1" /> 
     767        <input type="hidden" name="cbt" value="Return to your site to complete installation" /> 
     768        <input type="hidden" name="cancel_return" value="<?php echo tb_get_current_page_url(); ?>#tab-7" /> 
     769        <input type="submit" name="submit" class="button-secondary" value="Get Cache Manager" /> 
     770        <img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"> 
     771    </form> 
     772     
     773    </div> 
     774    </div> 
     775    <div class="box-right centered"> 
     776        <a href="/<?php echo(PLUGINDIR); ?>/tweet-blender/screenshot-10.png" title="Cache Manager for Tweet Blender"><img class="tb-addon-screenshot" src="/<?php echo(PLUGINDIR); ?>/tweet-blender/img/cache_manager_th.jpg" /></a> 
     777    </div> 
     778 
     779    <?php  
     780        // if Cache Manager is not active 
     781        } else if(!$tb_active_addons[1]) {  
     782    ?> 
     783    <h2>Cache Manager Is Not Active</h2> 
     784    <p>You have the Cache Manager plugin installed but not activated. Please use the [Plugins] menu on the left to activate the plugin</p> 
     785 
     786    <?php 
     787        // else Cache Manager is available 
     788        } else { 
     789            echo tb_cm_get_cache_page_html(); 
     790        }  
     791    ?> 
     792     
     793    </div> 
     794 
     795    <div id="tab-8"> 
    626796    Get Satisfaction Community: <a href="http://getsatisfaction.com/tweet_blender">http://getsatisfaction.com/tweet_blender</a><br/> 
    627797    Facebook Fan Page: <a href="http://www.facebook.com/pages/Tweet-Blender/96201618006">http://www.facebook.com/pages/Tweet-Blender/96201618006</a><br/> 
     
    633803 
    634804    <p class="submit"> 
    635     <input type="submit" class="button-primary" value="<?php _e('Save Settings', 'mt_trans_domain' ) ?>" /> 
     805    <input id="btn_save_settings" type="button" class="button-primary" value="<?php _e('Save Settings', 'mt_trans_domain' ) ?>" /> 
    636806    </p> 
    637 </form> 
    638807</div> 
    639808 
  • tweet-blender/trunk/css/admin.css

    r314317 r348497  
    4444    background:transparent url(/wp-content/plugins/tweet-blender/img/tweetblender-logo_32x32.png) no-repeat; 
    4545} 
     46 
     47img.tb-addon-screenshot { 
     48    border: 3px solid #EEE; 
     49} 
     50 
     51div.centered { 
     52    margin-top: 20px; 
     53    margin-bottom: 20px; 
     54    text-align: center; 
     55    vertical-align: middle; 
     56} 
     57 
     58div.box-left { 
     59    width: 45%; 
     60    display: inline-block; 
     61} 
     62 
     63div.box-right { 
     64    width: 45%; 
     65    float: right; 
     66} 
     67 
     68ol.feature-set { 
     69    margin: 25px; 
     70} 
     71 
     72#filter_bad_strings { 
     73    wrap-option:soft-wrap; 
     74} 
  • tweet-blender/trunk/js/admin.js

    r314317 r348497  
    1010// make tabs 
    1111jQuery(document).ready(function(){ 
     12     
     13    // don't do anything if we are not showing full admin page 
     14    if (jQuery('#icon-tweetblender').length <= 0) { 
     15        return; 
     16    } 
     17 
     18    // Bind event listener to save button 
     19    jQuery('#btn_save_settings').click(function() { 
     20        jQuery('#settings_form').submit(); 
     21    }); 
     22         
     23    // initialize tabs 
    1224    var tabsElement = jQuery("#tabs").tabs({ 
    1325        show:function(event, ui) { 
     
    2335     
    2436    // reopen last used tab 
    25     tabsElement.tabs('select', lastUsedTabId); 
     37    if (typeof(lastUsedTabId) != 'undefined') { 
     38        tabsElement.tabs('select', lastUsedTabId); 
     39    } 
    2640 
    2741    // bind event handler to disable archive checkbox 
     
    5367        } 
    5468    });  
    55  
    5669     
    5770    // if there were any problems, highlight the Status tab 
     
    6073    } 
    6174 
     75    // Cache Manager add-on 
     76    if (typeof(TB_cacheManagerAvailable) == 'undefined' || !TB_cacheManagerAvailable) { 
     77        jQuery('#cache-manager-tab a').css('text-decoration','line-through'); 
     78        jQuery('img.tb-addon-screenshot').parent().lightBox({ 
     79            imageLoading: TB_pluginPath + '/img/lightbox/lightbox-ico-loading.gif', 
     80            imageBtnClose: TB_pluginPath + '/img/lightbox/lightbox-btn-close.gif', 
     81            imageBtnPrev: TB_pluginPath + '/img/lightbox/lightbox-btn-prev.gif', 
     82            imageBtnNext: TB_pluginPath + '/img/lightbox/lightbox-btn-next.gif', 
     83            imageBlank: TB_pluginPath + '/img/lightbox/lightbox-blank.gif', 
     84            txtImage: 'Screenshot', 
     85       }); 
     86    } 
    6287}); 
     88 
     89function TB_showPopup(dialogName) { 
     90    $('#' + dialogName).dialog('open'); 
     91} 
    6392 
    6493 
  • tweet-blender/trunk/js/main.js

    r317884 r348497  
    33 */ 
    44 
    5 var TB_version = '3.2.4',   // Plugin version  
     5var TB_version = '3.3.0',   // Plugin version  
    66TB_rateLimitData, 
    77TB_tmp, 
     
    1313TB_tweetsToCache = new Object(), 
    1414TB_allSources = new Array(), 
    15 jQnc = jQuery.noConflict(), 
     15jQnc = jQuery, 
    1616TB_sourceCounts = new Array(), 
    1717TB_sourceNames = new Array(), 
     
    116116    TB_allSources = TB_getUniqueElements(TB_allSources); 
    117117     
    118     /* check opt out 
    119     jQuery.ajax({ 
    120         dataType: 'jsonp', 
    121         url: 'http://tweet-blender.com/check_optout.php', 
    122         timeout: 500, 
    123         data: ({ 
    124             u: window.location.href, 
    125             s: TB_allSources.join(','), 
    126             v: 'wp_' + TB_version 
    127         }), 
    128         success: function (json) { 
    129             if (!json.ERROR) { 
    130                 if (json.chk == 0) { 
    131                     jQuery('div.tb_tools').css('background-image','url(' + TB_pluginPath + '/img/bg.png)').width(56); 
    132                     jQuery('a.tb_infolink').css('display','inline').css('margin-right','11px'); 
    133                 } 
    134             } 
    135         } 
    136     }); 
    137     */ 
    138118    jQuery('div.tb_tools').css('background-image','url(' + TB_pluginPath + '/img/bg.png)').width(56); 
    139119    jQuery('a.tb_infolink').css('display','inline').css('margin-right','11px'); 
     
    262242            // if we are serving only favorites 
    263243            if (TB_config.widgets[widgetId].favoritesOnly) { 
    264                 TB_addAjaxUrl(widgetId,'favorites',screenName,src,1); 
     244                TB_addAjaxUrl(widgetId,'favorites',{'screen_name':screenName},src,1); 
    265245            } 
    266246            // if we are not using Search API 
    267247            else if (TB_config.advanced_no_search_api) { 
    268                 TB_addAjaxUrl(widgetId,'user_timeline','screen_name=' + screenName,src,1); 
     248                TB_addAjaxUrl(widgetId,'user_timeline',{'screen_name':screenName},src,1); 
    269249            } 
    270250            else { 
    271                 TB_addAjaxUrl(widgetId,'search','&from=' + screenName,src,1); 
     251                TB_addAjaxUrl(widgetId,'search',{'from':screenName},src,1); 
    272252            } 
    273253        } 
     
    288268                } 
    289269 
    290                 TB_addAjaxUrl(widgetId,'favorites',screenName,src,0); 
     270                TB_addAjaxUrl(widgetId,'favorites',{'screen_name':screenName},src,0); 
    291271            } 
    292272            // if it includes modifiers, use a one-off URL 
     
    307287                // if modifier is a hashtag 
    308288                if (modifier.charAt(0) == '#') { 
    309                     TB_addAjaxUrl(widgetId,'search','&from=' + screenName + '&tag=' + modifier.substr(1),src,0); 
     289                    TB_addAjaxUrl(widgetId,'search',{'from':screenName,'tag':modifier.substr(1)},src,0); 
    310290                } 
    311291                else { 
    312                     TB_addAjaxUrl(widgetId,'search','&from=' + screenName + '&ors=' + modifier,src,0); 
     292                    TB_addAjaxUrl(widgetId,'search',{'from':screenName,'ors':modifier},src,0); 
    313293                } 
    314294            } 
     
    328308                // if we are not using Search API 
    329309                if (TB_config.advanced_no_search_api) { 
    330                     TB_addAjaxUrl(widgetId,'user_timeline','screen_name=' +screenName,src,0); 
     310                    TB_addAjaxUrl(widgetId,'user_timeline',{'screen_name':screenName},src,0); 
    331311                } 
    332312                // else, group with other screen names 
     
    334314                    // check to make sure we are not over the query length limit 
    335315                    if (escape(TB_screenNameQueries.join(' OR ')).length + src.length > 140) { 
    336                         TB_addAjaxUrl(widgetId,'search','&q=' + escape(TB_screenNameQueries.join(' OR ')),escape('@'+TB_screenNames.join(',@')),0); 
     316                        TB_addAjaxUrl(widgetId,'search',{'q':TB_screenNameQueries.join(' OR ')},escape('@'+TB_screenNames.join(',@')),0); 
    337317                        TB_screenNames = new Array(); 
    338318                        TB_screenNameQueries = new Array(); 
     
    350330        // if it's a list 
    351331        else if (src.charAt(0) == '@' && src.indexOf('/') > 1) { 
    352             if (TB_config.advanced_reroute_on || TB_config.reached_api_limit) { 
    353                 TB_addAjaxUrl(widgetId,'list_timeline','&user=' + src.substr(1, src.indexOf('/') - 1) + '&list=' + src.substr(src.indexOf('/') + 1),src,0); 
    354             } 
    355             else { 
    356                 TB_addAjaxUrl(widgetId,'list_timeline',src.substr(1, src.indexOf('/') - 1) + '/lists/' + src.substr(src.indexOf('/') + 1) + '/statuses.json',src,0); 
    357             } 
     332            TB_addAjaxUrl(widgetId,'list_timeline',{'user':src.substr(1, src.indexOf('/') - 1),'list':src.substr(src.indexOf('/') + 1)},src,0); 
    358333        } 
    359334        // else it's a hash or keyword  
     
    369344 
    370345            // check to make sure we are not over the query length limit 
    371             if (escape(TB_searchTerms.join(' OR ')).length + src.length > 140) { 
    372                 TB_addAjaxUrl(widgetId,'search','&q=' + escape(TB_searchTerms.join(' OR ')),escape(TB_searchTerms.join(',')),0); 
     346            if (TB_searchTerms.join(' OR ').length + src.length > 140) { 
     347                TB_addAjaxUrl(widgetId,'search',{'q':TB_searchTerms.join(' OR ')},TB_searchTerms.join(','),0); 
    373348                TB_searchTerms = new Array(); 
    374349            } 
    375350            TB_searchTerms.push(src); 
    376  
    377 /* 
    378             // if it's a multi-word keyword give it a dedicated ajax call 
    379             if (src.indexOf(' ') > 0) { 
    380                 TB_addAjaxUrl(widgetId,'search','&q=' + src,src,0); 
    381             } 
    382             // else it will be grouped with the rest 
    383             else { 
    384                 // check to make sure we are not over the query length limit 
    385                 if (escape(TB_searchTerms.join(' ')).length + src.length > 140) { 
    386                     TB_addAjaxUrl(widgetId,'search','&ors=' + escape(TB_searchTerms.join(' ')),escape(TB_searchTerms.join(',')),0); 
    387                     TB_searchTerms = new Array(); 
    388                 } 
    389                 TB_searchTerms.push(src); 
    390             } 
    391 */                   
    392351        } 
    393352    }); 
     
    395354    // if there are terms that are not part of a query - add another query 
    396355    if (TB_searchTerms.length > 0) { 
    397         TB_addAjaxUrl(widgetId,'search','&q=' + escape(TB_searchTerms.join(' OR ')),escape(TB_searchTerms.join(',')),0); 
     356        TB_addAjaxUrl(widgetId,'search',{'q':TB_searchTerms.join(' OR ')},TB_searchTerms.join(','),0); 
    398357    } 
    399358     
    400359    // if there are screenNames - join them into a single query 
    401360    if (TB_screenNames.length > 0) { 
    402         TB_addAjaxUrl(widgetId,'search','&q=' + escape(TB_screenNameQueries.join(' OR ')),escape('@'+TB_screenNames.join(',@')),0); 
    403     } 
    404 } 
    405  
    406 function TB_addAjaxUrl(widgetId,actionType,urlPart,src,isPrivateSrc) { 
    407     var langFilter = '', 
    408     locationFilter = '', 
    409     negativeFilter = '', 
    410     privateParam = ''; 
    411  
     361        TB_addAjaxUrl(widgetId,'search',{'q':TB_screenNameQueries.join(' OR ')},encodeURI('@'+TB_screenNames.join(',@')),0); 
     362    } 
     363} 
     364 
     365function TB_addAjaxUrl(widgetId,actionType,queryData,src,isPrivateSrc) { 
     366     
    412367    // check language filter     
    413368    if (typeof(TB_config['filter_lang']) != 'undefined' && TB_config.filter_lang.length == 2) { 
    414         langFilter = '&lang=' + TB_config.filter_lang; 
     369        queryData.lang = TB_config.filter_lang; 
    415370    } 
    416371    else { 
    417         langFilter = '&lang=all'; 
    418     } 
    419      
    420     /* FUTURE: check location filter     
    421     if (typeof(TB_config['filter_location_name']) != 'undefined' && TB_config.filter_location_name.length > 0) { 
    422         locationFilter = escape('near:' + TB_config.filter_location_name + ' within:' + TB_config.filter_location_dist + TB_config.filter_location_dist_units); 
    423     } 
    424     */ 
    425      
     372        queryData.lang = 'all'; 
     373    } 
     374         
    426375    // check negative keywords 
    427376    if (typeof(TB_config['filter_bad_strings']) != 'undefined' && TB_config.filter_bad_strings.length > 0) { 
    428         negativeFilter = '&nots=' + escape(TB_config.filter_bad_strings.split(',').splice(0,9).join(' ')); 
     377        queryData.nots = TB_config.filter_bad_strings.split(',').splice(0,9).join(' '); 
    429378    } 
    430379     
    431380    // check private 
    432381    if (isPrivateSrc) { 
    433         privateParam = '&private=1'; 
     382        queryData.private  = 1; 
    434383    } 
    435384 
    436385    if (actionType == 'search' && (TB_config.advanced_reroute_on || TB_config.reached_api_limit || isPrivateSrc)) { 
     386        queryData.action = actionType; 
    437387        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    438             'url':TB_pluginPath + '/ws.php?action=search' + urlPart + langFilter + locationFilter + negativeFilter + privateParam, 
     388            'url':TB_pluginPath + '/ws.php', 
     389            'data':queryData, 
    439390            'source':src, 
    440391            'privateSrc':isPrivateSrc, 
     
    443394    } 
    444395    else if (actionType == 'search') { 
     396        queryData.rpp = TB_config.widgets[widgetId]['tweetsNum']; 
    445397        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    446             'url': 'http://search.twitter.com/search.json?' + locationFilter + urlPart + langFilter + negativeFilter, 
     398            'url': 'http://search.twitter.com/search.json', 
     399            'data':queryData, 
    447400            'source':src, 
    448401            'privateSrc':0, 
     
    451404    } 
    452405    else if (actionType == 'list_timeline' && (TB_config.advanced_reroute_on || TB_config.reached_api_limit)) { 
     406        queryData.action = actionType; 
     407        delete queryData.nots; 
     408        delete queryData.lang; 
    453409        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    454             'url':TB_pluginPath + '/ws.php?action=list_timeline' + urlPart, 
     410            'url':TB_pluginPath + '/ws.php', 
     411            'data':queryData, 
    455412            'source':src, 
    456413            'privateSrc':0, 
     
    459416    } 
    460417    else if (actionType == 'list_timeline'){ 
     418        queryData.per_page = TB_config.widgets[widgetId]['tweetsNum']; 
    461419        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    462             'url':'http://api.twitter.com/1/' + urlPart, 
     420            'url':'http://api.twitter.com/1/' + queryData.user + '/lists/' + queryData.list + '/statuses.json', 
     421            'data':queryData, 
    463422            'source':src, 
    464423            'privateSrc':0, 
     
    467426    } 
    468427    else if (actionType == 'user_timeline' && (TB_config.advanced_reroute_on || TB_config.reached_api_limit || isPrivateSrc)) { 
     428        queryData.action = actionType; 
    469429        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    470             'url':TB_pluginPath + '/ws.php?action=user_timeline&' + urlPart, 
     430            'url':TB_pluginPath + '/ws.php', 
     431            'data':queryData, 
    471432            'source':src, 
    472433            'privateSrc':0, 
     
    476437    else if (actionType == 'user_timeline') { 
    477438        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    478             'url': 'http://twitter.com/statuses/user_timeline.json?' + urlPart, 
     439            'data':queryData, 
     440            'url': 'http://api.twitter.com/1/statuses/user_timeline.json', 
    479441            'source':src, 
    480442            'private':0, 
     
    483445    } 
    484446    else if (actionType == 'favorites' && (TB_config.advanced_reroute_on || TB_config.reached_api_limit || isPrivateSrc)) { 
     447        queryData.action = actionType; 
    485448        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    486             'url':TB_pluginPath + '/ws.php?action=favorites&user=' + urlPart, 
     449            'data':queryData, 
     450            'url':TB_pluginPath + '/ws.php', 
    487451            'source':src, 
    488452            'privateSrc':0, 
     
    492456    else if (actionType == 'favorites') { 
    493457        TB_config.widgets[widgetId]['ajaxURLs'].push({ 
    494             'url': 'http://api.twitter.com/1/favorites/' + urlPart + '.json', 
     458            'data':{},  // favorites does not support any params 
     459            'url': 'http://api.twitter.com/1/favorites/' + queryData.screen_name + '.json', 
    495460            'source':src, 
    496461            'private':0, 
     
    524489        } 
    525490        else { 
    526             TB_config.widgets[widgetId].sourcesHTML += 'http://search.twitter.com/search?q=' + escape(src); 
     491            TB_config.widgets[widgetId].sourcesHTML += 'http://search.twitter.com/search?q=' + encodeURI(src); 
    527492        } 
    528493        TB_config.widgets[widgetId].sourcesHTML += '">' + src + '</a> '; 
     
    625590    // iterate over AJAX URLs 
    626591    jQuery.each(TB_config.widgets[widgetId].ajaxURLs,function(i,urlInfo) { 
    627         jQuery.ajax({ 
    628             dataType: urlInfo.dtype, 
    629             url: urlInfo.url, 
    630             success: function (json) { 
    631                 // if we had valid JSON but with error 
    632                 if (json.error) { 
    633                     // if we reached the API limit 
    634                     if (json.error.indexOf('Rate limit exceeded') == 0) { 
    635                         TB_config['reached_api_limit'] = true; 
     592         
     593        // special jsonp use case to ensure proper error handling 
     594        if (urlInfo.dtype == 'jsonp') { 
     595            jQuery.jsonp({ 
     596                data:urlInfo.data, 
     597                callbackParameter: "callback", 
     598                url: urlInfo.url, 
     599                timeout: 2000, 
     600                success: function (json) { 
     601                    // if we had valid JSON but with error 
     602                    if (json.error) { 
     603                        // if we reached the API limit 
     604                        if (json.error.indexOf('Rate limit exceeded') == 0) { 
     605                            TB_config['reached_api_limit'] = true; 
     606                        } 
     607                        TB_config.widgets[widgetId].urlsDone++; 
     608                        TB_checkComplete(widgetId); 
    636609                    } 
     610                    else { 
     611                        TB_addTweets(widgetId,json,urlInfo); 
     612                    } 
     613                }, 
     614                error: function(jqXHR, textStatus, errorThrown) { 
    637615                    TB_config.widgets[widgetId].urlsDone++; 
    638616                    TB_checkComplete(widgetId); 
    639617                } 
    640                 else { 
    641                     TB_addTweets(widgetId,json,urlInfo); 
    642                 } 
    643             }, 
    644             error: function() { 
    645                 TB_config.widgets[widgetId].urlsDone++; 
    646                 TB_checkComplete(widgetId); 
    647             } 
    648         }); 
     618            }); 
     619        } 
     620        else { 
     621            jQuery.ajax({ 
     622                data:urlInfo.data, 
     623                dataType: urlInfo.dtype, 
     624                url: urlInfo.url, 
     625                timeout: 2000, 
     626                success: function (json) { 
     627                    // if we had valid JSON but with error 
     628                    if (json.error) { 
     629                        // if we reached the API limit 
     630                        if (json.error.indexOf('Rate limit exceeded') == 0) { 
     631                            TB_config['reached_api_limit'] = true; 
     632                        } 
     633                        TB_config.widgets[widgetId].urlsDone++; 
     634                        TB_checkComplete(widgetId); 
     635                    } 
     636                    else { 
     637                        TB_addTweets(widgetId,json,urlInfo); 
     638                    } 
     639                }, 
     640                error: function(jqXHR, textStatus, errorThrown) { 
     641                    TB_config.widgets[widgetId].urlsDone++; 
     642                    TB_checkComplete(widgetId); 
     643                } 
     644            }); 
     645        } 
    649646    }); 
    650647} 
     
    11071104     
    11081105    // creates unique div ID for this tweet 
    1109     getDivId = function(tweetDate,screenName) { 
    1110         return 't-' + tweetDate.getTime() + '-' + screenName;    
     1106    getDivId = function(tweetDate,screenName,strId) { 
     1107        return 't-' + tweetDate.getTime() + '-' + screenName + '-' + strId;  
    11111108    } 
    11121109 
    11131110    // div id of the tweet 
    1114     this.divId = getDivId(this.tweetDate,this.screenName); 
     1111    this.divId = getDivId(this.tweetDate,this.screenName,this.id); 
    11151112     
    11161113    // makes HTML for each tweet 
     
    11481145        // link hash tags 
    11491146        if (TB_config.general_link_hash_tags) { 
    1150             textHtml = textHtml.replace(/\#([\w\-]+)/gi,'<a rel="nofollow" href="http://search.twitter.com/search?q=%23$1">#$1</a>');  
     1147            textHtml = textHtml.replace(/\#(\S+)/gi,'<a rel="nofollow" href="http://search.twitter.com/search?q=%23$1">#$1</a>');  
    11511148        } 
    11521149        if (tweetJson.profile_image_url) { 
  • tweet-blender/trunk/lib/lib.php

    r316925 r348497  
    11<?php 
    22 
    3 // Version 3.2.3 
     3// Version 3.3.0 
    44 
    55// aliases for sources 
     
    233233); 
    234234 
     235$tb_addons = array( 
     236    '1' => array( 
     237        'name' => 'Cache Manager', 
     238        'slug' => 'tweet-blender-cache-manager' 
     239    ), 
     240    '2' => array( 
     241        'name' => 'nStyle', 
     242        'slug' => 'tweet-blender-nstyle' 
     243    ), 
     244    '3' => array( 
     245        'name' => 'Tweet Injector', 
     246        'slug' => 'tweet-blender-injector' 
     247    ) 
     248); 
     249 
     250$tb_package_names = array( 
     251    '1' => 'Cache Manager', 
     252    '2' => 'nStyle', 
     253    '3' => 'Tweet Injector' 
     254); 
     255 
     256 
    235257function tb_get_url_content($url) 
    236258{ 
     
    446468 
    447469// creates HTML for the list of tweets using cached tweets 
    448 function tb_get_cached_tweets_html($mode,$instance) { 
     470function tb_get_cached_tweets_html($mode,$instance,$widget_id = '') { 
    449471 
    450472    global $json; 
     
    468490    // get data from DB 
    469491    $tweets_html = ''; 
    470     $tweets = tb_get_cached_tweets($sources, $tweets_to_show); 
     492    $tweets = tb_get_cached_tweets($sources, $tweets_to_show,$widget_id); 
    471493    foreach ($tweets as $t){ 
    472494        $tweet = $json->decode($t->tweet_json); 
     
    478500} 
    479501 
    480 function tb_get_cached_tweets($sources,$tweets_num) { 
     502function tb_get_cached_tweets($sources,$tweets_num,$widget_id = '') { 
    481503    global $wpdb; 
    482504    $table_name = $wpdb->prefix . "tweetblender"; 
    483505 
     506    // TODO: if widget_id contains "favorites" pull out only favorite tweets for the given sources 
     507     
    484508    $sources_sql = ""; 
    485509    if (sizeof($sources) > 0) { 
     
    513537    if (!isset($tweet->user)) { 
    514538        $user = new stdClass(); 
    515         if ($tweet->from_user) { 
     539        if (isset($tweet->from_user)) { 
    516540             
    517541            $user->screen_name = $tweet->from_user; 
     
    525549 
    526550    // see if there in alias for this screen name 
    527     $TB_sourceNames = $tb_o['alt_source_names']; 
     551    if (isset($tb_o['alt_source_names'])) { 
     552        $TB_sourceNames = $tb_o['alt_source_names']; 
     553    } 
    528554    if (isset($TB_sourceNames[strtolower($tweet->user->screen_name)])) { 
    529555        $tweet->user->alias = $TB_sourceNames[strtolower($tweet->user->screen_name)]; 
     
    551577    // link hashtags if requested 
    552578    if ($tb_o['general_link_hash_tags']) { 
    553         $patterns[] = '/\#([\w\-]+)/'; 
     579        $patterns[] = '/\#(\S+)/'; 
    554580        $replacements[] = '<a rel="nofollow" href="http://search.twitter.com/search?q=%23$1">#$1</a>'; 
    555581    } 
     
    571597 
    572598    // if source is not url encoded -> use as is 
    573     if (strpos($tweet->source,'&lt;') === false) { 
     599    if (isset($tweet->source) && strpos($tweet->source,'&lt;') === false) { 
    574600        $source_html = $tweet->source; 
    575601    } 
     
    612638     
    613639    // show source if requested 
    614     if ($tb_o[$mode . '_show_source'] && $tweet->source) { 
     640    if ($tb_o[$mode . '_show_source'] && isset($tweet->source)) { 
    615641        $tweet_template .= ' from {6}'; 
    616642    } 
     
    703729} 
    704730 
     731function tb_get_current_page_url() { 
     732    $page_url = 'http'; 
     733    if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") { 
     734        $page_url .= "s"; 
     735    } 
     736    $page_url .= "://"; 
     737    if ($_SERVER["SERVER_PORT"] != "80") { 
     738        $page_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 
     739    } 
     740    else { 
     741        $page_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 
     742    } 
     743    return $page_url; 
     744} 
     745 
     746 
     747function tb_download_package($item_number) { 
     748 
     749    global $tb_package_names; 
     750 
     751    if ($item_number <= 0) { 
     752        echo("ID of the addon to install not provided... aborting"); 
     753        return; 
     754    } 
     755     
     756    // get user-friendly package name 
     757    $package_name = $tb_package_names[$item_number];     
     758 
     759    // Show status updates on screen 
     760    echo "<h3>Installing $package_name for Tweet Blender</h3>\n"; 
     761 
     762    // get purchase transaction id 
     763    $txn_id = tb_get_txn_id($item_number); 
     764    if (!isset($txn_id) || strlen($txn_id) < 10) { 
     765        echo("Can't confirm purchase... aborting\n"); 
     766        return; 
     767    } 
     768 
     769    // Download 
     770    echo "Downloading package... \n"; 
     771    $response = wp_remote_get('http://tweetblender.com/download.php?item_number=' . $item_number . '&blog_url=' . urlencode(get_bloginfo('url')) . '&txn_id=' . $txn_id); 
     772     
     773    // if couldn't download - report error 
     774    if(is_wp_error($response)) { 
     775        echo 'not able to download. Error: ' . $response->get_error_message();; 
     776        return; 
     777    } 
     778    // else, if validation error 
     779    elseif(isset($response['headers']['validation-error'])) { 
     780        echo 'not able to download. Error: ' . $response['headers']['validation-error']; 
     781        return; 
     782    } 
     783    // else - proceed to save 
     784    else { 
     785         
     786        $package_file_name = $response['headers']['package-file-name']; 
     787 
     788        // form file name 
     789        $file_name = WP_PLUGIN_DIR . '/'. $package_file_name . '.zip'; 
     790         
     791        // if couldn't save - report error 
     792        if (file_put_contents($file_name,wp_remote_retrieve_body($response)) === false) { 
     793            echo "unable to save file $file_name. Check directory permissions"; 
     794            return; 
     795        } 
     796        // else - proceed to unzip 
     797        else { 
     798            echo "done<br />"; 
     799     
     800            // Unpack 
     801            echo "Unpacking... \n"; 
     802            require_once('uploader/pclzip.lib.php'); 
     803            $archive = new PclZip($file_name); 
     804             
     805            // if can't unzip - report error 
     806            if (($v_result_list = $archive->extract(PCLZIP_OPT_SET_CHMOD, 0777, PCLZIP_OPT_PATH, WP_PLUGIN_DIR)) == 0) { 
     807                echo "unable to unzip. Error: " . $archive->get_error_message(); 
     808                rturn; 
     809            } 
     810            // else - proceed to activate 
     811            else { 
     812 
     813                echo "done<br />"; 
     814 
     815                // clean up by removing zip file 
     816                unlink($file_name);          
     817                     
     818                // Activate 
     819                echo "Activating... \n"; 
     820                $activation = activate_plugin(WP_PLUGIN_DIR . '/' . $package_file_name . '/' . $package_file_name . '.php'); 
     821                 
     822                // if can't activate - report error 
     823                if (is_wp_error($activation)) { 
     824                    echo "unable to activate, please try to do it manually. Error: " . $activation->get_error_message(); 
     825                    return; 
     826                } 
     827                // else - wrap it up 
     828                else { 
     829                    echo "done<br />"; 
     830                     
     831                    /* TODO: change permissions to the same as ours 
     832                    $info = stat(__FILE__); 
     833                    $info['uid']; 
     834                    $info['gid']; */ 
     835 
     836                    // Done, link to admin 
     837                    $url = tb_get_current_page_url(); 
     838                    $url = str_replace('&install_addon=1', '', $url); 
     839                    echo "All Done!<br /><br /><a href='$url'>Start using $package_name</a><br /><br />"; 
     840                } 
     841            } 
     842        } 
     843    }    
     844} 
     845 
     846function tb_chmod_R($path, $filemode) { 
     847  
     848    $dh = opendir($path); 
     849    while ($file = readdir($dh)) { 
     850        if($file != '.' && $file != '..') { 
     851            $fullpath = $path.'/'.$file; 
     852            chmod($fullpath, $filemode); 
     853            if(is_dir($fullpath)) { 
     854  
     855               chmod_R($fullpath, $filemode); 
     856  
     857            }  
     858        } 
     859    } 
     860  
     861    closedir($dh);     
     862} 
     863 
     864function tb_get_txn_id($item_number) { 
     865     
     866    // check WP options 
     867    $txn_id = get_option('txn_id_' . $item_number); 
     868    if (isset($txn_id) && strlen($txn_id) > 10) { 
     869        return $txn_id; 
     870    } 
     871    // if not found check recovery file 
     872    else { 
     873        $txn_id = trim(@file_get_contents(WP_PLUGIN_DIR . '/tweet-blender/' . $item_number . '.txt')); 
     874         
     875        if (isset($txn_id) && strlen($txn_id) > 10) { 
     876             
     877            // update option 
     878            update_option('txn_id_'.$item_number,$txn_id); 
     879             
     880            // remove file 
     881            unlink(WP_PLUGIN_DIR . '/tweet-blender/' . $item_number . '.txt'); 
     882             
     883            // return 
     884            return $txn_id; 
     885        } 
     886        else { 
     887            return null; 
     888        }        
     889    } 
     890} 
     891 
     892function tb_save_txn_id($item_number,$txn_id) { 
     893    // save to WP options 
     894    update_option('txn_id_'.$item_number,$txn_id); 
     895} 
     896 
     897 
    705898?> 
  • tweet-blender/trunk/readme.txt

    r317884 r348497  
    11=== Tweet Blender === 
    22Contributors: kirilln 
    3 Tags: sidebar, twitter, tweets, multiple authors, tags, lists, hashtags, archive, widget, admin, AJAX, jquery, keywords, BuddyPress 
     3Tags: sidebar, twitter, tweets, multiple authors, favorites, tweet, tags, lists, hashtags, archive, widget, admin, AJAX, jquery, keywords, BuddyPress 
    44Requires at least: 2.8.0 
    5 Tested up to: 3.0.2 
    6 Stable tag: 3.2.4 
     5Tested up to: 3.0.5 
     6Stable tag: 3.3.0 
    77Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5907095 
    88 
     
    2020 
    2121= Features = 
    22 * NEW: filter that allows to filter out tweets that are from different screen names but have exactly same content 
    23 * NEW: filter that allows to show only replies and hide original tweets 
    24 * NEW: ability to define custom text for "view more" link 
    25 * NEW: Support for multi-keyword phrase searches (e.g. <b>Tweet Blender</b>) 
    26 * NEW: Ability to define name that shows up instead of twitter handle using a colon (e.g. @joesmith:Joe Smith would show "Joe Smith" for each tweet instead of "@joesmith")  
     22* NEW: ability to get Cache Manager addon ($) that allows to backup/restore cache and delete individual tweets 
     23* NEW: if you use custom field "tb_tags" for a post its value overrides actual tags and gets used by Tweet Blender for Tags widget (requested by Thomas P via GetSatisfaction) 
     24* NEW: support for non-English hashtags and filter words 
     25* A filter that allows to filter out tweets that are from different screen names but have exactly same content 
     26* A filter that allows to show only replies and hide original tweets 
     27* Ability to define custom text for "view more" link 
     28* Support for multi-keyword phrase searches (e.g. <b>Tweet Blender</b>) 
     29* Ability to define name that shows up instead of twitter handle using a colon (e.g. @joesmith:Joe Smith would show "Joe Smith" for each tweet instead of "@joesmith")  
    2730* Throttling that allows to limit number of tweets to show for each user account. You can now have X tweets for each user in the list no matter how frequently each of them tweets.  
    28 * favorites widget that shows favorite tweets or one or multiple users 
     31* Favorites widget that shows favorite tweets or one or multiple users 
    2932* Improved cache management controls 
    3033* Ability to qualify searches using a pipe symbol. For example @user|#fun will get all tweets from @user that contain #fun in them 
     
    1391428. Admin: advanced settings 
    1401439. Admin: status information 
     14410. Admin: Cache Manager addon (note: paid module) 
    141145 
    142146== Getting Help == 
     
    161165* Facebook: [Tweet Blender fan page](http://www.facebook.com/pages/Tweet-Blender/96201618006 "Facebook Fan Page") discussion board 
    162166* WordPress Support Forums: [tweet-blender tag](http://wordpress.org/tags/tweet-blender?forum_id=10 "WP forum") 
    163 * Old homepage: [http://kirill-novitchenko.com/tweet-blender](http://kirill-novitchenko.com/tweet-blender "old homepage") 
    164167 
    165168Additional resources: 
     
    173176 
    174177== Changelog == 
     178 
     179= 3.3.0 = 
     180* New feature: ability to get Cache Manager addon ($) that allows to backup/restore cache and delete individual tweets 
     181* New feature: if you use custom field "tb_tags" for a post its value overrides actual tags and gets used by Tweet Blender for Tags widget (requested by Thomas P via GetSatisfaction) 
     182* Bug fix: multiple escapes for filter phrases in quotes broke searches (thanks to @drtanz for reporting via WP Forums) 
     183* Bug fix: problem retrieving cached tweets for hashtags when API limit is reached 
     184* Bug fix: filters now support words in any lanugage, not just in English (thanks to Dmitry Sh for reporting via Facebook) 
     185* Bug fix: Twitter default number of search results (15) was returned even when widget was configured to show more (thanks to Brent S for reporting via GetSatisfaction) 
     186* Bug fix: non-English hashtags support (thanks to Esben R for reporting via GetSatisfaction) 
     187* Bug fix: jQuery conflict with CadabraPress theme (thanks to Dave G for reporting via GetSatisfaction) 
     188* Bug fix: multiple tweets created at the same second by the same user had only the first one show up in the stream 
     189* Improvement: switched to new Twitter API endpoint for user timelines 
     190* Improvement: "Loading tweets" message now hides if Twitter had an error and loading is done 
     191* Improvement: Made admin section use the latest jquery shipping with WP and stopped bundling local copy with plugin 
     192* Tested with WordPress 3.0.3, 3.0.4, 3.0.5 
    175193 
    176194= 3.2.4 = 
  • tweet-blender/trunk/tweet-blender.php

    r317884 r348497  
    44Plugin URI: http://www.tweet-blender.com 
    55Description: Provides several Twitter widgets: show your own tweets, show tweets relevant to post's tags, show tweets for Twitter lists, show tweets for hashtags, show tweets for keyword searches, show favorite tweets. Multiple widgets on the same page are supported. Can combine sources and blend all of them into a single stream. 
    6 Version: 3.2.4 
     6Version: 3.3.0 
    77Author: Kirill Novitchenko 
    88Author URI: http://kirill-novitchenko.com 
     
    203203        $dependencies[] = 'tojson'; 
    204204    } 
     205     
     206    // load jsonp plugin with good error hanlding 
     207    wp_enqueue_script('jsonp', '/' . PLUGINDIR . '/tweet-blender/js/jquery.jsonp-2.1.4.min.js', array('jquery')); 
     208     
    205209    // load main JS code 
    206210    wp_enqueue_script('tbmain', '/' . PLUGINDIR . '/tweet-blender/js/main.js', $dependencies); 
     
    306310    } 
    307311    if (isset($tb_o['general_seo_tweets_googleoff']) && $tb_o['general_seo_tweets_googleoff']) { 
    308         $html .= '<!--googleoff: index--><div class="tb_tweetlist">' . tb_get_cached_tweets_html($mode,$instance) . '</div><!--googleon: index-->'; 
     312        $html .= '<!--googleoff: index--><div class="tb_tweetlist">' . tb_get_cached_tweets_html($mode,$instance,$widget_id) . '</div><!--googleon: index-->'; 
    309313    } 
    310314    else { 
  • tweet-blender/trunk/widget-favorites.php

    r315373 r348497  
    11<?php 
     2 
     3// version 3.3.0 
     4 
    25class TweetBlenderFavorites extends WP_Widget { 
    36     
     
    9295        // process sources 
    9396        $errors = array(); 
    94         $old_sources = preg_split('/[\n\r]/m', $old_instance['widget_sources']); 
     97        if (isset($old_instance['widget_sources'])) { 
     98            $old_sources = preg_split('/[\n\r]/m', $old_instance['widget_sources']); 
     99        } 
     100        else { 
     101            $old_sources = array(); 
     102        } 
    95103        $new_sources = preg_split('/[\n\r]/m', $new_instance['widget_sources']); 
    96104        $oAuth = null; 
     
    186194  
    187195        // report errors if any 
    188         if ($this->error) { 
     196        if (isset($this->error)) { 
    189197            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');}"); 
    190198            echo '<div class="error">' . $this->error . '</div>'; 
     
    192200        } 
    193201        // report messages if an 
    194         if ($this->message) { 
     202        if (isset($this->message)) { 
    195203            echo '<div class="updated">' . $this->message . '</div>'; 
    196204        } 
     
    209217        $field_id = $this->get_field_id('widget_private_sources'); 
    210218        $field_name = $this->get_field_name('widget_private_sources'); 
     219        if (!isset($instance['widget_private_sources'])) { 
     220            $instance['widget_private_sources'] = ''; 
     221        }  
    211222        echo "\r\n".'<input type="hidden" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_private_sources'] ) . '" />'; 
    212223                 
     
    249260        $field_id = $this->get_field_id('widget_view_more_text'); 
    250261        $field_name = $this->get_field_name('widget_view_more_text'); 
     262        if (!isset($instance['widget_view_more_text'])) { 
     263            $instance['widget_view_more_text'] = ''; 
     264        }  
    251265        echo "\r\n".'<br/><label for="'.$field_id.'">'.__('Text for &quot;view more&quot; link').':</label>'; 
    252266        echo "\r\n".'<input class="widefat" type="text" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_view_more_text'] ) . '">';; 
     
    255269        $field_id = $this->get_field_id('widget_view_more_url'); 
    256270        $field_name = $this->get_field_name('widget_view_more_url'); 
     271        if (!isset($instance['widget_view_more_url'])) { 
     272            $instance['widget_view_more_url'] = ''; 
     273        }  
    257274        echo "\r\n".'<br/><label for="'.$field_id.'">'.__('URL for &quot;view more&quot; link').':</label>'; 
    258275        echo "\r\n".'<input class="widefat" type="text" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_view_more_url'] ) . '"><br/>'; 
     
    312329            $jsonData = $json->decode($result['body']); 
    313330            // if Twitter reported error 
    314             if ($jsonData->{error}) { 
     331            if (!isset($jsonData)) { 
     332                $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; 
     333                $log_msg = "($src) json error: could not decode body\n"; 
     334            } 
     335            elseif(isset($jsonData->{'error'})) { 
     336             
    315337                // if it's a private user 
    316                 if (strpos($jsonData->{error},"Not authorized") !== false){ 
     338                if (strpos($jsonData->{'error'},"Not authorized") !== false){ 
    317339                    $is_private = true; 
    318340                    // if we don't have access tokens - error 
  • tweet-blender/trunk/widget-tags.php

    r314317 r348497  
    11<?php 
     2 
     3// v3.3.0 
     4 
    25class TweetBlenderForTags extends WP_Widget { 
    36     
     
    1821        } 
    1922 
     23        // check custom tb_tags field 
     24        $sources = array(); 
     25        $custom_fields = get_post_custom($post->ID); 
     26        $post_tags = get_the_tags($post->ID); 
     27        if (isset($custom_fields['tb_tags'])) { 
     28            foreach($custom_fields['tb_tags'] as $key => $tags) { 
     29                $sources = array_merge($sources,explode(',',$tags)); 
     30            }            
     31        } 
     32        // check general post tags 
     33        elseif (isset($post_tags) && is_array($post_tags) && sizeof($post_tags) > 0) { 
     34            foreach($post_tags as $tag) { 
     35                $sources[] = trim($tag->name);           
     36            } 
     37        } 
    2038        // don't show widget if there are no tags 
    21         $sources = array(); 
    22         $post_tags = get_the_tags($post->ID); 
    23         if (is_object($post_tags) || sizeof($post_tags) == 0) { 
     39        else { 
    2440            echo '<!-- Tweet Blender: Not shown as there are no tags for this post -->'; 
    2541            return; 
     
    3551        if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }; 
    3652 
    37         foreach($post_tags as $tag) { 
    38             $sources[] = trim($tag->name); 
    39              
    40         } 
    4153        $instance['widget_sources'] = join('\n\r',$sources); 
    4254             
     
    8294  
    8395        // report messages if an 
    84         if ($this->message) { 
     96        if (isset($this->message)) { 
    8597            echo '<div class="updated">' . $this->message . '</div>'; 
    8698        } 
  • tweet-blender/trunk/widget.php

    r315373 r348497  
    11<?php 
     2 
     3// version 3.3.0 
     4 
    25class TweetBlender extends WP_Widget { 
    36     
     
    9295        // process sources 
    9396        $errors = array(); 
    94         $old_sources = preg_split('/[\n\r]/m', $old_instance['widget_sources']); 
     97        if(isset($old_instance['widget_sources'])) { 
     98            $old_sources = preg_split('/[\n\r]/m', $old_instance['widget_sources']); 
     99        } 
     100        else { 
     101            $old_sources = array(); 
     102        } 
    95103        $new_sources = preg_split('/[\n\r]/m', $new_instance['widget_sources']); 
    96104        $oAuth = null; 
     
    225233        $field_id = $this->get_field_id('widget_private_sources'); 
    226234        $field_name = $this->get_field_name('widget_private_sources'); 
     235        if (!isset($instance['widget_private_sources'])) { 
     236            $instance['widget_private_sources'] = ''; 
     237        }  
    227238        echo "\r\n".'<input type="hidden" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_private_sources'] ) . '" />'; 
    228239                 
     
    265276        $field_id = $this->get_field_id('widget_view_more_text'); 
    266277        $field_name = $this->get_field_name('widget_view_more_text'); 
     278        if (!isset($instance['widget_view_more_text'])) { 
     279            $instance['widget_view_more_text'] = ''; 
     280        }  
    267281        echo "\r\n".'<br/><label for="'.$field_id.'">'.__('Text for &quot;view more&quot; link').':</label>'; 
    268282        echo "\r\n".'<input class="widefat" type="text" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_view_more_text'] ) . '">';; 
     
    271285        $field_id = $this->get_field_id('widget_view_more_url'); 
    272286        $field_name = $this->get_field_name('widget_view_more_url'); 
     287        if (!isset($instance['widget_view_more_url'])) { 
     288            $instance['widget_view_more_url'] = ''; 
     289        }  
    273290        echo "\r\n".'<br/><label for="'.$field_id.'">'.__('URL for &quot;view more&quot; link').':</label>'; 
    274291        echo "\r\n".'<input class="widefat" type="text" id="'.$field_id.'" name="'.$field_name.'" value="' . esc_attr( $instance['widget_view_more_url'] ) . '"><br/>'; 
     
    323340        if (!is_wp_error($result)) { 
    324341            $jsonData = $json->decode($result['body']); 
     342            if (!isset($jsonData)) { 
     343                $source_check_result = ' ' . $src . ' - <span class="fail">FAIL</span>'; 
     344                $log_msg = "($src) json error: can't get json\n"; 
     345            } 
    325346            // if Twitter reported error 
    326             if ($jsonData->{error}) { 
     347            elseif (isset($jsonData->{'error'})) { 
    327348                // if it's a private user 
    328                 if (strpos($jsonData->{error},"Not authorized") !== false){ 
     349                if (strpos($jsonData->{'error'},"Not authorized") !== false){ 
    329350                    $is_private = true; 
    330351                    // if we don't have access tokens - error 
  • tweet-blender/trunk/ws.php

    r315373 r348497  
    11<?php 
    22 
    3 // version 3.2.2 
     3// version 3.3.0 
    44 
    55// include WP functions 
     
    3030 
    3131    $params = array(); 
    32     parse_str(esc_attr($_SERVER['QUERY_STRING']),$params); 
     32    parse_str($_SERVER['QUERY_STRING'],$params); 
    3333    unset($params['action']); 
    3434 
    3535    if ($_GET['action'] == 'search') { 
    3636        // if its for screen names 
    37         if ($_GET['from']) { 
     37        if (isset($_GET['from'])) { 
    3838            $sources = split(' OR ',$_GET['from']); 
    3939            // add the @ sign 
    4040            array_walk($sources, create_function('&$src','$src = "@" . $src;')); 
    4141        } 
     42        elseif (isset($_GET['ors'])) { 
     43            $sources = split(' ',$_GET['ors']); 
     44        } 
    4245        else { 
    43             $sources = split(' ',$_GET['ors']); 
     46            $sources = split(' OR ',$_GET['q']); 
    4447        } 
    4548        $url = 'http://search.twitter.com/search.json'; 
Note: See TracChangeset for help on using the changeset viewer.