a722/data/db/base/13394/3380">3380 a4345e5759 first commit лет назад: 4 3381 a4345e5759 first commit лет назад: 4 3394 a4345e5759 first commit лет назад: 4 3394_fsm a4345e5759 first commit лет назад: 4 3394_vm a4345e5759 first commit лет назад: 4 3395 a4345e5759 first commit лет назад: 4 3429 a4345e5759 first commit лет назад: 4 3430 a4345e5759 first commit лет назад: 4 3431 a4345e5759 first commit лет назад: 4 3433 a4345e5759 first commit лет назад: 4 3439 a4345e5759 first commit лет назад: 4 3440 a4345e5759 first commit лет назад: 4 3455 a4345e5759 first commit лет назад: 4 3456 a4345e5759 first commit лет назад: 4 3456_fsm a4345e5759 first commit лет назад: 4 3456_vm a4345e5759 first commit лет назад: 4 3466 a4345e5759 first commit лет назад: 4 3467 a4345e5759 first commit лет назад: 4 3468 a4345e5759 first commit лет назад: 4 3501 a4345e5759 first commit лет назад: 4 3502 a4345e5759 first commit лет назад: 4 3503 a4345e5759 first commit лет назад: 4 3534 a4345e5759 first commit лет назад: 4 3541 a4345e5759 first commit лет назад: 4 3541_fsm a4345e5759 first commit лет назад: 4 3541_vm a4345e5759 first commit лет назад: 4 3542 a4345e5759 first commit лет назад: 4 3574 a4345e5759 first commit лет назад: 4 3575 a4345e5759 first commit лет назад: 4 3576 a4345e5759 first commit лет назад: 4 3596 a4345e5759 first commit лет назад: 4 3597 a4345e5759 first commit лет назад: 4 3598 a4345e5759 first commit лет назад: 4 3599 a4345e5759 first commit лет назад: 4 3600 a4345e5759 first commit лет назад: 4 3600_fsm a4345e5759 first commit лет назад: 4 3600_vm a4345e5759 first commit лет назад: 4 3601 a4345e5759 first commit лет назад: 4 3601_fsm a4345e5759 first commit лет назад: 4 3601_vm a4345e5759 first commit лет назад: 4 3602 a4345e5759 first commit лет назад: 4 3602_fsm a4345e5759 first commit лет назад: 4 3602_vm a4345e5759 first commit лет назад: 4 3603 a4345e5759 first commit лет назад: 4 3603_fsm a4345e5759 first commit лет назад: 4 3603_vm a4345e5759 first commit лет назад: 4 3604 a4345e5759 first commit лет назад: 4 3605 a4345e5759 first commit лет назад: 4 3606 a4345e5759 first commit лет назад: 4 3607 a4345e5759 first commit лет назад: 4 3608 a4345e5759 first commit лет назад: 4 3609 a4345e5759 first commit лет назад: 4 3712 a4345e5759 first commit лет назад: 4 3764 a4345e5759 first commit лет назад: 4 3764_fsm a4345e5759 first commit лет назад: 4 3764_vm a4345e5759 first commit лет назад: 4 3766 a4345e5759 first commit лет назад: 4 3767 a4345e5759 first commit лет назад: 4 3997 a4345e5759 first commit лет назад: 4 4143 a4345e5759 first commit лет назад: 4 4144 a4345e5759 first commit лет назад: 4 4145 a4345e5759 first commit лет назад: 4 4146 a4345e5759 first commit лет назад: 4 4147 a4345e5759 first commit лет назад: 4 4148 a4345e5759 first commit лет назад: 4 4149 a4345e5759 first commit лет назад: 4 4150 a4345e5759 first commit лет назад: 4 4151 a4345e5759 first commit лет назад: 4 4152 a4345e5759 first commit лет назад: 4 4153 a4345e5759 first commit лет назад: 4 4154 a4345e5759 first commit лет назад: 4 4155 a4345e5759 first commit лет назад: 4 4156 a4345e5759 first commit лет назад: 4 4157 a4345e5759 first commit лет назад: 4 4158 a4345e5759 first commit лет назад: 4 4159 a4345e5759 first commit лет назад: 4 4160 a4345e5759 first commit лет назад: 4 4161 a4345e5759 first commit лет назад: 4 4162 a4345e5759 first commit лет назад: 4 4163 a4345e5759 first commit лет назад: 4 4164 a4345e5759 first commit лет назад: 4 4165 a4345e5759 first commit лет назад: 4 4166 a4345e5759 first commit лет назад: 4 4167 a4345e5759 first commit лет назад: 4 4168 a4345e5759 first commit лет назад: 4 4169 a4345e5759 first commit лет назад: 4 4170 a4345e5759 first commit лет назад: 4 4171 a4345e5759 first commit лет назад: 4 4172 a4345e5759 first commit лет назад: 4 4173 a4345e5759 first commit лет назад: 4 4174 a4345e5759 first commit лет назад: 4 5002 a4345e5759 first commit лет назад: 4 548 a4345e5759 first commit лет назад: 4 549 a4345e5759 first commit лет назад: 4 6102 a4345e5759 first commit лет назад: 4 6104 a4345e5759 first commit лет назад: 4 6106 a4345e5759 first commit лет назад: 4 6110 a4345e5759 first commit лет назад: 4 6111 a4345e5759 first commit лет назад: 4 6112 a4345e5759 first commit лет назад: 4 6113 a4345e5759 first commit лет назад: 4 6117 a4345e5759 first commit лет назад: 4 826 a4345e5759 first commit лет назад: 4 827 a4345e5759 first commit лет назад: 4 828 a4345e5759 first commit лет назад: 4 PG_VERSION a4345e5759 first commit лет назад: 4 pg_filenode.map a4345e5759 first commit лет назад: 4 tum/whitesports - Gogs: Simplico Git Service

