| Server IP : 119.36.225.67 / Your IP : 43.174.71.198 Web Server : nginx/1.28.0 System : Linux 1763701629066 6.8.0-53-generic #55-Ubuntu SMP PREEMPT_DYNAMIC Fri Jan 17 15:37:52 UTC 2025 x86_64 User : www ( 1001) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.lengcat.cn/wp-content/themes/onenav/inc/widgets/ |
Upload File : |
<?php
/*
* @Author: iowen
* @Author URI: https://www.iowen.cn/
* @Date: 2024-10-01 22:02:14
* @LastEditors: iowen
* @LastEditTime: 2024-11-02 23:45:25
* @FilePath: /onenav/inc/widgets/w.about.author.php
* @Description:
*/
IOCF::createWidget('iow_about_author_min', array(
'title' => 'IO 关于作者',
'classname' => 'io-widget-about-author',
'description' => '只显示在正文和作者页面',
'fields' => array(
array(
'id' => 'show_posts',
'type' => 'switcher',
'title' => '显示文章',
'default' => true,
'class' => 'compact min'
),
array(
'id' => 'count',
'type' => 'number',
'title' => '数量',
'unit' => '条',
'default' => 3,
'class' => 'compact min'
),
)
));
function iow_about_author_min($args, $instance)
{
if (!is_author() && !is_single()) {
return;
}
global $wpdb, $post;
$author_id = $post->post_author;
if(!$author_id){
return;
}
$author_url = get_author_posts_url($author_id);
$author_bg = get_lazy_img_bg(io_get_user_cover($author_id, "full"));
$avatar = get_avatar(get_the_author_meta('user_email',$author_id), '80');
$caption = io_get_user_cap_string($author_id);
$name = get_the_author_meta('nickname',$author_id);
$badge = io_get_user_badges($author_id, true);
$posts = '';
if ($instance['show_posts']) {
$query = new WP_Query(array(
'author' => $author_id,
'posts_per_page' => $instance['count'],
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
));
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$posts .= '<div class="text-sm min-posts-card line1 my-1"><a href="' . get_permalink() . '">' . get_the_title() . '</a></div>';
}
wp_reset_postdata();
}
}
$posts = $posts? '<div class="author-post-list mt-3">' . $posts . '</div>' : '';
echo $args['before_widget'];
echo <<<HTML
<div class="widget-author-cover br-top-inherit text-center">
<div class="author-bg bg-image br-top-inherit" {$author_bg}></div>
<div class="widget-author-avatar mt-n5">
<a href="{$author_url}" class="avatar-img">{$avatar}</a>
</div>
</div>
<div class="widget-author-meta p-3">
<div class="text-center mb-3">
<div>{$name}</div>
<div class="badge vc-purple btn-outline text-ss mt-2">{$caption}</div>
</div>
<div class="author-badge mt-2 d-flex justify-content-center">{$badge}</div>
{$posts}
</div>
HTML;
echo $args['after_widget'];
}