author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 16 | a86126ab1dd4 |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 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 |
*/ |
|
9 | 13 |
define( 'XMLRPC_REQUEST', true ); |
0 | 14 |
|
15 |
// Some browser-embedded clients send cookies. We don't want them. |
|
16 |
$_COOKIE = array(); |
|
17 |
||
16 | 18 |
// $HTTP_RAW_POST_DATA was deprecated in PHP 5.6 and removed in PHP 7.0. |
19 |
// phpcs:disable PHPCompatibility.Variables.RemovedPredefinedGlobalVariables.http_raw_post_dataDeprecatedRemoved |
|
9 | 20 |
if ( ! isset( $HTTP_RAW_POST_DATA ) ) { |
0 | 21 |
$HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); |
22 |
} |
|
23 |
||
16 | 24 |
// Fix for mozBlog and other cases where '<?xml' isn't on the very first line. |
9 | 25 |
if ( isset( $HTTP_RAW_POST_DATA ) ) { |
26 |
$HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA ); |
|
27 |
} |
|
16 | 28 |
// phpcs:enable |
0 | 29 |
|
30 |
/** Include the bootstrap for setting up WordPress environment */ |
|
16 | 31 |
require_once __DIR__ . '/wp-load.php'; |
0 | 32 |
|
33 |
if ( isset( $_GET['rsd'] ) ) { // http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
9 | 34 |
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
35 |
echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>'; |
|
36 |
?> |
|
0 | 37 |
<rsd version="1.0" xmlns="http://archipelago.phrasewise.com/rsd"> |
9 | 38 |
<service> |
39 |
<engineName>WordPress</engineName> |
|
40 |
<engineLink>https://wordpress.org/</engineLink> |
|
41 |
<homePageLink><?php bloginfo_rss( 'url' ); ?></homePageLink> |
|
42 |
<apis> |
|
43 |
<api name="WordPress" blogID="1" preferred="true" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" /> |
|
44 |
<api name="Movable Type" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" /> |
|
45 |
<api name="MetaWeblog" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" /> |
|
46 |
<api name="Blogger" blogID="1" preferred="false" apiLink="<?php echo site_url( 'xmlrpc.php', 'rpc' ); ?>" /> |
|
47 |
<?php |
|
48 |
/** |
|
49 |
* Add additional APIs to the Really Simple Discovery (RSD) endpoint. |
|
50 |
* |
|
51 |
* @link http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html |
|
52 |
* |
|
53 |
* @since 3.5.0 |
|
54 |
*/ |
|
55 |
do_action( 'xmlrpc_rsd_apis' ); |
|
56 |
?> |
|
57 |
</apis> |
|
58 |
</service> |
|
0 | 59 |
</rsd> |
9 | 60 |
<?php |
61 |
exit; |
|
0 | 62 |
} |
63 |
||
16 | 64 |
require_once ABSPATH . 'wp-admin/includes/admin.php'; |
65 |
require_once ABSPATH . WPINC . '/class-IXR.php'; |
|
66 |
require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php'; |
|
0 | 67 |
|
68 |
/** |
|
69 |
* Posts submitted via the XML-RPC interface get that title |
|
9 | 70 |
* |
0 | 71 |
* @name post_default_title |
72 |
* @var string |
|
73 |
*/ |
|
9 | 74 |
$post_default_title = ''; |
0 | 75 |
|
76 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* Filters the class used for handling XML-RPC requests. |
0 | 78 |
* |
79 |
* @since 3.1.0 |
|
5 | 80 |
* |
81 |
* @param string $class The name of the XML-RPC server class. |
|
0 | 82 |
*/ |
83 |
$wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' ); |
|
9 | 84 |
$wp_xmlrpc_server = new $wp_xmlrpc_server_class; |
0 | 85 |
|
16 | 86 |
// Fire off the request. |
0 | 87 |
$wp_xmlrpc_server->serve_request(); |
88 |
||
89 |
exit; |
|
90 |
||
91 |
/** |
|
92 |
* logIO() - Writes logging info to a file. |
|
93 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @deprecated 3.4.0 Use error_log() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
* @see error_log() |
0 | 96 |
* |
97 |
* @param string $io Whether input or output |
|
98 |
* @param string $msg Information describing logging reason. |
|
99 |
*/ |
|
16 | 100 |
function logIO( $io, $msg ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
_deprecated_function( __FUNCTION__, '3.4.0', 'error_log()' ); |
9 | 102 |
if ( ! empty( $GLOBALS['xmlrpc_logging'] ) ) { |
0 | 103 |
error_log( $io . ' - ' . $msg ); |
9 | 104 |
} |
105 |
} |