section-article-function.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. if (iro_opt("article_function")) {
  3. ?>
  4. <footer class="post-footer">
  5. <?php
  6. global $post;
  7. $post_meta_license = get_post_meta($post->ID, 'license', true);
  8. $license = $post_meta_license ? $post_meta_license : iro_opt("article_lincenses");
  9. $license_link;
  10. $license_icon;
  11. $license_desc;
  12. if ($license != "0") {
  13. if ($license == "1") {
  14. $license = "cc-by-nc-sa";
  15. }
  16. if ($license === "cc0") {
  17. $license_link = "https://creativecommons.org/publicdomain/zero/1.0/";
  18. $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"), "CC0 1.0");
  19. $license_icon = array("fa-creative-commons-zero");
  20. } else {
  21. $variant = substr($license, 3);
  22. $license_link = "https://creativecommons.org/licenses/$variant/4.0/";
  23. $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"), "CC " . strtoupper($variant) . " 4.0");
  24. $license_icon = array_map(function ($v) {
  25. return "fa-creative-commons-$v";
  26. }, explode("-", $variant));
  27. }
  28. // 根据WP设置的语言填充链接
  29. // 不存在该语言翻译时会默认显示英文
  30. $locale = get_locale();
  31. ?>
  32. <a class="post-license" href="<?= $license_link . "deed." . $locale ?>" target="_blank" rel="nofollow" title="<?= $license_desc ?>">
  33. <i class="fa-brands fa-creative-commons"></i>
  34. <?php
  35. foreach ($license_icon as $icon_class) {
  36. echo '<i class="fa-brands ' . $icon_class . '"></i>';
  37. }
  38. ?>
  39. </a>
  40. <?php
  41. }
  42. ?>
  43. <?php the_reward(); ?>
  44. <section class="author-profile">
  45. <?php
  46. $author_id = get_the_author_meta('ID');
  47. $author_url = esc_url(get_author_posts_url($author_id));
  48. $author_name = get_the_author();
  49. ?>
  50. <div class="info" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
  51. <a href="<?= $author_url; ?>" class="profile gravatar">
  52. <img class="fa-spin" style="--fa-animation-duration: 15s;" src="<?php echo get_avatar_profile_url(); ?>" itemprop="image" alt="<?= $author_name; ?>" height="30" width="30">
  53. </a>
  54. </div>
  55. <div class="meta">
  56. <a href="<?= $author_url; ?>" itemprop="url" rel="author"><?= $author_name; ?></a>
  57. </div>
  58. <?php
  59. if (iro_opt('author_profile_quote') == '1') {
  60. $author_description = get_the_author_meta('description');
  61. if (empty($author_description)) {
  62. $author_description = __('This author has not provided a description.', 'sakurairo');
  63. }
  64. ?>
  65. <div class="desc">
  66. <i class="fa-solid fa-feather" aria-hidden="true"></i><?= $author_description; ?>
  67. </div>
  68. <?php } ?>
  69. </section>
  70. <div class="post-modified-time">
  71. <i class="fa-solid fa-calendar-day" aria-hidden="true"></i><?php _e('Last updated on ', 'sakurairo');
  72. echo get_the_modified_time('Y-m-d'); ?>
  73. </div>
  74. <div class="post-tags">
  75. <?php if (has_tag()) {
  76. echo '<i class="fa-solid fa-tag" aria-hidden="true"></i> ';
  77. the_tags('', ' ', ' ');
  78. } else {
  79. echo '<i class="fa-solid fa-tag" aria-hidden="true"></i> ';
  80. _e('Nothing~', 'sakurairo');
  81. } ?>
  82. </div>
  83. </footer><!-- .entry-footer -->
  84. <?php
  85. }