Permalink
Browse files

Improve Tweet token handling.

  • Loading branch information...
1 parent bafc001 commit 30d1e8b1e5f9c1ff43e991c5cb425169f6c99cce Michael Sisk committed Feb 28, 2013
Showing with 5 additions and 19 deletions.
  1. +5 −19 webcomic.php
View
@@ -1027,21 +1027,7 @@ public function tweet_webcomic( $new, $old, $post ) {
'%collection-names' => self::$config[ 'collections' ][ $post->post_type ][ 'name' ],
'%collection-name' => self::$config[ 'collections' ][ $post->post_type ][ 'name' ],
'%collections' => '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $post->post_type ][ 'slugs' ][ 'name' ] ),
- '%collection' => '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $post->post_type ][ 'slugs' ][ 'name' ] ),
- '%xcollection-names' => '',
- '%xcollections' => '',
- '%!storyline-names' => '',
- '%xstoryline-names' => '',
- '%storyline-names' => '',
- '%!storylines' => '',
- '%xstorylines' => '',
- '%storylines' => '',
- '%!character-names' => '',
- '%xcharacter-names' => '',
- '%character-names' => '',
- '%!characters' => '',
- '%xcharacters' => '',
- '%characters' => ''
+ '%collection' => '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $post->post_type ][ 'slugs' ][ 'name' ] )
) );
if ( preg_match( sprintf( '/%%%s/', join( '|%', array_merge( array( 'storyline', 'character' ), self::$config[ 'collections' ][ $post->post_type ][ 'taxonomies' ] ) ) ), self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'format' ] ) and $terms = wp_get_object_terms( $post->ID, array_merge( array( "{$post->post_type}_storyline", "{$post->post_type}_character" ), self::$config[ 'collections' ][ $post->post_type ][ 'taxonomies' ] ) ) and !is_wp_error( $terms ) ) {
@@ -1052,10 +1038,10 @@ public function tweet_webcomic( $new, $old, $post ) {
$parts = explode( '_', $term->taxonomy );
if ( false === strpos( $tokens[ 'collection-names' ], self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ] ) ) {
- $tokens[ '%collections' ] .= '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $parts[ 0 ] ][ 'slugs' ][ 'name' ] );
- $tokens[ '%collection-names' ] .= self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ];
- $tokens[ '%xcollections' ] .= '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $parts[ 0 ] ][ 'slugs' ][ 'name' ] );
- $tokens[ '%xcollection-names' ] .= self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ];
+ $tokens[ '%collections' ] .= ' #' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $parts[ 0 ] ][ 'slugs' ][ 'name' ] );
+ $tokens[ '%collection-names' ] .= ' ' . self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ];
+ $tokens[ '%xcollections' ] .= empty( $tokens[ '%xcollection-names' ] ) ? '#' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $parts[ 0 ] ][ 'slugs' ][ 'name' ] ) : ' #' . str_replace( array( '_', '-' ), '', self::$config[ 'collections' ][ $parts[ 0 ] ][ 'slugs' ][ 'name' ] );
+ $tokens[ '%xcollection-names' ] .= empty( $tokens[ '%xcollection-names' ] ) ? self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ] : ' ' . self::$config[ 'collections' ][ $parts[ 0 ] ][ 'name' ];
}
$tokens[ "%{$parts[ 1 ]}s" ] .= empty( $tokens[ '%{$parts[ 1 ]}s' ] ) ? "{$hash}" : " {$hash}";

0 comments on commit 30d1e8b

Please sign in to comment.