Skip to content
GitLab
Explore
Sign in
Commits on Source (1)
Extract blog name from URL when it is missing
· 5559e592
ale
authored
Apr 30, 2022
And replace get_post_permalink() with the more generic get_permalink() function.
5559e592
Hide whitespace changes
Inline
Side-by-side
ai-global-activity.php
View file @
5559e592
...
...
@@ -74,7 +74,7 @@ function ai_activity_publish_post($post_id) {
}
$post_title
=
get_the_title
(
$post
);
$post_url
=
get_
post_
permalink
(
$post
);
$post_url
=
get_permalink
(
$post
);
$post_content
=
apply_filters
(
'the_content'
,
get_the_content
(
'more...'
,
false
,
$post
));
$post_excerpt
=
get_the_excerpt
(
$post
);
$post_author
=
apply_filters
(
'the_author'
,
$post
->
post_author
);
...
...
@@ -125,6 +125,16 @@ function ai_activity_get_next_page_link() {
return
"?"
.
AI_ACTIVITY_PAGE_ARG_NAME
.
"="
.
(
$p
+
1
);
}
function
ai_activity_get_blog_name
(
$blog_id
)
{
$blog_details
=
get_blog_details
(
$blog_id
);
$blog_name
=
$blog_details
->
blogname
;
if
(
!
$blog_name
)
{
preg_match
(
'/^https?:\/\/([^.]+)/'
,
get_site_url
(
$blog_id
),
$matches
);
$blog_name
=
$matches
[
1
];
}
return
$blog_name
;
}
function
ai_activity_get_latest_posts
(
$offset
,
$limit
)
{
global
$wpdb
;
...
...
@@ -170,9 +180,9 @@ function ai_activity_display_recent_posts($tmp_number, $tmp_title_characters, $t
}
if
(
$show_blog
)
{
$blog_
details
=
get_blog_
details
(
$blog_id
);
$blog_
name
=
esc_html
(
ai_activity_
get_blog_
name
(
$blog_id
)
)
;
$site_url
=
get_site_url
(
$blog_id
);
$html
.
=
" (<a href=
\"
{
$site_url
}
\"
>
{
$blog_
details
->
blog
name
}
</a>)"
;
$html
.
=
" (<a href=
\"
{
$site_url
}
\"
>
{
$blog_name
}
</a>)"
;
}
$html
.
=
"</div>"
;
}
...
...