Permalink
Browse files

Only load Twitter libraries when necessary.

This covers cases where another plugin may have already loaded the same
OAuth/Twitter library that Webcomic utilizes.
  • Loading branch information...
mgsisk committed Dec 6, 2012
1 parent 9b48d46 commit b42a6fbcc9bd668cca11fd024be6eb2382e24a0c
Showing with 12 additions and 4 deletions.
  1. +3 −1 -/library/twitter.php
  2. +3 −1 -/php/config.php
  3. +3 −1 -/php/posts.php
  4. +3 −1 webcomic.php
View
@@ -25,7 +25,9 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-require_once dirname( __FILE__ ) . '/oauth.php';
+if ( !class_exists( 'OAuthConsumer' ) ) {
+ require_once dirname( __FILE__ ) . '/oauth.php';
+}
/**
* Twitter OAuth class
View
@@ -1208,7 +1208,9 @@ public static function ajax_commerce_defaults( $email ) {
* @param string $collection Collection the Twitter credentials belong to.
*/
public static function ajax_twitter_account( $consumer_key, $consumer_secret, $collection ) {
- require_once self::$dir . '-/library/twitter.php';
+ if ( !class_exists( 'TwitterOAuth' ) ) {
+ require_once self::$dir . '-/library/twitter.php';
+ }
if ( $consumer_key and $consumer_secret ) {
$oauth = new TwitterOAuth( $consumer_key, $consumer_secret, self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_token' ], self::$config[ 'collections' ][ $collection ][ 'twitter' ][ 'oauth_secret' ] );
View
@@ -278,7 +278,9 @@ public function tweet_webcomic( $new, $old, $post ) {
}
if ( $status ) {
- require_once self::$dir . '-/library/twitter.php';
+ if ( !class_exists( 'TwitterOAuth' ) ) {
+ require_once self::$dir . '-/library/twitter.php';
+ }
$oauth = new TwitterOAuth( self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'consumer_key' ], self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'consumer_secret' ], self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'oauth_token' ], self::$config[ 'collections' ][ $post->post_type ][ 'twitter' ][ 'oauth_secret' ] );
$response = $oauth->post( 'statuses/update', array( 'status' => substr( strip_tags( $status ), 0, 140 ) ) );
View
@@ -1144,7 +1144,9 @@ public function log_ipn() {
*/
public function twitter_oauth() {
if ( isset( $_GET[ 'webcomic_twitter_oauth' ] ) ) {
- require_once self::$dir . '-/library/twitter.php';
+ if ( !class_exists( 'TwitterOAuth' ) ) {
+ require_once self::$dir . '-/library/twitter.php';
+ }
$admin_url = add_query_arg( array( 'post_type' => $_GET[ 'webcomic_collection' ], 'page' => "{$_GET[ 'webcomic_collection' ]}-options" ), admin_url( 'edit.php' ) );

0 comments on commit b42a6fb

Please sign in to comment.