Last active
May 23, 2016 18:08
-
-
Save jtsternberg/ace26c317c4d4a070abd to your computer and use it in GitHub Desktop.
basic usage for wds twitter widget (outside a widget)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
wds_twwi_disable_widget_app_settings( array( | |
'consumer_key' => 'YOUR CONSUMER KEY', | |
'consumer_secret' => 'YOUR CONSUMER SECRET', | |
'access_token' => 'YOUR ACCESS TOKEN', | |
'access_token_secret' => 'YOUR ACCESS TOKEN SECRET', | |
) ); | |
add_filter( 'wds_twwi_do_widget', '__return_false' ); | |
function wds_get_tweets( $settings = array() ) { | |
$tw_app = TwitterWP::start()->get_app_creds(); | |
$defaults = array( | |
'twitter_id' => '', // twitter username | |
'twitter_num' => 1, // number of tweets | |
'twitter_duration' => 60, // transient cache duration | |
'twitter_hide_replies' => 0, // Show user's @replies | |
'show_time_stamp' => 0, // Show tweet timestamp | |
'follow_link_show' => 0, // Show a 'follow user' link | |
'follow_link_text' => '', // Text for follow_link_show link | |
'consumer_key' => $tw_app[0], // | |
'consumer_secret' => $tw_app[1], | |
'access_token' => $tw_app[2], | |
'access_token_secret' => $tw_app[3], | |
); | |
$settings = wp_parse_args( $settings, $defaults ); | |
return WDS_Twitter::get_tweets( $settings ); | |
} | |
function wds_do_tweet( $settings = array() ) { | |
$tweets = wds_get_tweets( $settings ); | |
foreach ( $tweets as $tweet ) { | |
echo $tweet; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or to have the plugin handle the output:
^ to return the output rather than echo it, change the last line to:
return WDS_Twitter::get_tweets_list( $settings );