/xmlrpc.php

  1. <?php 
  2. /** 
  3. * XML-RPC protocol support for WordPress 
  4. * 
  5. * @package WordPress 
  6. */ 
  7.  
  8. /** 
  9. * Whether this is an XML-RPC Request 
  10. * 
  11. * @var bool 
  12. */ 
  13. define('XMLRPC_REQUEST', true); 
  14.  
  15. // Some browser-embedded clients send cookies. We don't want them. 
  16. $_COOKIE = array(); 
  17.  
  18. // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,  
  19. // but we can do it ourself. 
  20. if ( !isset( $HTTP_RAW_POST_DATA ) ) { 
  21. $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); 
  22.  
  23. // fix for mozBlog and other cases where '<?xml' isn't on the very first line 
  24. if ( isset($HTTP_RAW_POST_DATA) ) 
  25. $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); 
  26.  
  27. /** Include the bootstrap for setting up WordPress environment */ 
  28. include( dirname( __FILE__ ) . '/wp-load.php' ); 
  29.  
  30. if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html 
  31. header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 
  32. ?> 
  33. <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 
  34. <rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"> 
  35. <service> 
  36. <engineName>WordPress</engineName> 
  37. <engineLink>https://wordpress.org/</engineLink> 
  38. <homePageLink><?php bloginfo_rss('url') ?></homePageLink> 
  39. <apis> 
  40. <api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> 
  41. <api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> 
  42. <api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> 
  43. <api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url('xmlrpc.php', 'rpc') ?>" /> 
  44. <?php 
  45. /** 
  46. * Add additional APIs to the Really Simple Discovery (RSD) endpoint. 
  47. * 
  48. * @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html 
  49. * 
  50. * @since 3.5.0 
  51. */ 
  52. do_action( 'xmlrpc_rsd_apis' ); 
  53. ?> 
  54. </apis> 
  55. </service> 
  56. </rsd> 
  57. <?php 
  58. exit; 
  59.  
  60. include_once(ABSPATH . 'wp-admin/includes/admin.php'); 
  61. include_once(ABSPATH . WPINC . '/class-IXR.php'); 
  62. include_once(ABSPATH . WPINC . '/class-wp-xmlrpc-server.php');  
  63.  
  64. /** 
  65. * Posts submitted via the XML-RPC interface get that title 
  66. * @name post_default_title 
  67. * @var string 
  68. */ 
  69. $post_default_title = ""; 
  70.  
  71. /** 
  72. * Filters the class used for handling XML-RPC requests. 
  73. * 
  74. * @since 3.1.0 
  75. * 
  76. * @param string $class The name of the XML-RPC server class. 
  77. */ 
  78. $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' ); 
  79. $wp_xmlrpc_server = new $wp_xmlrpc_server_class; 
  80.  
  81. // Fire off the request 
  82. $wp_xmlrpc_server->serve_request(); 
  83.  
  84. exit; 
  85.  
  86. /** 
  87. * logIO() - Writes logging info to a file. 
  88. * 
  89. * @deprecated 3.4.0 Use error_log() 
  90. * @see error_log() 
  91. * 
  92. * @param string $io Whether input or output 
  93. * @param string $msg Information describing logging reason. 
  94. */ 
  95. function logIO( $io, $msg ) { 
  96. _deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); 
  97. if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) 
  98. error_log( $io . ' - ' . $msg ); 
.