Changeset 953529
- Timestamp:
- 07/23/2014 02:48:55 PM (12 years ago)
- Location:
- widget-embed-lastest-tweets
- Files:
-
- 6 edited
- 1 copied
-
tags/0.6.4 (copied) (copied from widget-embed-lastest-tweets/trunk)
-
tags/0.6.4/js/welt-scripts.js (modified) (2 diffs)
-
tags/0.6.4/readme.txt (modified) (1 diff)
-
tags/0.6.4/widget-embed-latest-tweets.php (modified) (10 diffs)
-
trunk/js/welt-scripts.js (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/widget-embed-latest-tweets.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
widget-embed-lastest-tweets/tags/0.6.4/js/welt-scripts.js
r907818 r953529 5 5 6 6 jQuery(document).ready( function(){ 7 8 var all_welt_widgets = []; 7 9 8 10 jQuery('.welt-tweet-wrapper').each( function(){ … … 14 16 widget_id = widget_id.replace('welt-', ''); 15 17 16 var data = { 17 action: 'welt_display_tweets', 18 widget_id: widget_id, 19 widget_data: widget_data 20 }; 18 all_welt_widgets.push( { widget_id : widget_id, widget_data : widget_data } ); 21 19 22 jQuery.post( 23 weltAjaxurl, 24 data, 25 function(response) { 26 current_widget.append(response); 20 }); 21 22 23 var data = { 24 action: 'welt_display_tweets', 25 all_welt_widgets: all_welt_widgets, 26 }; 27 28 jQuery.post( 29 weltAjaxurl, 30 data, 31 function(response) { 32 33 if( response ){ 34 response = JSON.parse( response ); 35 36 for( var i in response ){ 37 38 var widget_selector = '#welt-' + i; 39 jQuery( widget_selector ).append( response[i] ); 40 } 41 27 42 twttr.widgets.load(); 28 43 } 29 ); 30 31 }); 44 } 45 ); 32 46 }); 33 47 -
widget-embed-lastest-tweets/tags/0.6.4/readme.txt
r946503 r953529 61 61 == Changelog == 62 62 63 = 0.6.4 = 64 65 * Only one AJAX calls to get Tweet data ( Thank you Christof Rodejohann ) 66 * Some bugfix for the new widget preview in the customizer 67 63 68 = 0.6.3 = 64 69 65 * fix : probleme with new tweet not showing 66 Thank you Christof Rodejohann 70 * fix : probleme with new tweet not showing ( Thank you Christof Rodejohann ) 67 71 68 72 = 0.6.2 = -
widget-embed-lastest-tweets/tags/0.6.4/widget-embed-latest-tweets.php
r946507 r953529 4 4 * Plugin URI: http://arnaudban.me/blog/portfolio/widget-embed-latest-tweets/ 5 5 * Description: A Widget to show your latest Tweets. Use the oEmbed methode and some cache. Visit the option page "Plugins->Widget Embed Last Plugin" to authentify yourself 6 * Version: 0.6. 36 * Version: 0.6.4 7 7 * Author: Arnaud Banvillet 8 8 * Author URI: http://arnaudban.me … … 37 37 'align' => 'none', 38 38 'hide_thread' => true, 39 'lang' => 'en',40 39 'include_rts' => true, 41 40 'hide_media' => true, … … 54 53 array('description' => __('Show your latest Tweets', 'widget-embed-lastest-tweets'))// Args 55 54 ); 55 56 if( defined( 'WPLANG' ) ){ 57 $this->defaut['lang'] = substr( WPLANG, 0, 2 ); 58 } else { 59 $this->defaut['lang'] = 'en'; 60 } 56 61 } 57 62 … … 85 90 if( !empty( $screen_name ) ){ 86 91 87 if( method_exists('Widget', 'is_preview' ) && $this->is_preview() ){88 89 $data = ' '; 92 $data = ' '; 93 if( method_exists('WP_Widget', 'is_preview' ) && $this->is_preview() ){ 94 90 95 foreach ($instance as $key => $value) { 91 96 … … 95 100 } 96 101 97 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'$data></div>";98 99 } else {100 101 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'></div>";102 102 } 103 104 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'$data></div>"; 105 103 106 } 104 107 … … 144 147 145 148 // When everythings is check and we are not in the customizer, set the transient 146 if( ! method_exists('Widget', 'is_preview' ) || ! $this->is_preview() ){ 147 welt_set_tweet_transient( $this->id, $instance , true ); 148 } 149 149 if( ! method_exists('WP_Widget', 'is_preview' ) || ! $this->is_preview() ){ 150 151 welt_set_tweet_transient( $this->id, $instance ); 152 153 } 150 154 151 155 return $instance; … … 168 172 // Are all the options there ? 169 173 if( is_array( $twitter_oauth_var ) && count($twitter_oauth_var) == 4 ){ 174 175 170 176 171 177 ?> … … 253 259 function welt_set_tweet_transient( $widget_id, $options ){ 254 260 255 $return_value = false;256 261 257 262 $last_tweet = welt_get_latest_tweet( $options ); … … 376 381 function welt_display_tweets( ){ 377 382 378 $widget_id = $_POST['widget_id']; 379 380 $tweet_html = ''; 381 382 // In preview mode we passe all instance in data html attrribut 383 if( isset( $_POST['widget_data'] ) && ! empty( $_POST['widget_data'] ) ){ 384 385 $instance = $_POST['widget_data']; 386 387 $last_tweet = welt_get_latest_tweet( $instance ); 388 389 foreach ($last_tweet as $tweet_id) { 390 391 $tweet_html .= welt_get_tweet_html( $tweet_id, $instance ); 392 393 } 394 395 396 } else { 397 398 399 $last_tweet = get_transient('last_tweet_' . $widget_id); 400 401 if( false === $last_tweet ) { 402 403 // Get the widget instance 404 $all_instance_widget = get_option('widget_welt_last_tweets'); 405 406 $widget_real_id = str_replace('welt_last_tweets-', '', $widget_id); 407 408 $instance = $all_instance_widget[$widget_real_id]; 409 410 411 // Set the transient for this widget 383 $all_welt_widgets = $_POST['all_welt_widgets']; 384 385 $tweet_html = array(); 386 387 foreach ($all_welt_widgets as $welt_widget ) { 388 389 $widget_id = $welt_widget['widget_id']; 390 $widget_data = isset( $welt_widget['widget_data'] ) && ! empty( $welt_widget['widget_data'] ) ? $welt_widget['widget_data'] : false; 391 392 $tweet_html[ $widget_id ] = ''; 393 394 // In preview mode we passe all instance in data html attrribut 395 if( $widget_data ){ 396 397 $instance = $widget_data; 398 412 399 $last_tweet = welt_get_latest_tweet( $instance ); 413 }414 415 if( $last_tweet && is_array( $last_tweet ) ){416 417 set_transient('last_tweet_' . $widget_id , $last_tweet, 60 * 5);418 400 419 401 foreach ($last_tweet as $tweet_id) { 420 402 421 // retrocompatibility 422 if( is_object( $tweet_id ) ){ 423 $tweet_id = $tweet_id->id_str; 403 $tweet_html[ $widget_id ] .= welt_get_tweet_html( $tweet_id, $instance ); 404 405 } 406 407 408 } else { 409 410 411 $last_tweet = get_transient('last_tweet_' . $widget_id); 412 413 if( false === $last_tweet ) { 414 415 // Get the widget instance 416 $instance = $instance = welt_get_widget_instance( $widget_id ); 417 418 419 // Set the transient for this widget 420 $last_tweet = welt_get_latest_tweet( $instance ); 421 } 422 423 if( $last_tweet && is_array( $last_tweet ) ){ 424 425 set_transient('last_tweet_' . $widget_id , $last_tweet, 60 * 5); 426 427 foreach ($last_tweet as $tweet_id) { 428 429 // retrocompatibility 430 if( is_object( $tweet_id ) ){ 431 $tweet_id = $tweet_id->id_str; 432 } 433 434 $tweet_html_transient = get_transient('last_tweet_html_' . $tweet_id); 435 436 if( false === $tweet_html_transient ){ 437 438 $instance = welt_get_widget_instance( $widget_id ); 439 440 $tweet_html_transient = welt_get_tweet_html( $tweet_id, $instance ); 441 442 if( $tweet_html_transient ){ 443 set_transient('last_tweet_html_' . $tweet_id, $tweet_html_transient, ( 24 * WEEK_IN_SECONDS ) ); // 6 mouths 444 $tweet_html[ $widget_id ] .= $tweet_html_transient; 445 } 446 447 } else { 448 449 // retrocompatibility 450 if( is_object( $tweet_html_transient ) ){ 451 $tweet_html_transient = $tweet_html_transient->html; 452 } 453 $tweet_html[ $widget_id ] .= $tweet_html_transient; 454 } 455 424 456 } 425 426 $tweet_html_transient = get_transient('last_tweet_html_' . $tweet_id);427 428 if( false === $tweet_html_transient ){429 430 $tweet_html_transient = welt_get_tweet_html( $tweet_id, $instance );431 432 if( $tweet_html_transient ){433 set_transient('last_tweet_html_' . $tweet_id, $tweet_html_transient, ( 24 * WEEK_IN_SECONDS ) ); // 6 mouths434 $tweet_html .= $tweet_html_transient;435 }436 437 } else {438 439 // retrocompatibility440 if( is_object( $tweet_html_transient ) ){441 $tweet_html_transient = $tweet_html_transient->html;442 }443 $tweet_html .= $tweet_html_transient;444 }445 446 457 } 447 } 448 449 } 450 451 echo $tweet_html; 458 459 } 460 } 461 462 463 echo json_encode( $tweet_html ); 452 464 die; 453 465 } … … 456 468 add_action('wp_ajax_nopriv_welt_display_tweets', 'welt_display_tweets'); 457 469 470 471 /** 472 * Return the instance of a widget base on his id 473 */ 474 function welt_get_widget_instance( $widget_id ){ 475 476 // Get the widget instance 477 $all_instance_widget = get_option('widget_welt_last_tweets'); 478 479 $widget_real_id = str_replace('welt_last_tweets-', '', $widget_id); 480 481 return $all_instance_widget[$widget_real_id]; 482 } 458 483 459 484 /** -
widget-embed-lastest-tweets/trunk/js/welt-scripts.js
r907818 r953529 5 5 6 6 jQuery(document).ready( function(){ 7 8 var all_welt_widgets = []; 7 9 8 10 jQuery('.welt-tweet-wrapper').each( function(){ … … 14 16 widget_id = widget_id.replace('welt-', ''); 15 17 16 var data = { 17 action: 'welt_display_tweets', 18 widget_id: widget_id, 19 widget_data: widget_data 20 }; 18 all_welt_widgets.push( { widget_id : widget_id, widget_data : widget_data } ); 21 19 22 jQuery.post( 23 weltAjaxurl, 24 data, 25 function(response) { 26 current_widget.append(response); 20 }); 21 22 23 var data = { 24 action: 'welt_display_tweets', 25 all_welt_widgets: all_welt_widgets, 26 }; 27 28 jQuery.post( 29 weltAjaxurl, 30 data, 31 function(response) { 32 33 if( response ){ 34 response = JSON.parse( response ); 35 36 for( var i in response ){ 37 38 var widget_selector = '#welt-' + i; 39 jQuery( widget_selector ).append( response[i] ); 40 } 41 27 42 twttr.widgets.load(); 28 43 } 29 ); 30 31 }); 44 } 45 ); 32 46 }); 33 47 -
widget-embed-lastest-tweets/trunk/readme.txt
r946503 r953529 61 61 == Changelog == 62 62 63 = 0.6.4 = 64 65 * Only one AJAX calls to get Tweet data ( Thank you Christof Rodejohann ) 66 * Some bugfix for the new widget preview in the customizer 67 63 68 = 0.6.3 = 64 69 65 * fix : probleme with new tweet not showing 66 Thank you Christof Rodejohann 70 * fix : probleme with new tweet not showing ( Thank you Christof Rodejohann ) 67 71 68 72 = 0.6.2 = -
widget-embed-lastest-tweets/trunk/widget-embed-latest-tweets.php
r946507 r953529 4 4 * Plugin URI: http://arnaudban.me/blog/portfolio/widget-embed-latest-tweets/ 5 5 * Description: A Widget to show your latest Tweets. Use the oEmbed methode and some cache. Visit the option page "Plugins->Widget Embed Last Plugin" to authentify yourself 6 * Version: 0.6. 36 * Version: 0.6.4 7 7 * Author: Arnaud Banvillet 8 8 * Author URI: http://arnaudban.me … … 37 37 'align' => 'none', 38 38 'hide_thread' => true, 39 'lang' => 'en',40 39 'include_rts' => true, 41 40 'hide_media' => true, … … 54 53 array('description' => __('Show your latest Tweets', 'widget-embed-lastest-tweets'))// Args 55 54 ); 55 56 if( defined( 'WPLANG' ) ){ 57 $this->defaut['lang'] = substr( WPLANG, 0, 2 ); 58 } else { 59 $this->defaut['lang'] = 'en'; 60 } 56 61 } 57 62 … … 85 90 if( !empty( $screen_name ) ){ 86 91 87 if( method_exists('Widget', 'is_preview' ) && $this->is_preview() ){88 89 $data = ' '; 92 $data = ' '; 93 if( method_exists('WP_Widget', 'is_preview' ) && $this->is_preview() ){ 94 90 95 foreach ($instance as $key => $value) { 91 96 … … 95 100 } 96 101 97 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'$data></div>";98 99 } else {100 101 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'></div>";102 102 } 103 104 echo "<div id='welt-{$this->id}' class='welt-tweet-wrapper'$data></div>"; 105 103 106 } 104 107 … … 144 147 145 148 // When everythings is check and we are not in the customizer, set the transient 146 if( ! method_exists('Widget', 'is_preview' ) || ! $this->is_preview() ){ 147 welt_set_tweet_transient( $this->id, $instance , true ); 148 } 149 149 if( ! method_exists('WP_Widget', 'is_preview' ) || ! $this->is_preview() ){ 150 151 welt_set_tweet_transient( $this->id, $instance ); 152 153 } 150 154 151 155 return $instance; … … 168 172 // Are all the options there ? 169 173 if( is_array( $twitter_oauth_var ) && count($twitter_oauth_var) == 4 ){ 174 175 170 176 171 177 ?> … … 253 259 function welt_set_tweet_transient( $widget_id, $options ){ 254 260 255 $return_value = false;256 261 257 262 $last_tweet = welt_get_latest_tweet( $options ); … … 376 381 function welt_display_tweets( ){ 377 382 378 $widget_id = $_POST['widget_id']; 379 380 $tweet_html = ''; 381 382 // In preview mode we passe all instance in data html attrribut 383 if( isset( $_POST['widget_data'] ) && ! empty( $_POST['widget_data'] ) ){ 384 385 $instance = $_POST['widget_data']; 386 387 $last_tweet = welt_get_latest_tweet( $instance ); 388 389 foreach ($last_tweet as $tweet_id) { 390 391 $tweet_html .= welt_get_tweet_html( $tweet_id, $instance ); 392 393 } 394 395 396 } else { 397 398 399 $last_tweet = get_transient('last_tweet_' . $widget_id); 400 401 if( false === $last_tweet ) { 402 403 // Get the widget instance 404 $all_instance_widget = get_option('widget_welt_last_tweets'); 405 406 $widget_real_id = str_replace('welt_last_tweets-', '', $widget_id); 407 408 $instance = $all_instance_widget[$widget_real_id]; 409 410 411 // Set the transient for this widget 383 $all_welt_widgets = $_POST['all_welt_widgets']; 384 385 $tweet_html = array(); 386 387 foreach ($all_welt_widgets as $welt_widget ) { 388 389 $widget_id = $welt_widget['widget_id']; 390 $widget_data = isset( $welt_widget['widget_data'] ) && ! empty( $welt_widget['widget_data'] ) ? $welt_widget['widget_data'] : false; 391 392 $tweet_html[ $widget_id ] = ''; 393 394 // In preview mode we passe all instance in data html attrribut 395 if( $widget_data ){ 396 397 $instance = $widget_data; 398 412 399 $last_tweet = welt_get_latest_tweet( $instance ); 413 }414 415 if( $last_tweet && is_array( $last_tweet ) ){416 417 set_transient('last_tweet_' . $widget_id , $last_tweet, 60 * 5);418 400 419 401 foreach ($last_tweet as $tweet_id) { 420 402 421 // retrocompatibility 422 if( is_object( $tweet_id ) ){ 423 $tweet_id = $tweet_id->id_str; 403 $tweet_html[ $widget_id ] .= welt_get_tweet_html( $tweet_id, $instance ); 404 405 } 406 407 408 } else { 409 410 411 $last_tweet = get_transient('last_tweet_' . $widget_id); 412 413 if( false === $last_tweet ) { 414 415 // Get the widget instance 416 $instance = $instance = welt_get_widget_instance( $widget_id ); 417 418 419 // Set the transient for this widget 420 $last_tweet = welt_get_latest_tweet( $instance ); 421 } 422 423 if( $last_tweet && is_array( $last_tweet ) ){ 424 425 set_transient('last_tweet_' . $widget_id , $last_tweet, 60 * 5); 426 427 foreach ($last_tweet as $tweet_id) { 428 429 // retrocompatibility 430 if( is_object( $tweet_id ) ){ 431 $tweet_id = $tweet_id->id_str; 432 } 433 434 $tweet_html_transient = get_transient('last_tweet_html_' . $tweet_id); 435 436 if( false === $tweet_html_transient ){ 437 438 $instance = welt_get_widget_instance( $widget_id ); 439 440 $tweet_html_transient = welt_get_tweet_html( $tweet_id, $instance ); 441 442 if( $tweet_html_transient ){ 443 set_transient('last_tweet_html_' . $tweet_id, $tweet_html_transient, ( 24 * WEEK_IN_SECONDS ) ); // 6 mouths 444 $tweet_html[ $widget_id ] .= $tweet_html_transient; 445 } 446 447 } else { 448 449 // retrocompatibility 450 if( is_object( $tweet_html_transient ) ){ 451 $tweet_html_transient = $tweet_html_transient->html; 452 } 453 $tweet_html[ $widget_id ] .= $tweet_html_transient; 454 } 455 424 456 } 425 426 $tweet_html_transient = get_transient('last_tweet_html_' . $tweet_id);427 428 if( false === $tweet_html_transient ){429 430 $tweet_html_transient = welt_get_tweet_html( $tweet_id, $instance );431 432 if( $tweet_html_transient ){433 set_transient('last_tweet_html_' . $tweet_id, $tweet_html_transient, ( 24 * WEEK_IN_SECONDS ) ); // 6 mouths434 $tweet_html .= $tweet_html_transient;435 }436 437 } else {438 439 // retrocompatibility440 if( is_object( $tweet_html_transient ) ){441 $tweet_html_transient = $tweet_html_transient->html;442 }443 $tweet_html .= $tweet_html_transient;444 }445 446 457 } 447 } 448 449 } 450 451 echo $tweet_html; 458 459 } 460 } 461 462 463 echo json_encode( $tweet_html ); 452 464 die; 453 465 } … … 456 468 add_action('wp_ajax_nopriv_welt_display_tweets', 'welt_display_tweets'); 457 469 470 471 /** 472 * Return the instance of a widget base on his id 473 */ 474 function welt_get_widget_instance( $widget_id ){ 475 476 // Get the widget instance 477 $all_instance_widget = get_option('widget_welt_last_tweets'); 478 479 $widget_real_id = str_replace('welt_last_tweets-', '', $widget_id); 480 481 return $all_instance_widget[$widget_real_id]; 482 } 458 483 459 484 /**
Note: See TracChangeset
for help on using the changeset viewer.