✏️ 正在编辑: content-card-1.php
路径:
/home/h359620/public_html/wp-content/themes/datis/template-parts/project/content/content-card-1.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php $post_id = get_the_ID(); /** * Read NEW project card features from CMB2 */ $features = get_post_meta($post_id, '_datis_project_card_features', true); if (is_string($features)) { $maybe = maybe_unserialize($features); if (is_array($maybe)) { $features = $maybe; } } if (!is_array($features)) { $features = []; } ?> <div class="wrapper"> <div class="projects-thumbnail"> <?php if (has_post_thumbnail()) : ?> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail(); ?> </a> <?php else : ?> <a href="<?php the_permalink(); ?>"> <img src="https://placehold.co/200x420" alt="<?php the_title_attribute(); ?>"> </a> <?php endif; ?> </div> <div class="project-details"> <h3 class="project-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h3> <?php if (!empty($features)) : ?> <ul class="project-metas"> <?php foreach ($features as $feature) : if (!is_array($feature)) continue; $icon_type = $feature['icon_type'] ?? 'icon'; // class | image $icon_class = trim($feature['icon_class'] ?? ''); $icon_image = $feature['icon_image'] ?? ''; $title = $feature['label'] ?? ''; $desc = $feature['value'] ?? ''; // Normalize icon_type if ($icon_type === 'class') { $icon_type = 'icon'; } // Normalize icon_image (ID | URL | array) if (is_array($icon_image)) { if (!empty($icon_image['id'])) { $icon_image = (int) $icon_image['id']; } elseif (!empty($icon_image['url'])) { $icon_image = $icon_image['url']; } elseif (!empty($icon_image[0])) { $icon_image = $icon_image[0]; } } // Build icon HTML $icon_html = ''; if ($icon_type === 'image' && $icon_image) { if (is_numeric($icon_image)) { $icon_html = wp_get_attachment_image( (int) $icon_image, 'thumbnail', false, [ 'class' => 'project-meta-icon', 'loading' => 'lazy', ] ); if (!$icon_html) { $src = wp_get_attachment_url((int) $icon_image); if ($src) { $icon_html = '<img class="project-meta-icon" src="' . esc_url($src) . '" alt="">'; } } } elseif (is_string($icon_image)) { $icon_html = '<img class="project-meta-icon" src="' . esc_url($icon_image) . '" alt="">'; } } elseif ($icon_type === 'icon' && $icon_class !== '') { $icon_html = '<i class="project-meta-icon ' . esc_attr($icon_class) . '" aria-hidden="true"></i>'; } ?> <li class="project-meta-item"> <?php if ($icon_html) : ?> <span class="project-meta-icon-wrap"> <?php echo $icon_html; ?> </span> <?php endif; ?> <div class="project-meta-content"> <?php if ($title) : ?> <h5 class="project-meta-title"><?php echo esc_html($title); ?></h5> <?php endif; ?> <?php if ($desc) : ?> <p class="project-meta-desc"><?php echo esc_html($desc); ?></p> <?php endif; ?> </div> </li> <?php endforeach; ?> </ul> <?php endif; ?> <?php if (has_excerpt()) : ?> <div class="project-excerpt"> <p><?php echo wp_trim_words(get_the_excerpt(), 12); ?></p> </div> <?php endif; ?> <a href="<?php the_permalink(); ?>" class="view-project"> <span class="view-project-text"> <?php esc_html_e('View project', 'datis'); ?> </span> <span class="view-project-icon"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6 6H15M6 6V15M6 6L12.5 12.5M18 18L15.5 15.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> </span> </a> </div> </div>
💾 保存文件
← 返回文件管理器