Keine Beschreibung

rss.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Server-side rendering of the `core/rss` block.
  4. *
  5. * @package WordPress
  6. */
  7. /**
  8. * Renders the `core/rss` block on server.
  9. *
  10. * @param array $attributes The block attributes.
  11. *
  12. * @return string Returns the block content with received rss items.
  13. */
  14. function render_block_core_rss( $attributes ) {
  15. $rss = fetch_feed( $attributes['feedURL'] );
  16. if ( is_wp_error( $rss ) ) {
  17. return '<div class="components-placeholder"><div class="notice notice-error"><strong>' . __( 'RSS Error:' ) . '</strong> ' . $rss->get_error_message() . '</div></div>';
  18. }
  19. if ( ! $rss->get_item_quantity() ) {
  20. return '<div class="components-placeholder"><div class="notice notice-error">' . __( 'An error has occurred, which probably means the feed is down. Try again later.' ) . '</div></div>';
  21. }
  22. $rss_items = $rss->get_items( 0, $attributes['itemsToShow'] );
  23. $list_items = '';
  24. foreach ( $rss_items as $item ) {
  25. $title = esc_html( trim( strip_tags( $item->get_title() ) ) );
  26. if ( empty( $title ) ) {
  27. $title = __( '(no title)' );
  28. }
  29. $link = $item->get_link();
  30. $link = esc_url( $link );
  31. if ( $link ) {
  32. $title = "<a href='{$link}'>{$title}</a>";
  33. }
  34. $title = "<div class='wp-block-rss__item-title'>{$title}</div>";
  35. $date = '';
  36. if ( $attributes['displayDate'] ) {
  37. $date = $item->get_date( 'U' );
  38. if ( $date ) {
  39. $date = sprintf(
  40. '<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
  41. date_i18n( get_option( 'c' ), $date ),
  42. date_i18n( get_option( 'date_format' ), $date )
  43. );
  44. }
  45. }
  46. $author = '';
  47. if ( $attributes['displayAuthor'] ) {
  48. $author = $item->get_author();
  49. if ( is_object( $author ) ) {
  50. $author = $author->get_name();
  51. $author = '<span class="wp-block-rss__item-author">' . sprintf(
  52. /* translators: %s: the author. */
  53. __( 'by %s' ),
  54. esc_html( strip_tags( $author ) )
  55. ) . '</span>';
  56. }
  57. }
  58. $excerpt = '';
  59. if ( $attributes['displayExcerpt'] ) {
  60. $excerpt = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
  61. $excerpt = esc_attr( wp_trim_words( $excerpt, $attributes['excerptLength'], ' [&hellip;]' ) );
  62. // Change existing [...] to [&hellip;].
  63. if ( '[...]' === substr( $excerpt, -5 ) ) {
  64. $excerpt = substr( $excerpt, 0, -5 ) . '[&hellip;]';
  65. }
  66. $excerpt = '<div class="wp-block-rss__item-excerpt">' . esc_html( $excerpt ) . '</div>';
  67. }
  68. $list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>";
  69. }
  70. $classnames = array();
  71. if ( isset( $attributes['blockLayout'] ) && 'grid' === $attributes['blockLayout'] ) {
  72. $classnames[] = 'is-grid';
  73. }
  74. if ( isset( $attributes['columns'] ) && 'grid' === $attributes['blockLayout'] ) {
  75. $classnames[] = 'columns-' . $attributes['columns'];
  76. }
  77. $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
  78. return sprintf( '<ul %s>%s</ul>', $wrapper_attributes, $list_items );
  79. }
  80. /**
  81. * Registers the `core/rss` block on server.
  82. */
  83. function register_block_core_rss() {
  84. register_block_type_from_metadata(
  85. __DIR__ . '/rss',
  86. array(
  87. 'render_callback' => 'render_block_core_rss',
  88. )
  89. );
  90. }
  91. add_action( 'init', 'register_block_core_rss' );