WordPress.org

Plugin Directory

Changeset 599500


Ignore:
Timestamp:
09/15/12 23:19:06 (20 months ago)
Author:
betzster
Message:

Only tweet if the post is new

Location:
tweet-posts/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tweet-posts/trunk/readme.txt

    r590723 r599500  
    44Requires at least: 3.4 
    55Tested up to: 3.4.1 
    6 Stable tag: 0.1 
     6Stable tag: 0.1.1 
    77 
    88Tweet your posts. 
     
    2121== Changelog == 
    2222 
     23= 0.1.1 = 
     24* Fix bug where tweets would be sent even if the post wasn't new 
     25 
    2326= 0.1 = 
    2427* Initial plugin 
  • tweet-posts/trunk/tweet-posts.php

    r590723 r599500  
    44Plugin URI: http://joshbetz.com/2012/08/tweet-posts/ 
    55Description: Tweet your posts. 
    6 Version: 0.1 
     6Version: 0.1.1 
    77Author: Josh Betz 
    88Author URI: http://joshbetz.com 
     
    1313class Tweet_Posts { 
    1414 
    15     const VERSION = '0.1'; 
     15    const VERSION = '0.1.1'; 
    1616    const SLUG    = 'tweet-posts'; 
    1717    const OPTION  = 'tweet_posts'; 
     
    2323        add_action( 'admin_init', array( $this, 'admin_init' ) ); 
    2424        add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 
    25         add_action( 'publish_post', array( $this, 'publish_post' ) ); 
     25        add_action( 'publish_post', array( $this, 'publish_post' ), 10, 2 ); 
    2626         
    2727        $this->keys = get_option( self::OPTION ); 
     
    3636    } 
    3737 
    38     function publish_post( $id ) { 
    39         $post = get_post( $id ); 
     38    function publish_post( $id, $post ) { 
     39        // If this isn't new, bail 
     40        if ( $post->post_date != $post->post_modified ) 
     41            return; 
     42 
    4043        $title = $post->post_title; 
    4144        $shortlink = wp_get_shortlink( $id ); 
Note: See TracChangeset for help on using the changeset viewer.