• Resolved yitwail

    (@yitwail)


    Would it be possible to add something like the snippet below to rotatingtweets.php? This would allow developers to rearrange things, alter text, substitute screen_name for name, etc. I think the plugin is terrific, but I had to hack it and add this snippet so I could format the tweets the way the user requested it. It drops through to case ‘0’ unless functions.php contains a function named override_rotating_tweets_meta.

    Thanks.

    # Now for the meta text
    switch ($args['official_format']) {
    case 'custom':
    	if (function_exists('override_rotating_tweets_meta')) {
    		$result .= override_rotating_tweets_meta(
    			$args, $user, $main_text, $twitter_object, $twitterlocale, $targetvalue);
    		break;
    	}

    https://wordpress.org/plugins/rotatingtweets/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Martin Tod

    (@mpntod)

    What a brilliant idea! I’ve included it in the development version.

    I’ve adjusted it a bit to add in other possible display variables:

    case 'custom':
    	# This first option lets you use your own function to display tweets
    	if (function_exists('rotatingtweets_display_override')) {
    		$result .= rotatingtweets_display_override(
    			$args, $tweetuser, $main_text, $twitter_object, $twitterlocale, $targetvalue, $retweeter = array(), $show_media='', $nextprev='' );
    		break;
    	}

    I’ve also changed the function name to be slightly more consistent with other RT functions.

    The one thing that may be different vs. your version is how retweets are handled. To get an ‘old style’ retweet, you will need some code like:

    if(isset($retweeter)):
    	$main_text = "RT @".$tweetuser['screen_name'] . " " . $main_text;
    	$tweetuser = $retweeter;
    endif;

    to convert back to that format of display.

    Thread Starter yitwail

    (@yitwail)

    Martin,

    that’s kind of you. I’ll try the development version shortly.

    thanks,
    John

    Thread Starter yitwail

    (@yitwail)

    Martin,

    Your new code eliminates the nextprev links, among other things. I think it should look something like this:

    if (function_exists('rotatingtweets_display_override')) {
    	$retweeter = isset($retweeter)? $retweeter : array();
    	$show_media = isset($show_media)? $show_media : '';
    	$nextprev = isset($nextprev)? $nextprev : '';
    	$result .= rotatingtweets_display_override(
    		$args, $tweetuser, $main_text, $twitter_object, $twitterlocale, $targetvalue, $retweeter, $show_media, $nextprev );

    Otherwise, it works fine.

    Plugin Author Martin Tod

    (@mpntod)

    Good stuff – although it shouldn’t have been resetting the values – just setting default argument values.

    It should all be fine now – and I’ve also (in theory) added it as an option to the widget! (Does this work?)

    Incidentally, the old-style retweet should probably be:

    if(isset($retweeter)):
    	$main_text = "RT " . rotatingtweets_user_intent($tweetuser,$twitterlocale,'screen_name',$targetvalue) . " " . $main_text;
    	$tweetuser = $retweeter;
    endif;

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Feature request: custom 'official_format'’ is closed to new replies.