HEX
Server: nginx/1.16.1
System: Linux VM-0-14-centos 4.18.0-348.7.1.el8_5.x86_64 #1 SMP Wed Dec 22 13:25:12 UTC 2021 x86_64
User: www (1000)
PHP: 8.3.31
Disabled: 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
Upload Files
File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/template/module-page/theme-news-3.php
<?php
/**
 * Template: 新闻资讯
 * @Author: 大胡子
 * @Email:  dahuzi@xintheme.com
 * @Link:   www.xintheme.com
 * @Date:   2023-08-01 07:27:28
 * @Last Modified by:   dahuzi
 * @Last Modified time: 2024-08-28 16:26:25
 */

$data_settings    = wp_json_encode([
    'id' => $module['id'],
]);
// 将 JSON 数据转义为 HTML 属性
$data_settings = esc_attr($data_settings);

if(!empty($module_content)){?>
<div class="section">
    <div class="container">
        <?php
        if( !empty($module_setting['title_display']) ){?>
        <div class="section-title <?php echo $wow_style;?>">
            <?php
            if( !empty($module_title) ){
            echo '<strong>'.$module_title.'</strong>';
            }
            if( !empty($module_desc) ){
            echo '<p>'.$module_desc.'</p>';
            }
            ?>
        </div>
        <?php
        }

        //分类目录
        $count_cat = count((array)$module_content['cat_id']);//大于1个分类才显示tab菜单
        if( !empty($module_content['cat_id']) && $count_cat>1 ){
            echo '<ul class="'.$wow_style.' tab-post-menu menu-'.$module['id'].' mb-tab-menu" data-settings='.$data_settings.'>';
            foreach ($module_content['cat_id'] as $cat_id ){
                $cat = get_category($cat_id);
                echo '<li>';
                    echo '<a href="javascript:;">'.$cat->name.'</a>';
                echo '</li>';
            } 
            echo '</ul>';
        }?>
        <div class="<?php echo $wow_style;?> swiper content-<?php echo $module['id'];?> swiper-container" data-settings='<?php echo $data_settings;?>'>
            <div class="swiper-wrapper">
                <?php
                //对应的分类文章
                if( !empty($module_content['cat_id']) ){
                    foreach ($module_content['cat_id'] as $cat_id ){
                    ?>
                    <div class="swiper-slide">
                        <div class="md-news">
                            <?php
                            //最新文章
                            if( $module_content['large_type'] == 'new_post' ){

                                $cat_posts_query = wpjam_query([
                                    'posts_per_page'        => 1,
                                    'ignore_sticky_posts'   => true,
                                    'cat'                   => $cat_id,
                                ]);
                                if($cat_posts_query->have_posts()){

                                    while($cat_posts_query->have_posts()){
                                        $cat_posts_query->the_post();
                                        global $post;
                                        //获取文章缩略图
                                        $get_post_thumbnail_url = wpjam_get_post_thumbnail_url();

                                        //图片Alt标签
                                        $img_alt = get_the_title();

                                        echo '<div class="news-large">';
                                        echo '<img loading="lazy" src="'.$get_post_thumbnail_url.'" alt="'.$img_alt.'" />';
                                        echo '<div class="large-text">';
                                        echo '<h2>'.get_the_title().'</h2>';
                                        echo dahuzi_excerpt( 180, '...' );
                                        echo '</div>';
                                        echo '<a href="'.get_the_permalink().'" aria-label="'.get_the_title().'"></a>';
                                        echo '</div>';

                                    }
                                    wp_reset_query();

                                }

                            //自定义图文
                            }elseif( $module_content['large_type'] == 'custom_image' ){
                                echo '<div class="news-large">';
                                if( !empty($module_content['large_img']) ){
                                    echo '<img loading="lazy" src="'.$module_content['large_img'].'" alt="'.dahuzi_get_image_alt($module_content['large_img']).'" />';
                                }
                                if( !empty($module_content['large_title']) || !empty($module_content['large_desc']) ){
                                    echo '<div class="large-text">';
                                    if( !empty($module_content['large_title']) ){
                                        echo '<h2>'.$module_content['large_title'].'</h2>';
                                    }
                                    if( !empty($module_content['large_desc']) ){
                                        echo '<p>'.$module_content['large_desc'].'</p>';
                                    }
                                    echo '</div>';
                                }
                                if( !empty($module_content['large_url']) ){
                                    echo '<a href="'.$module_content['large_url'].'" aria-label="'.$module_content['large_title'].'"></a>';
                                }
                                echo '</div>';
                            }?>
                            <div class="news-list">
                                <?php

                                    if( $module_content['large_type'] == 'new_post' ){
                                        $cat_posts_query = wpjam_query([
                                            'offset'                => 1,
                                            'posts_per_page'        => 4,
                                            'ignore_sticky_posts'   => true,
                                            'cat'                   => $cat_id,
                                        ]);
                                    }else{
                                        $cat_posts_query = wpjam_query([
                                            'posts_per_page'        => 4,
                                            'ignore_sticky_posts'   => true,
                                            'cat'                   => $cat_id,
                                        ]);
                                    }
 
                                    if($cat_posts_query->have_posts()){

                                        while($cat_posts_query->have_posts()){
                                            $cat_posts_query->the_post();
                                            global $post;
                                            ?>
                                            <a href="<?php the_permalink();?>" class="news-itme">
                                                <?php
                                                //样式-2不显示发布日期
                                                if( $module_setting['list_style'] != 'style_2'){?>
                                                <div class="itme-time">
                                                    <span><?php the_time('m-d');?></span>
                                                    <span><?php the_time('Y');?></span>
                                                </div>
                                                <?php }?>
                                                <div class="itme-text">
                                                    <h2><?php the_title();?></h2>
                                                    <?php dahuzi_excerpt( 180, '...' );?>
                                                </div>
                                            </a>
                                            <?php
                                        }
                                        wp_reset_query();

                                    }else{
                                        echo '<p style="width:100%;text-align:center;">'.__( '暂无相关内容', 'modular_theme' ).'</p>';
                                    }
                                    ?>
                            </div>
                            <?php if( !empty($module_setting['cat_url']) ){
                                echo '<a href="'.get_category_link($cat_id).'" class="cat-url">'.__( '查看更多', 'modular_theme' ).'</a>';
                            }?>
                        </div>
                    </div>
                    <?php
                    }
                }
                ?>
            </div>
        </div>
    </div>
</div>
<?php }?>

<?php
//echo wpjam_print_r( $module_setting );
//echo wpjam_print_r( $module_content );
//echo wpjam_print_r( $module_style );