Skip to content

Commit b4e9b63

Browse files
committed
Bugfix 2 Links @ 1 Tweet
1 parent 8fd1f8d commit b4e9b63

File tree

3 files changed

+53
-26
lines changed

3 files changed

+53
-26
lines changed

mathilda_painting.php

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -493,24 +493,30 @@ function mathilda_tweet_paint($date,$tweet,$id,$me,$image,$mention,$url,$hashtag
493493

494494
if ($url=='TRUE')
495495
{
496+
foreach($tweet_urls as $tweet_url) {
497+
496498
if ($url_handling=='Longlink') {
497-
$tweet=str_replace ( $tweet_urls[0][1], ' ' , $tweet ) ;
499+
500+
$tweet=str_replace ( $tweet_url[1], ' ' , $tweet ) ;
501+
498502
}
499503
elseif ($url_handling=='Shortlink') {
500504
if($embed_content) {
501-
$embed_value=mathilda_embed_rendering($tweet_urls[0][0],$tweet_urls[0][2]);
505+
$embed_value=mathilda_embed_rendering($tweet_url[0],$tweet_url[2]);
502506
if($embed_value) {
503507
$url_handling="Longlink";
504-
$tweet=str_replace ( $tweet_urls[0][1], ' ' , $tweet ) ;
508+
$tweet=str_replace ( $tweet_url[1], ' ' , $tweet ) ;
505509
}
506510
else {
507-
$shortlink='<a class="mathilda-tweet-url-link mathilda-shortlink" href="'.$tweet_urls[0][1].'" target="_blank">'.$tweet_urls[0][3].'</a>';$tweet=str_replace ( $tweet_urls[0][1], $shortlink , $tweet ) ;
511+
$shortlink='<a class="mathilda-tweet-url-link mathilda-shortlink" href="'.$tweet_url[1].'" target="_blank">'.$tweet_url[3].'</a>';$tweet=str_replace ( $tweet_url[1], $shortlink , $tweet ) ;
508512
}
509513
} else {
510-
$shortlink='<a class="mathilda-tweet-url-link mathilda-shortlink" href="'.$tweet_urls[0][1].'" target="_blank">'.$tweet_urls[0][3].'</a>';
511-
$tweet=str_replace ( $tweet_urls[0][1], $shortlink , $tweet ) ;
514+
$shortlink='<a class="mathilda-tweet-url-link mathilda-shortlink" href="'.$tweet_url[1].'" target="_blank">'.$tweet_url[3].'</a>';
515+
$tweet=str_replace ( $tweet_url[1], $shortlink , $tweet ) ;
512516
}
513517
}
518+
519+
}
514520
}
515521

516522
/* Media Transformation @ Tweet */
@@ -528,37 +534,56 @@ function mathilda_tweet_paint($date,$tweet,$id,$me,$image,$mention,$url,$hashtag
528534
/* Paint URL */
529535
if ($url=='TRUE')
530536
{
531-
if ($url_handling=='Longlink') {
532-
if($embed_content) {
533537

534-
$embed_value=mathilda_embed_rendering($tweet_urls[0][0],$tweet_urls[0][2]);
538+
// Initialize URL Counter
539+
$number_of_urls=count($tweet_urls);
540+
$current_url=1;
541+
542+
foreach($tweet_urls as $tweet_url)
543+
{
544+
// Margin Bottom More As 1 URL
545+
if($number_of_urls > $current_url ) {
546+
$current_url_style=' style="margin-bottom:5px"';
547+
}
548+
else {
549+
$current_url_style="";
550+
}
551+
552+
$current_url=$current_url+1;
553+
554+
if ($url_handling=='Longlink') {
535555

536-
if ($embed_value) {
556+
if($embed_content) {
537557

538-
if (is_ssl()) {
539-
if (strpos($tweet_urls[0][2], 'https://') !== false) {
558+
$embed_value=mathilda_embed_rendering($tweet_url[0],$tweet_url[2]);
559+
560+
if ($embed_value) {
561+
562+
if (is_ssl()) {
563+
if (strpos($tweet_url[2], 'https://') !== false) {
564+
$mathilda_content.='<div class="mathilda-tweet-url mathilda-embed mathilda-longlink'.$image_follows_class_url.'"> ';
565+
$mathilda_content.=$embed_value;
566+
$mathilda_content.=' </div>';
567+
}
568+
else {
569+
$mathilda_content.='<p class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" '.$current_url_style.' href="'.$tweet_url[2].'" target="_blank">'.$tweet_url[2].'</a></p>';
570+
}
571+
} else {
540572
$mathilda_content.='<div class="mathilda-tweet-url mathilda-embed mathilda-longlink'.$image_follows_class_url.'"> ';
541573
$mathilda_content.=$embed_value;
542574
$mathilda_content.=' </div>';
543575
}
544-
else {
545-
$mathilda_content.='<p class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" href="'.$tweet_urls[0][2].'" target="_blank">'.$tweet_urls[0][2].'</a></p>';
546-
}
576+
547577
} else {
548-
$mathilda_content.='<div class="mathilda-tweet-url mathilda-embed mathilda-longlink'.$image_follows_class_url.'"> ';
549-
$mathilda_content.=$embed_value;
550-
$mathilda_content.=' </div>';
578+
$mathilda_content.='<p '.$current_url_style.' class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" href="'.$tweet_url[2].'" target="_blank">'.$tweet_url[2].'</a></p>';
551579
}
552580

553-
} else {
554-
$mathilda_content.='<p class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" href="'.$tweet_urls[0][2].'" target="_blank">'.$tweet_urls[0][2].'</a></p>';
555581
}
556-
557-
}
558-
else {
559-
$mathilda_content.='<p class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" href="'.$tweet_urls[0][2].'" target="_blank">'.$tweet_urls[0][2].'</a></p>';
560-
}
561-
}
582+
else {
583+
$mathilda_content.='<p '.$current_url_style.' class="mathilda-tweet-url mathilda-longlink'.$image_follows_class_url.'"><a class="mathilda-tweet-url-link" href="'.$tweet_url[2].'" target="_blank">'.$tweet_url[2].'</a></p>';
584+
}
585+
}
586+
}
562587
}
563588

564589
/* Paint Image */

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ This project is licensed under the GPL3 License.
156156

157157
* June 2018
158158
* Feature: Support of Tweet Galleries
159+
* Bugfix: URL Rendering (if more as 1 Link is included)
159160

160161
### 0.9 "Renee Montoya"
161162

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Backlinks to Twitter will be declared as nofollow. This affects Hashtags, Mentio
108108
= 0.10 "Deadshot" =
109109
* June 2018
110110
* Feature: Support of Tweet Galleries
111+
* Bugfix: URL Rendering (if more as 1 Link is included)
111112

112113
= 0.9 "Renee Montoya" =
113114
* April 2018

0 commit comments

Comments
 (0)