Plugin Directory

Changeset 230793


Ignore:
Timestamp:
04/19/2010 09:40:45 PM (16 years ago)
Author:
tech163
Message:

Version 0.4.3 - http://fusionswift.com/wordpress-tweeter/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wordpress-tweeter/trunk/wptweeter.php

    r222403 r230793  
    44Plugin URI: http://fusionswift.com/wordpress-tweeter/
    55Description: WordPress Tweeter tweets every time you make a new post on your blog. Make sure you read the <a href="http://fusionswift.com/wordpress-tweeter/" title="WordPress Tweeter">documentations</a> before using this plugin. The changelog, installation instructions, and any other plugin related information is there.
    6 Version: 0.4.2
     6Version: 0.4.3
    77Author: Tech163
    88Author URI: http://fusionwift.com/
     
    2727    if(!empty($parameter))
    2828        $parameter = '?' . $parameter;
    29     $status = str_replace('%blogtitle%', get_bloginfo('name'), $tpl);
    30     $status = str_replace('%posttitle%', $_POST['post_title'], $status);
    3129    $services = array();
    3230    $services['tinyurl'] = 'http://tinyurl.com/api-create.php?url=%url%';
     
    4341    curl_setopt($ch, CURLOPT_URL, $serviceurl);
    4442    $posturl = curl_exec($ch);
    45     $status = str_replace('%url%', $homeurl, $status);
     43    $status = str_replace('%url%', $homeurl, $tpl);
    4644    $status = str_replace('%posturl%', $posturl, $status);
     45    $status = str_replace('%date%', date(get_option('date_format')), $status);
     46    $status = str_replace('%time%', date(get_option('time_format')), $status);
     47    $status = str_replace('%blogtitle%', get_bloginfo('name'), $status);
     48    $maxlen = 137 - strlen(preg_replace('/%(.*)%/', '', $status));
     49    $status = str_replace('%posttitle%', (strlen($_POST['post_title']) > $maxlen ? substr($_POST['post_title'], 0, $maxlen) . '...' : $_POST['post_title']), $status);
    4750    curl_setopt($ch, CURLOPT_URL, 'http' . $protocal . '://api.twitter.com/1/statuses/update.xml');
    4851    curl_setopt($ch, CURLOPT_HEADER, false);
     
    5760    global $options, $wptweeterstatus;
    5861    $options = get_option('wp_tweeter');
    59     if($options['postupdate'] != 'true') {
    60         if($wptweeterstatus != 'publish') {
    61             wp_tweeter_tweet($options['tpl']);
    62         }
    63     } else {
     62    if($wptweeterstatus != 'publish') {
     63        wp_tweeter_tweet($options['tpl']);
     64    } elseif($options['postupdate'] == 'true') {
    6465        wp_tweeter_tweet($options['updatetpl']);
    6566    }
     
    123124            'tpl' => '%blogtitle% New Post - %posttitle%. Read it now at %posturl%',
    124125            'postupdate' => '',
    125             'updatetpl' => '%blogtitle% Post updated - %posttitle%. Read it now at %posturl%');
     126            'updatetpl' => 'Post updated %date% - %posttitle%. Read it now at %posturl%');
    126127        }
    127128        update_option('wp_tweeter', $default);
     
    214215}
    215216
     217function wp_tweeter_notice() {
     218    if(function_exists('admin_url') && !is_array(get_option('wp_tweeter')))
     219        echo '<div class="error"><p>WordPress Tweeter is NOT configured yet! Please <a href="' . admin_url('options-general.php?page=wptweeter.php') . '">configure</a> it now! <strong><a href="http://fusionswift.com/wordpress-tweeter/" target="_blank">Documentations</a></strong></p></div>';
     220}
     221
    216222add_action('admin_menu', 'wp_tweeter_menu');
    217223add_action('pre_post_update', 'wp_tweeter_checkstatus');
    218224add_action('publish_post', 'wp_tweeter_update');
     225add_action('admin_notices', 'wp_tweeter_notice');
    219226?>
Note: See TracChangeset for help on using the changeset viewer.