🔌 Base for Helm chart that uses Ansible to set up a hardened WordPress https://code.habd.as/comfusion/WordPress
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.4 KiB

  1. <?php
  2. /**
  3. * Outputs the OPML XML format for getting the links defined in the link
  4. * administration. This can be used to export links from one blog over to
  5. * another. Links aren't exported by the WordPress export, so this file handles
  6. * that.
  7. *
  8. * This file is not added by default to WordPress theme pages when outputting
  9. * feed links. It will have to be added manually for browsers and users to pick
  10. * up that this file exists.
  11. *
  12. * @package WordPress
  13. */
  14. require_once __DIR__ . '/wp-load.php';
  15. header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
  16. $link_cat = '';
  17. if ( ! empty( $_GET['link_cat'] ) ) {
  18. $link_cat = $_GET['link_cat'];
  19. if ( ! in_array( $link_cat, array( 'all', '0' ), true ) ) {
  20. $link_cat = absint( (string) urldecode( $link_cat ) );
  21. }
  22. }
  23. echo '<?xml version="1.0"?' . ">\n";
  24. ?>
  25. <opml version="1.0">
  26. <head>
  27. <title>
  28. <?php
  29. /* translators: %s: Site title. */
  30. printf( __( 'Links for %s' ), esc_attr( get_bloginfo( 'name', 'display' ) ) );
  31. ?>
  32. </title>
  33. <dateCreated><?php echo gmdate( 'D, d M Y H:i:s' ); ?> GMT</dateCreated>
  34. <?php
  35. /**
  36. * Fires in the OPML header.
  37. *
  38. * @since 3.0.0
  39. */
  40. do_action( 'opml_head' );
  41. ?>
  42. </head>
  43. <body>
  44. <?php
  45. if ( empty( $link_cat ) ) {
  46. $cats = get_categories(
  47. array(
  48. 'taxonomy' => 'link_category',
  49. 'hierarchical' => 0,
  50. )
  51. );
  52. } else {
  53. $cats = get_categories(
  54. array(
  55. 'taxonomy' => 'link_category',
  56. 'hierarchical' => 0,
  57. 'include' => $link_cat,
  58. )
  59. );
  60. }
  61. foreach ( (array) $cats as $cat ) :
  62. /** This filter is documented in wp-includes/bookmark-template.php */
  63. $catname = apply_filters( 'link_category', $cat->name );
  64. ?>
  65. <outline type="category" title="<?php echo esc_attr( $catname ); ?>">
  66. <?php
  67. $bookmarks = get_bookmarks( array( 'category' => $cat->term_id ) );
  68. foreach ( (array) $bookmarks as $bookmark ) :
  69. /**
  70. * Filters the OPML outline link title text.
  71. *
  72. * @since 2.2.0
  73. *
  74. * @param string $title The OPML outline title text.
  75. */
  76. $title = apply_filters( 'link_title', $bookmark->link_name );
  77. ?>
  78. <outline text="<?php echo esc_attr( $title ); ?>" type="link" xmlUrl="<?php echo esc_attr( $bookmark->link_rss ); ?>" htmlUrl="<?php echo esc_attr( $bookmark->link_url ); ?>" updated="
  79. <?php
  80. if ( '0000-00-00 00:00:00' !== $bookmark->link_updated ) {
  81. echo $bookmark->link_updated;}
  82. ?>
  83. " />
  84. <?php
  85. endforeach; // $bookmarks
  86. ?>
  87. </outline>
  88. <?php
  89. endforeach; // $cats
  90. ?>
  91. </body>
  92. </opml>