wp/wp-includes/class-wp-xmlrpc-server.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 22 8c2e4d02f4ef
permissions -rw-r--r--
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
     3
 * XML-RPC protocol support for WordPress.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     6
 * @subpackage Publishing
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * WordPress XMLRPC server implementation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * Implements compatibility for Blogger API, MetaWeblog API, MovableType, and
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 * pingback. Additional WordPress API for managing comments, pages, posts,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * options, etc.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * As of WordPress 3.5.0, XML-RPC is enabled by default. It can be disabled
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    17
 * via the {@see 'xmlrpc_enabled'} filter found in wp_xmlrpc_server::set_is_enabled().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    20
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 * @see IXR_Server
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    23
#[AllowDynamicProperties]
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
class wp_xmlrpc_server extends IXR_Server {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    26
	 * Methods.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	 * @var array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
	public $methods;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    33
	 * Blog options.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    34
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
	 * @var array
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    37
	public $blog_options;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    38
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    40
	 * IXR_Error instance.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
	 * @var IXR_Error
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
	public $error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    45
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    47
	 * Flags that the user authentication has failed in this instance of wp_xmlrpc_server.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    48
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    49
	 * @var bool
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    50
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    51
	protected $auth_failed = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    52
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    53
	/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    54
	 * Flags that XML-RPC is enabled
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    55
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    56
	 * @var bool
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    57
	 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    58
	private $is_enabled;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    59
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    60
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    61
	 * Registers all of the XMLRPC methods that XMLRPC server understands.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    63
	 * Sets up server and method property. Passes XMLRPC methods through the
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    64
	 * {@see 'xmlrpc_methods'} filter to allow plugins to extend or replace
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    65
	 * XML-RPC methods.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
	public function __construct() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
		$this->methods = array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    71
			// WordPress API.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    72
			'wp.getUsersBlogs'                 => 'this:wp_getUsersBlogs',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    73
			'wp.newPost'                       => 'this:wp_newPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    74
			'wp.editPost'                      => 'this:wp_editPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    75
			'wp.deletePost'                    => 'this:wp_deletePost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    76
			'wp.getPost'                       => 'this:wp_getPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    77
			'wp.getPosts'                      => 'this:wp_getPosts',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    78
			'wp.newTerm'                       => 'this:wp_newTerm',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    79
			'wp.editTerm'                      => 'this:wp_editTerm',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    80
			'wp.deleteTerm'                    => 'this:wp_deleteTerm',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    81
			'wp.getTerm'                       => 'this:wp_getTerm',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    82
			'wp.getTerms'                      => 'this:wp_getTerms',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
			'wp.getTaxonomy'                   => 'this:wp_getTaxonomy',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
			'wp.getTaxonomies'                 => 'this:wp_getTaxonomies',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
			'wp.getUser'                       => 'this:wp_getUser',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
			'wp.getUsers'                      => 'this:wp_getUsers',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    87
			'wp.getProfile'                    => 'this:wp_getProfile',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    88
			'wp.editProfile'                   => 'this:wp_editProfile',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    89
			'wp.getPage'                       => 'this:wp_getPage',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    90
			'wp.getPages'                      => 'this:wp_getPages',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    91
			'wp.newPage'                       => 'this:wp_newPage',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
			'wp.deletePage'                    => 'this:wp_deletePage',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    93
			'wp.editPage'                      => 'this:wp_editPage',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
			'wp.getPageList'                   => 'this:wp_getPageList',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    95
			'wp.getAuthors'                    => 'this:wp_getAuthors',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    96
			'wp.getCategories'                 => 'this:mw_getCategories',     // Alias.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    97
			'wp.getTags'                       => 'this:wp_getTags',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    98
			'wp.newCategory'                   => 'this:wp_newCategory',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    99
			'wp.deleteCategory'                => 'this:wp_deleteCategory',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   100
			'wp.suggestCategories'             => 'this:wp_suggestCategories',
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   101
			'wp.uploadFile'                    => 'this:mw_newMediaObject',    // Alias.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   102
			'wp.deleteFile'                    => 'this:wp_deletePost',        // Alias.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   103
			'wp.getCommentCount'               => 'this:wp_getCommentCount',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   104
			'wp.getPostStatusList'             => 'this:wp_getPostStatusList',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   105
			'wp.getPageStatusList'             => 'this:wp_getPageStatusList',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   106
			'wp.getPageTemplates'              => 'this:wp_getPageTemplates',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   107
			'wp.getOptions'                    => 'this:wp_getOptions',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   108
			'wp.setOptions'                    => 'this:wp_setOptions',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   109
			'wp.getComment'                    => 'this:wp_getComment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   110
			'wp.getComments'                   => 'this:wp_getComments',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   111
			'wp.deleteComment'                 => 'this:wp_deleteComment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   112
			'wp.editComment'                   => 'this:wp_editComment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   113
			'wp.newComment'                    => 'this:wp_newComment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   114
			'wp.getCommentStatusList'          => 'this:wp_getCommentStatusList',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   115
			'wp.getMediaItem'                  => 'this:wp_getMediaItem',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
			'wp.getMediaLibrary'               => 'this:wp_getMediaLibrary',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   117
			'wp.getPostFormats'                => 'this:wp_getPostFormats',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
			'wp.getPostType'                   => 'this:wp_getPostType',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
			'wp.getPostTypes'                  => 'this:wp_getPostTypes',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   120
			'wp.getRevisions'                  => 'this:wp_getRevisions',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
			'wp.restoreRevision'               => 'this:wp_restoreRevision',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   123
			// Blogger API.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
			'blogger.getUsersBlogs'            => 'this:blogger_getUsersBlogs',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
			'blogger.getUserInfo'              => 'this:blogger_getUserInfo',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   126
			'blogger.getPost'                  => 'this:blogger_getPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
			'blogger.getRecentPosts'           => 'this:blogger_getRecentPosts',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
			'blogger.newPost'                  => 'this:blogger_newPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   129
			'blogger.editPost'                 => 'this:blogger_editPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   130
			'blogger.deletePost'               => 'this:blogger_deletePost',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   132
			// MetaWeblog API (with MT extensions to structs).
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   133
			'metaWeblog.newPost'               => 'this:mw_newPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   134
			'metaWeblog.editPost'              => 'this:mw_editPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   135
			'metaWeblog.getPost'               => 'this:mw_getPost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   136
			'metaWeblog.getRecentPosts'        => 'this:mw_getRecentPosts',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   137
			'metaWeblog.getCategories'         => 'this:mw_getCategories',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   138
			'metaWeblog.newMediaObject'        => 'this:mw_newMediaObject',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   140
			/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   141
			 * MetaWeblog API aliases for Blogger API.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   142
			 * See http://www.xmlrpc.com/stories/storyReader$2460
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   143
			 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   144
			'metaWeblog.deletePost'            => 'this:blogger_deletePost',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   145
			'metaWeblog.getUsersBlogs'         => 'this:blogger_getUsersBlogs',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   147
			// MovableType API.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   148
			'mt.getCategoryList'               => 'this:mt_getCategoryList',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   149
			'mt.getRecentPostTitles'           => 'this:mt_getRecentPostTitles',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   150
			'mt.getPostCategories'             => 'this:mt_getPostCategories',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   151
			'mt.setPostCategories'             => 'this:mt_setPostCategories',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   152
			'mt.supportedMethods'              => 'this:mt_supportedMethods',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   153
			'mt.supportedTextFilters'          => 'this:mt_supportedTextFilters',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   154
			'mt.getTrackbackPings'             => 'this:mt_getTrackbackPings',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   155
			'mt.publishPost'                   => 'this:mt_publishPost',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   157
			// Pingback.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
			'pingback.ping'                    => 'this:pingback_ping',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
			'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   161
			'demo.sayHello'                    => 'this:sayHello',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   162
			'demo.addTwoNumbers'               => 'this:addTwoNumbers',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		$this->initialise_blog_option_info();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   167
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   168
		 * Filters the methods exposed by the XML-RPC server.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
		 * This filter can be used to add new methods, and remove built-in methods.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   171
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
		 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   174
		 * @param string[] $methods An array of XML-RPC methods, keyed by their methodName.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
		$this->methods = apply_filters( 'xmlrpc_methods', $this->methods );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   177
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   178
		$this->set_is_enabled();
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   179
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   180
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   181
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   182
	 * Sets wp_xmlrpc_server::$is_enabled property.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   183
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   184
	 * Determines whether the xmlrpc server is enabled on this WordPress install
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   185
	 * and set the is_enabled property accordingly.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   186
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   187
	 * @since 5.7.3
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   188
	 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   189
	private function set_is_enabled() {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   190
		/*
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   191
		 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   192
		 * option was deprecated in 3.5.0. Use the {@see 'xmlrpc_enabled'} hook instead.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   193
		 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   194
		$is_enabled = apply_filters( 'pre_option_enable_xmlrpc', false );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   195
		if ( false === $is_enabled ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   196
			$is_enabled = apply_filters( 'option_enable_xmlrpc', true );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   197
		}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   198
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   199
		/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   200
		 * Filters whether XML-RPC methods requiring authentication are enabled.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   201
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   202
		 * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully*
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   203
		 * enabled, rather, it only controls whether XML-RPC methods requiring authentication -
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   204
		 * such as for publishing purposes - are enabled.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   205
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   206
		 * Further, the filter does not control whether pingbacks or other custom endpoints that don't
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   207
		 * require authentication are enabled. This behavior is expected, and due to how parity was matched
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   208
		 * with the `enable_xmlrpc` UI option the filter replaced when it was introduced in 3.5.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   209
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   210
		 * To disable XML-RPC methods that require authentication, use:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   211
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   212
		 *     add_filter( 'xmlrpc_enabled', '__return_false' );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   213
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   214
		 * For more granular control over all XML-RPC methods and requests, see the {@see 'xmlrpc_methods'}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   215
		 * and {@see 'xmlrpc_element_limit'} hooks.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   216
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   217
		 * @since 3.5.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   218
		 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   219
		 * @param bool $is_enabled Whether XML-RPC is enabled. Default true.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   220
		 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   221
		$this->is_enabled = apply_filters( 'xmlrpc_enabled', $is_enabled );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   225
	 * Makes private/protected methods readable for backward compatibility.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
	 * @since 4.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   229
	 * @param string $name      Method to call.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   230
	 * @param array  $arguments Arguments to pass when calling.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   231
	 * @return array|IXR_Error|false Return value of the callback, false otherwise.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   233
	public function __call( $name, $arguments ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
		if ( '_multisite_getUsersBlogs' === $name ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   235
			return $this->_multisite_getUsersBlogs( ...$arguments );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
		return false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   239
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   240
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   241
	 * Serves the XML-RPC request.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   242
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   243
	 * @since 2.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   244
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   245
	public function serve_request() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   246
		$this->IXR_Server( $this->methods );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   250
	 * Tests XMLRPC API by saying, "Hello!" to client.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   254
	 * @return string Hello string response.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   256
	public function sayHello() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
		return 'Hello!';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   261
	 * Tests XMLRPC API by adding two numbers for client.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   265
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   266
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   267
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   268
	 *     @type int $0 A number to add.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   269
	 *     @type int $1 A second number to add.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   270
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   271
	 * @return int Sum of the two given numbers.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   273
	public function addTwoNumbers( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		$number1 = $args[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
		$number2 = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		return $number1 + $number2;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   280
	 * Logs user in.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
	 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
	 * @param string $username User's username.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
	 * @param string $password User's password.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   286
	 * @return WP_User|false WP_User object if authentication passed, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   288
	public function login(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   289
		$username,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   290
		#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   291
		$password
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   292
	) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   293
		if ( ! $this->is_enabled ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
			$this->error = new IXR_Error( 405, sprintf( __( 'XML-RPC services are disabled on this site.' ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
		if ( $this->auth_failed ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   299
			$user = new WP_Error( 'login_prevented' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   300
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   301
			$user = wp_authenticate( $username, $password );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   302
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   303
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   304
		if ( is_wp_error( $user ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
			$this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   307
			// Flag that authentication has failed once on this wp_xmlrpc_server instance.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   308
			$this->auth_failed = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   311
			 * Filters the XML-RPC user login error message.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
			 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
			 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   315
			 * @param IXR_Error $error The XML-RPC error message.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   316
			 * @param WP_Error  $user  WP_Error object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
			$this->error = apply_filters( 'xmlrpc_login_error', $this->error, $user );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
		wp_set_current_user( $user->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
		return $user;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   327
	 * Checks user's credentials. Deprecated.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
	 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   330
	 * @deprecated 2.8.0 Use wp_xmlrpc_server::login()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   331
	 * @see wp_xmlrpc_server::login()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	 * @param string $username User's username.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
	 * @param string $password User's password.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
	 * @return bool Whether authentication passed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
	 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   337
	public function login_pass_ok(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   338
		$username,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   339
		#[\SensitiveParameter]
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   340
		$password
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   341
	) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
		return (bool) $this->login( $username, $password );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   346
	 * Escapes string or array of strings for database.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
	 * @since 1.5.2
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
	 * @param string|array $data Escape single string or array of strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   351
	 * @return string|void Returns with string is passed, alters by-reference
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   352
	 *                     when array is passed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
	public function escape( &$data ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   355
		if ( ! is_array( $data ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
			return wp_slash( $data );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		foreach ( $data as &$v ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   360
			if ( is_array( $v ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
				$this->escape( $v );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
			} elseif ( ! is_object( $v ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
				$v = wp_slash( $v );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   369
	 * Sends error response to client.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   370
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   371
	 * Sends an XML error response to the client. If the endpoint is enabled
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   372
	 * an HTTP 200 response is always sent per the XML-RPC specification.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   373
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   374
	 * @since 5.7.3
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   375
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   376
	 * @param IXR_Error|string $error   Error code or an error object.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   377
	 * @param false            $message Error message. Optional.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   378
	 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   379
	public function error( $error, $message = false ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   380
		// Accepts either an error object or an error code and message
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   381
		if ( $message && ! is_object( $error ) ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   382
			$error = new IXR_Error( $error, $message );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   383
		}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   384
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   385
		if ( ! $this->is_enabled ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   386
			status_header( $error->code );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   387
		}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   388
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   389
		$this->output( $error->getXml() );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   390
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   391
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   392
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   393
	 * Retrieves custom fields for post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
	 * @param int $post_id Post ID.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
	 * @return array Custom fields, if exist.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   400
	public function get_custom_fields( $post_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
		$post_id = (int) $post_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
		$custom_fields = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   405
		foreach ( (array) has_meta( $post_id ) as $meta ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
			// Don't expose protected fields.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   407
			if ( ! current_user_can( 'edit_post_meta', $post_id, $meta['meta_key'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   409
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
			$custom_fields[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   412
				'id'    => $meta['meta_id'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   413
				'key'   => $meta['meta_key'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   414
				'value' => $meta['meta_value'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
		return $custom_fields;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   422
	 * Sets custom fields for post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   426
	 * @param int   $post_id Post ID.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   427
	 * @param array $fields  Custom fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   429
	public function set_custom_fields( $post_id, $fields ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
		$post_id = (int) $post_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		foreach ( (array) $fields as $meta ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   433
			if ( isset( $meta['id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
				$meta['id'] = (int) $meta['id'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   435
				$pmeta      = get_metadata_by_mid( 'post', $meta['id'] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   436
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   437
				if ( ! $pmeta || (int) $pmeta->post_id !== $post_id ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   438
					continue;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   439
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   440
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   441
				if ( isset( $meta['key'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
					$meta['key'] = wp_unslash( $meta['key'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
					if ( $meta['key'] !== $pmeta->meta_key ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
						continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   445
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
					$meta['value'] = wp_unslash( $meta['value'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   447
					if ( current_user_can( 'edit_post_meta', $post_id, $meta['key'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
						update_metadata_by_mid( 'post', $meta['id'], $meta['value'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   449
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
				} elseif ( current_user_can( 'delete_post_meta', $post_id, $pmeta->meta_key ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
					delete_metadata_by_mid( 'post', $meta['id'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
			} elseif ( current_user_can( 'add_post_meta', $post_id, wp_unslash( $meta['key'] ) ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
				add_post_meta( $post_id, $meta['key'], $meta['value'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   460
	 * Retrieves custom fields for a term.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   461
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   462
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   463
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   464
	 * @param int $term_id Term ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   465
	 * @return array Array of custom fields, if they exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   466
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   467
	public function get_term_custom_fields( $term_id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   468
		$term_id = (int) $term_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   469
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   470
		$custom_fields = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   471
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   472
		foreach ( (array) has_term_meta( $term_id ) as $meta ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   473
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   474
			if ( ! current_user_can( 'edit_term_meta', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   475
				continue;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   476
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   477
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   478
			$custom_fields[] = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   479
				'id'    => $meta['meta_id'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
				'key'   => $meta['meta_key'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   481
				'value' => $meta['meta_value'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   482
			);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   483
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   484
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   485
		return $custom_fields;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   486
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   487
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   488
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   489
	 * Sets custom fields for a term.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   490
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   491
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   492
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   493
	 * @param int   $term_id Term ID.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   494
	 * @param array $fields  Custom fields.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   495
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   496
	public function set_term_custom_fields( $term_id, $fields ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   497
		$term_id = (int) $term_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   498
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   499
		foreach ( (array) $fields as $meta ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   500
			if ( isset( $meta['id'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   501
				$meta['id'] = (int) $meta['id'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   502
				$pmeta      = get_metadata_by_mid( 'term', $meta['id'] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   503
				if ( isset( $meta['key'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   504
					$meta['key'] = wp_unslash( $meta['key'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   505
					if ( $meta['key'] !== $pmeta->meta_key ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   506
						continue;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   507
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   508
					$meta['value'] = wp_unslash( $meta['value'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   509
					if ( current_user_can( 'edit_term_meta', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   510
						update_metadata_by_mid( 'term', $meta['id'], $meta['value'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   511
					}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   512
				} elseif ( current_user_can( 'delete_term_meta', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   513
					delete_metadata_by_mid( 'term', $meta['id'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   514
				}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
			} elseif ( current_user_can( 'add_term_meta', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
				add_term_meta( $term_id, $meta['key'], $meta['value'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   518
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   519
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   520
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   521
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   522
	 * Sets up blog options property.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   524
	 * Passes property through {@see 'xmlrpc_blog_options'} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   528
	public function initialise_blog_option_info() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
		$this->blog_options = array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   530
			// Read-only options.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   531
			'software_name'           => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   532
				'desc'     => __( 'Software Name' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   533
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   534
				'value'    => 'WordPress',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   536
			'software_version'        => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   537
				'desc'     => __( 'Software Version' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   538
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   539
				'value'    => get_bloginfo( 'version' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   541
			'blog_url'                => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   542
				'desc'     => __( 'WordPress Address (URL)' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   543
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   544
				'option'   => 'siteurl',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   546
			'home_url'                => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   547
				'desc'     => __( 'Site Address (URL)' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   548
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   549
				'option'   => 'home',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   551
			'login_url'               => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   552
				'desc'     => __( 'Login Address (URL)' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   553
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   554
				'value'    => wp_login_url(),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   556
			'admin_url'               => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   557
				'desc'     => __( 'The URL to the admin area' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   558
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   559
				'value'    => get_admin_url(),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
			),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
			'image_default_link_type' => array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   562
				'desc'     => __( 'Image default link type' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   563
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   564
				'option'   => 'image_default_link_type',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   566
			'image_default_size'      => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   567
				'desc'     => __( 'Image default size' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   568
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   569
				'option'   => 'image_default_size',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   571
			'image_default_align'     => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   572
				'desc'     => __( 'Image default align' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   573
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   574
				'option'   => 'image_default_align',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   576
			'template'                => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   577
				'desc'     => __( 'Template' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   578
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   579
				'option'   => 'template',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   581
			'stylesheet'              => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   582
				'desc'     => __( 'Stylesheet' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   583
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   584
				'option'   => 'stylesheet',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   586
			'post_thumbnail'          => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   587
				'desc'     => __( 'Post Thumbnail' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   588
				'readonly' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   589
				'value'    => current_theme_supports( 'post-thumbnails' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
			),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   592
			// Updatable options.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   593
			'time_zone'               => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   594
				'desc'     => __( 'Time Zone' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   595
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   596
				'option'   => 'gmt_offset',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   598
			'blog_title'              => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   599
				'desc'     => __( 'Site Title' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   600
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   601
				'option'   => 'blogname',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   602
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   603
			'blog_tagline'            => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   604
				'desc'     => __( 'Site Tagline' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   605
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   606
				'option'   => 'blogdescription',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   608
			'date_format'             => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   609
				'desc'     => __( 'Date Format' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   610
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   611
				'option'   => 'date_format',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   613
			'time_format'             => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   614
				'desc'     => __( 'Time Format' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   615
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   616
				'option'   => 'time_format',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   617
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   618
			'users_can_register'      => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   619
				'desc'     => __( 'Allow new users to sign up' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   620
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   621
				'option'   => 'users_can_register',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   623
			'thumbnail_size_w'        => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   624
				'desc'     => __( 'Thumbnail Width' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   625
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   626
				'option'   => 'thumbnail_size_w',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   628
			'thumbnail_size_h'        => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   629
				'desc'     => __( 'Thumbnail Height' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   630
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   631
				'option'   => 'thumbnail_size_h',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   632
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   633
			'thumbnail_crop'          => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   634
				'desc'     => __( 'Crop thumbnail to exact dimensions' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   635
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   636
				'option'   => 'thumbnail_crop',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   637
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   638
			'medium_size_w'           => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   639
				'desc'     => __( 'Medium size image width' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   640
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   641
				'option'   => 'medium_size_w',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   643
			'medium_size_h'           => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   644
				'desc'     => __( 'Medium size image height' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   645
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   646
				'option'   => 'medium_size_h',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   647
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   648
			'medium_large_size_w'     => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   649
				'desc'     => __( 'Medium-Large size image width' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   650
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   651
				'option'   => 'medium_large_size_w',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   652
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   653
			'medium_large_size_h'     => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   654
				'desc'     => __( 'Medium-Large size image height' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   655
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   656
				'option'   => 'medium_large_size_h',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   657
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   658
			'large_size_w'            => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   659
				'desc'     => __( 'Large size image width' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   660
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   661
				'option'   => 'large_size_w',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   663
			'large_size_h'            => array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   664
				'desc'     => __( 'Large size image height' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   665
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   666
				'option'   => 'large_size_h',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   668
			'default_comment_status'  => array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   669
				'desc'     => __( 'Allow people to submit comments on new posts.' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   670
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   671
				'option'   => 'default_comment_status',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
			),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   673
			'default_ping_status'     => array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   674
				'desc'     => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new posts.' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   675
				'readonly' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   676
				'option'   => 'default_ping_status',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   677
			),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   681
		 * Filters the XML-RPC blog options property.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   682
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   683
		 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   684
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   685
		 * @param array $blog_options An array of XML-RPC blog options.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   686
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
		$this->blog_options = apply_filters( 'xmlrpc_blog_options', $this->blog_options );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   691
	 * Retrieves the blogs of the user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   695
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   696
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   697
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   698
	 *     @type string $0 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   699
	 *     @type string $1 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   700
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   701
	 * @return array|IXR_Error Array contains:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
	 *  - 'isAdmin'
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   703
	 *  - 'isPrimary' - whether the blog is the user's primary blog
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
	 *  - 'url'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
	 *  - 'blogid'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
	 *  - 'blogName'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
	 *  - 'xmlrpc' - url of xmlrpc endpoint
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   709
	public function wp_getUsersBlogs( $args ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   710
		if ( ! $this->minimum_args( $args, 2 ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   711
			return $this->error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   712
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   713
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   714
		// If this isn't on WPMU then just use blogger_getUsersBlogs().
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   715
		if ( ! is_multisite() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
			array_unshift( $args, 1 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
			return $this->blogger_getUsersBlogs( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
		$username = $args[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
		$password = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   724
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   725
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   726
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   728
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
		 * Fires after the XML-RPC user has been authenticated but before the rest of
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
		 * the method logic begins.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
		 * All built-in XML-RPC methods use the action xmlrpc_call, with a parameter
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
		 * equal to the method's name, e.g., wp.getUsersBlogs, wp.newPost, etc.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
		 * @since 2.5.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   738
		 * @since 5.7.0 Added the `$args` and `$server` parameters.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
		 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   740
		 * @param string           $name   The method name.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   741
		 * @param array|string     $args   The escaped arguments passed to the method.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   742
		 * @param wp_xmlrpc_server $server The XML-RPC server instance.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
		 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   744
		do_action( 'xmlrpc_call', 'wp.getUsersBlogs', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   746
		$blogs  = (array) get_blogs_of_user( $user->ID );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   747
		$struct = array();
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   748
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   749
		$primary_blog_id = 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   750
		$active_blog     = get_active_blog_for_user( $user->ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   751
		if ( $active_blog ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   752
			$primary_blog_id = (int) $active_blog->blog_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   753
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   755
		$current_network_id = get_current_network_id();
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   756
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   757
		foreach ( $blogs as $blog ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   758
			// Don't include blogs that aren't hosted at this site.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   759
			if ( $blog->site_id !== $current_network_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   761
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
			$blog_id = $blog->userblog_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
			switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   767
			$is_admin   = current_user_can( 'manage_options' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   768
			$is_primary = ( (int) $blog_id === $primary_blog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
			$struct[] = array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   771
				'isAdmin'   => $is_admin,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   772
				'isPrimary' => $is_primary,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   773
				'url'       => home_url( '/' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   774
				'blogid'    => (string) $blog_id,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   775
				'blogName'  => get_option( 'blogname' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   776
				'xmlrpc'    => site_url( 'xmlrpc.php', 'rpc' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
			restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   782
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
	 * Checks if the method received at least the minimum number of arguments.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   790
	 * @param array $args  An array of arguments to check.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   791
	 * @param int   $count Minimum number of arguments.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   792
	 * @return bool True if `$args` contains at least `$count` arguments, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
	protected function minimum_args( $args, $count ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   795
		if ( ! is_array( $args ) || count( $args ) < $count ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
			$this->error = new IXR_Error( 400, __( 'Insufficient arguments passed to this XML-RPC method.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
	 * Prepares taxonomy data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   806
	 * @param WP_Taxonomy $taxonomy The unprepared taxonomy data.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   807
	 * @param array       $fields   The subset of taxonomy fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   808
	 * @return array The prepared taxonomy data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   809
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   810
	protected function _prepare_taxonomy( $taxonomy, $fields ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
		$_taxonomy = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   812
			'name'         => $taxonomy->name,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   813
			'label'        => $taxonomy->label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
			'hierarchical' => (bool) $taxonomy->hierarchical,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   815
			'public'       => (bool) $taxonomy->public,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   816
			'show_ui'      => (bool) $taxonomy->show_ui,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   817
			'_builtin'     => (bool) $taxonomy->_builtin,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   820
		if ( in_array( 'labels', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
			$_taxonomy['labels'] = (array) $taxonomy->labels;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   822
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   823
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   824
		if ( in_array( 'cap', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
			$_taxonomy['cap'] = (array) $taxonomy->cap;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   826
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   827
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   828
		if ( in_array( 'menu', $fields, true ) ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   829
			$_taxonomy['show_in_menu'] = (bool) $taxonomy->show_in_menu;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   830
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   831
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   832
		if ( in_array( 'object_type', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
			$_taxonomy['object_type'] = array_unique( (array) $taxonomy->object_type );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   834
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   836
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   837
		 * Filters XML-RPC-prepared data for the given taxonomy.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   839
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   840
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   841
		 * @param array       $_taxonomy An array of taxonomy data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   842
		 * @param WP_Taxonomy $taxonomy  Taxonomy object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   843
		 * @param array       $fields    The subset of taxonomy fields to return.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   844
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   845
		return apply_filters( 'xmlrpc_prepare_taxonomy', $_taxonomy, $taxonomy, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   848
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
	 * Prepares term data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   850
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   851
	 * @param array|object $term The unprepared term data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   852
	 * @return array The prepared term data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
	protected function _prepare_term( $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
		$_term = $term;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   856
		if ( ! is_array( $_term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
			$_term = get_object_vars( $_term );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   858
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
		// For integers which may be larger than XML-RPC supports ensure we return strings.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   861
		$_term['term_id']          = (string) $_term['term_id'];
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   862
		$_term['term_group']       = (string) $_term['term_group'];
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   863
		$_term['term_taxonomy_id'] = (string) $_term['term_taxonomy_id'];
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   864
		$_term['parent']           = (string) $_term['parent'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
		// Count we are happy to return as an integer because people really shouldn't use terms that much.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   867
		$_term['count'] = (int) $_term['count'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   869
		// Get term meta.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   870
		$_term['custom_fields'] = $this->get_term_custom_fields( $_term['term_id'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   871
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   872
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   873
		 * Filters XML-RPC-prepared data for the given term.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   874
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   877
		 * @param array        $_term An array of term data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   878
		 * @param array|object $term  Term object or array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   879
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
		return apply_filters( 'xmlrpc_prepare_term', $_term, $term );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   884
	 * Converts a WordPress date string to an IXR_Date object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   886
	 * @param string $date Date string to convert.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   887
	 * @return IXR_Date IXR_Date object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
	protected function _convert_date( $date ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   890
		if ( '0000-00-00 00:00:00' === $date ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
			return new IXR_Date( '00000000T00:00:00Z' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   892
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
		return new IXR_Date( mysql2date( 'Ymd\TH:i:s', $date, false ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   896
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   897
	 * Converts a WordPress GMT date string to an IXR_Date object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   899
	 * @param string $date_gmt WordPress GMT date string.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   900
	 * @param string $date     Date string.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   901
	 * @return IXR_Date IXR_Date object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
	protected function _convert_date_gmt( $date_gmt, $date ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   904
		if ( '0000-00-00 00:00:00' !== $date && '0000-00-00 00:00:00' === $date_gmt ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
			return new IXR_Date( get_gmt_from_date( mysql2date( 'Y-m-d H:i:s', $date, false ), 'Ymd\TH:i:s' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
		return $this->_convert_date( $date_gmt );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
	 * Prepares post data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   913
	 * @param array $post   The unprepared post data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   914
	 * @param array $fields The subset of post type fields to return.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   915
	 * @return array The prepared post data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
	protected function _prepare_post( $post, $fields ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   918
		// Holds the data for this post. built up based on $fields.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   919
		$_post = array( 'post_id' => (string) $post['ID'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   921
		// Prepare common post fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
		$post_fields = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
			'post_title'        => $post['post_title'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
			'post_date'         => $this->_convert_date( $post['post_date'] ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
			'post_date_gmt'     => $this->_convert_date_gmt( $post['post_date_gmt'], $post['post_date'] ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
			'post_modified'     => $this->_convert_date( $post['post_modified'] ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   927
			'post_modified_gmt' => $this->_convert_date_gmt( $post['post_modified_gmt'], $post['post_modified'] ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
			'post_status'       => $post['post_status'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   929
			'post_type'         => $post['post_type'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   930
			'post_name'         => $post['post_name'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
			'post_author'       => $post['post_author'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
			'post_password'     => $post['post_password'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
			'post_excerpt'      => $post['post_excerpt'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
			'post_content'      => $post['post_content'],
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   935
			'post_parent'       => (string) $post['post_parent'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
			'post_mime_type'    => $post['post_mime_type'],
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   937
			'link'              => get_permalink( $post['ID'] ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
			'guid'              => $post['guid'],
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   939
			'menu_order'        => (int) $post['menu_order'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
			'comment_status'    => $post['comment_status'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
			'ping_status'       => $post['ping_status'],
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   942
			'sticky'            => ( 'post' === $post['post_type'] && is_sticky( $post['ID'] ) ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   944
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   945
		// Thumbnail.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   946
		$post_fields['post_thumbnail'] = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   947
		$thumbnail_id                  = get_post_thumbnail_id( $post['ID'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
		if ( $thumbnail_id ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   949
			$thumbnail_size                = current_theme_supports( 'post-thumbnail' ) ? 'post-thumbnail' : 'thumbnail';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
			$post_fields['post_thumbnail'] = $this->_prepare_media_item( get_post( $thumbnail_id ), $thumbnail_size );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   953
		// Consider future posts as published.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   954
		if ( 'future' === $post_fields['post_status'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
			$post_fields['post_status'] = 'publish';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   956
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   958
		// Fill in blank post format.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
		$post_fields['post_format'] = get_post_format( $post['ID'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   960
		if ( empty( $post_fields['post_format'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
			$post_fields['post_format'] = 'standard';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   962
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   964
		// Merge requested $post_fields fields into $_post.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   965
		if ( in_array( 'post', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
			$_post = array_merge( $_post, $post_fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
			$requested_fields = array_intersect_key( $post_fields, array_flip( $fields ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   969
			$_post            = array_merge( $_post, $requested_fields );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   972
		$all_taxonomy_fields = in_array( 'taxonomies', $fields, true );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   973
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   974
		if ( $all_taxonomy_fields || in_array( 'terms', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
			$post_type_taxonomies = get_object_taxonomies( $post['post_type'], 'names' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   976
			$terms                = wp_get_object_terms( $post['ID'], $post_type_taxonomies );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   977
			$_post['terms']       = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
			foreach ( $terms as $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
				$_post['terms'][] = $this->_prepare_term( $term );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   983
		if ( in_array( 'custom_fields', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
			$_post['custom_fields'] = $this->get_custom_fields( $post['ID'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   985
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   986
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   987
		if ( in_array( 'enclosure', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
			$_post['enclosure'] = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   989
			$enclosures         = (array) get_post_meta( $post['ID'], 'enclosure' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   990
			if ( ! empty( $enclosures ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   991
				$encdata                      = explode( "\n", $enclosures[0] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   992
				$_post['enclosure']['url']    = trim( htmlspecialchars( $encdata[0] ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
				$_post['enclosure']['length'] = (int) trim( $encdata[1] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   994
				$_post['enclosure']['type']   = trim( $encdata[2] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   997
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   998
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   999
		 * Filters XML-RPC-prepared date for the given post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1000
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1001
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
		 * @param array $_post  An array of modified post data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
		 * @param array $post   An array of post data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
		 * @param array $fields An array of post fields.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
		return apply_filters( 'xmlrpc_prepare_post', $_post, $post, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1011
	 * Prepares post data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1013
	 * @since 3.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1014
	 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1015
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1016
	 * @param WP_Post_Type $post_type Post type object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1017
	 * @param array        $fields    The subset of post fields to return.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1018
	 * @return array The prepared post type data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
	protected function _prepare_post_type( $post_type, $fields ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1021
		$_post_type = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1022
			'name'         => $post_type->name,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1023
			'label'        => $post_type->label,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
			'hierarchical' => (bool) $post_type->hierarchical,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1025
			'public'       => (bool) $post_type->public,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1026
			'show_ui'      => (bool) $post_type->show_ui,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1027
			'_builtin'     => (bool) $post_type->_builtin,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1028
			'has_archive'  => (bool) $post_type->has_archive,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1029
			'supports'     => get_all_post_type_supports( $post_type->name ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1031
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1032
		if ( in_array( 'labels', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
			$_post_type['labels'] = (array) $post_type->labels;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1035
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1036
		if ( in_array( 'cap', $fields, true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1037
			$_post_type['cap']          = (array) $post_type->cap;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1038
			$_post_type['map_meta_cap'] = (bool) $post_type->map_meta_cap;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1039
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1040
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1041
		if ( in_array( 'menu', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
			$_post_type['menu_position'] = (int) $post_type->menu_position;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1043
			$_post_type['menu_icon']     = $post_type->menu_icon;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1044
			$_post_type['show_in_menu']  = (bool) $post_type->show_in_menu;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1045
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1046
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1047
		if ( in_array( 'taxonomies', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
			$_post_type['taxonomies'] = get_object_taxonomies( $post_type->name, 'names' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1049
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1051
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1052
		 * Filters XML-RPC-prepared date for the given post type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1053
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1054
		 * @since 3.4.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1055
		 * @since 4.6.0 Converted the `$post_type` parameter to accept a WP_Post_Type object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1056
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1057
		 * @param array        $_post_type An array of post type data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1058
		 * @param WP_Post_Type $post_type  Post type object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1059
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
		return apply_filters( 'xmlrpc_prepare_post_type', $_post_type, $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
	 * Prepares media item data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1066
	 * @param WP_Post $media_item     The unprepared media item data.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1067
	 * @param string  $thumbnail_size The image size to use for the thumbnail URL.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1068
	 * @return array The prepared media item data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
	protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
		$_media_item = array(
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1072
			'attachment_id'    => (string) $media_item->ID,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
			'date_created_gmt' => $this->_convert_date_gmt( $media_item->post_date_gmt, $media_item->post_date ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1074
			'parent'           => $media_item->post_parent,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1075
			'link'             => wp_get_attachment_url( $media_item->ID ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1076
			'title'            => $media_item->post_title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1077
			'caption'          => $media_item->post_excerpt,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
			'description'      => $media_item->post_content,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
			'metadata'         => wp_get_attachment_metadata( $media_item->ID ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1080
			'type'             => $media_item->post_mime_type,
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1081
			'alt'              => get_post_meta( $media_item->ID, '_wp_attachment_image_alt', true ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1082
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1083
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1084
		$thumbnail_src = image_downsize( $media_item->ID, $thumbnail_size );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1085
		if ( $thumbnail_src ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1086
			$_media_item['thumbnail'] = $thumbnail_src[0];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1087
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1088
			$_media_item['thumbnail'] = $_media_item['link'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1089
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1090
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1091
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1092
		 * Filters XML-RPC-prepared data for the given media item.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1093
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1094
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1095
		 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1096
		 * @param array   $_media_item    An array of media item data.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1097
		 * @param WP_Post $media_item     Media item object.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1098
		 * @param string  $thumbnail_size Image size.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
		return apply_filters( 'xmlrpc_prepare_media_item', $_media_item, $media_item, $thumbnail_size );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1103
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
	 * Prepares page data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1106
	 * @param WP_Post $page The unprepared page data.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1107
	 * @return array The prepared page data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1109
	protected function _prepare_page( $page ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
		// Get all of the page content and link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1111
		$full_page = get_extended( $page->post_content );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1112
		$link      = get_permalink( $page->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1114
		// Get info the page parent if there is one.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1115
		$parent_title = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
		if ( ! empty( $page->post_parent ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1117
			$parent       = get_post( $page->post_parent );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
			$parent_title = $parent->post_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1119
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
		// Determine comment and ping settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
		$allow_comments = comments_open( $page->ID ) ? 1 : 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1123
		$allow_pings    = pings_open( $page->ID ) ? 1 : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
		// Format page date.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1126
		$page_date     = $this->_convert_date( $page->post_date );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
		$page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1129
		// Pull the categories info together.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
		$categories = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
		if ( is_object_in_taxonomy( 'page', 'category' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
			foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1133
				$categories[] = get_cat_name( $cat_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1134
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1136
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1137
		// Get the author info.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
		$author = get_userdata( $page->post_author );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1139
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1140
		$page_template = get_page_template_slug( $page->ID );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1141
		if ( empty( $page_template ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1142
			$page_template = 'default';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1143
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1145
		$_page = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
			'dateCreated'            => $page_date,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
			'userid'                 => $page->post_author,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1148
			'page_id'                => $page->ID,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
			'page_status'            => $page->post_status,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1150
			'description'            => $full_page['main'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
			'title'                  => $page->post_title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1152
			'link'                   => $link,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1153
			'permaLink'              => $link,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1154
			'categories'             => $categories,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
			'excerpt'                => $page->post_excerpt,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
			'text_more'              => $full_page['extended'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1157
			'mt_allow_comments'      => $allow_comments,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1158
			'mt_allow_pings'         => $allow_pings,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1159
			'wp_slug'                => $page->post_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1160
			'wp_password'            => $page->post_password,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
			'wp_author'              => $author->display_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
			'wp_page_parent_id'      => $page->post_parent,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
			'wp_page_parent_title'   => $parent_title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
			'wp_page_order'          => $page->menu_order,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1165
			'wp_author_id'           => (string) $author->ID,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
			'wp_author_display_name' => $author->display_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
			'date_created_gmt'       => $page_date_gmt,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
			'custom_fields'          => $this->get_custom_fields( $page->ID ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1169
			'wp_page_template'       => $page_template,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1173
		 * Filters XML-RPC-prepared data for the given page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1174
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1175
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1176
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
		 * @param array   $_page An array of page data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1178
		 * @param WP_Post $page  Page object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1180
		return apply_filters( 'xmlrpc_prepare_page', $_page, $page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1181
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1183
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1184
	 * Prepares comment data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1186
	 * @param WP_Comment $comment The unprepared comment data.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1187
	 * @return array The prepared comment data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1188
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
	protected function _prepare_comment( $comment ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1190
		// Format page date.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1191
		$comment_date_gmt = $this->_convert_date_gmt( $comment->comment_date_gmt, $comment->comment_date );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1192
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1193
		if ( '0' === $comment->comment_approved ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
			$comment_status = 'hold';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1195
		} elseif ( 'spam' === $comment->comment_approved ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
			$comment_status = 'spam';
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1197
		} elseif ( '1' === $comment->comment_approved ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
			$comment_status = 'approve';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1199
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1200
			$comment_status = $comment->comment_approved;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1202
		$_comment = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
			'date_created_gmt' => $comment_date_gmt,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
			'user_id'          => $comment->user_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1205
			'comment_id'       => $comment->comment_ID,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1206
			'parent'           => $comment->comment_parent,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1207
			'status'           => $comment_status,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1208
			'content'          => $comment->comment_content,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1209
			'link'             => get_comment_link( $comment ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1210
			'post_id'          => $comment->comment_post_ID,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1211
			'post_title'       => get_the_title( $comment->comment_post_ID ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
			'author'           => $comment->comment_author,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
			'author_url'       => $comment->comment_author_url,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
			'author_email'     => $comment->comment_author_email,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
			'author_ip'        => $comment->comment_author_IP,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
			'type'             => $comment->comment_type,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1217
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1219
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1220
		 * Filters XML-RPC-prepared data for the given comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1221
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1222
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1223
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1224
		 * @param array      $_comment An array of prepared comment data.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1225
		 * @param WP_Comment $comment  Comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
		return apply_filters( 'xmlrpc_prepare_comment', $_comment, $comment );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1228
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1230
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1231
	 * Prepares user data for return in an XML-RPC object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1232
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1233
	 * @param WP_User $user   The unprepared user object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1234
	 * @param array   $fields The subset of user fields to return.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1235
	 * @return array The prepared user data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
	protected function _prepare_user( $user, $fields ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1238
		$_user = array( 'user_id' => (string) $user->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1239
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
		$user_fields = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1241
			'username'     => $user->user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1242
			'first_name'   => $user->user_firstname,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1243
			'last_name'    => $user->user_lastname,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1244
			'registered'   => $this->_convert_date( $user->user_registered ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1245
			'bio'          => $user->user_description,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1246
			'email'        => $user->user_email,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1247
			'nickname'     => $user->nickname,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1248
			'nicename'     => $user->user_nicename,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1249
			'url'          => $user->user_url,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1250
			'display_name' => $user->display_name,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1251
			'roles'        => $user->roles,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1252
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1253
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1254
		if ( in_array( 'all', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
			$_user = array_merge( $_user, $user_fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
		} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1257
			if ( in_array( 'basic', $fields, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
				$basic_fields = array( 'username', 'email', 'registered', 'display_name', 'nicename' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1259
				$fields       = array_merge( $fields, $basic_fields );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
			$requested_fields = array_intersect_key( $user_fields, array_flip( $fields ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1262
			$_user            = array_merge( $_user, $requested_fields );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1263
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1265
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1266
		 * Filters XML-RPC-prepared data for the given user.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1267
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1268
		 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1269
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1270
		 * @param array   $_user  An array of user data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1271
		 * @param WP_User $user   User object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1272
		 * @param array   $fields An array of user fields.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1273
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1274
		return apply_filters( 'xmlrpc_prepare_user', $_user, $user, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1275
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1276
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1278
	 * Creates a new post for any registered post type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1280
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1281
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1282
	 * @link https://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1283
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1284
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1285
	 *     Method arguments. Note: top-level arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1287
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1288
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1289
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1290
	 *     @type array  $3 {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1291
	 *         Content struct for adding a new post. See wp_insert_post() for information on
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1292
	 *         additional post fields
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1293
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1294
	 *         @type string $post_type      Post type. Default 'post'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1295
	 *         @type string $post_status    Post status. Default 'draft'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1296
	 *         @type string $post_title     Post title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1297
	 *         @type int    $post_author    Post author ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1298
	 *         @type string $post_excerpt   Post excerpt.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1299
	 *         @type string $post_content   Post content.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1300
	 *         @type string $post_date_gmt  Post date in GMT.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1301
	 *         @type string $post_date      Post date.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1302
	 *         @type string $post_password  Post password (20-character limit).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1303
	 *         @type string $comment_status Post comment enabled status. Accepts 'open' or 'closed'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1304
	 *         @type string $ping_status    Post ping status. Accepts 'open' or 'closed'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1305
	 *         @type bool   $sticky         Whether the post should be sticky. Automatically false if
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1306
	 *                                      `$post_status` is 'private'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1307
	 *         @type int    $post_thumbnail ID of an image to use as the post thumbnail/featured image.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1308
	 *         @type array  $custom_fields  Array of meta key/value pairs to add to the post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1309
	 *         @type array  $terms          Associative array with taxonomy names as keys and arrays
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1310
	 *                                      of term IDs as values.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1311
	 *         @type array  $terms_names    Associative array with taxonomy names as keys and arrays
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1312
	 *                                      of term names as values.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1313
	 *         @type array  $enclosure      {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1314
	 *             Array of feed enclosure data to add to post meta.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1315
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1316
	 *             @type string $url    URL for the feed enclosure.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1317
	 *             @type int    $length Size in bytes of the enclosure.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1318
	 *             @type string $type   Mime-type for the enclosure.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1319
	 *         }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1320
	 *     }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1321
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1322
	 * @return int|IXR_Error Post ID on success, IXR_Error instance otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1323
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1324
	public function wp_newPost( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1325
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1327
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
		$username       = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1332
		$password       = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
		$content_struct = $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1335
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1336
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1338
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1340
		// Convert the date field back to IXR form.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1341
		if ( isset( $content_struct['post_date'] ) && ! ( $content_struct['post_date'] instanceof IXR_Date ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1342
			$content_struct['post_date'] = $this->_convert_date( $content_struct['post_date'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1343
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1344
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1345
		/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1346
		 * Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1347
		 * since _insert_post() will ignore the non-GMT date if the GMT date is set.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1348
		 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1349
		if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1350
			if ( '0000-00-00 00:00:00' === $content_struct['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1351
				unset( $content_struct['post_date_gmt'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1352
			} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1353
				$content_struct['post_date_gmt'] = $this->_convert_date( $content_struct['post_date_gmt'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1354
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1355
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1356
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1357
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1358
		do_action( 'xmlrpc_call', 'wp.newPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
		unset( $content_struct['ID'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
		return $this->_insert_post( $user, $content_struct );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
	 * Helper method for filtering out elements from an array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
	 * @param int $count Number to compare to one.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1371
	 * @return bool True if the number is greater than one, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
	private function _is_greater_than_one( $count ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
		return $count > 1;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1378
	 * Encapsulates the logic for sticking a post and determining if
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1379
	 * the user has permission to do so.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1380
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1381
	 * @since 4.3.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1382
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1383
	 * @param array $post_data
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1384
	 * @param bool  $update
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1385
	 * @return void|IXR_Error
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1386
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1387
	private function _toggle_sticky( $post_data, $update = false ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1388
		$post_type = get_post_type_object( $post_data['post_type'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1389
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1390
		// Private and password-protected posts cannot be stickied.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1391
		if ( 'private' === $post_data['post_status'] || ! empty( $post_data['post_password'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1392
			// Error if the client tried to stick the post, otherwise, silently unstick.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1393
			if ( ! empty( $post_data['sticky'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1394
				return new IXR_Error( 401, __( 'Sorry, you cannot stick a private post.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1395
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1396
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1397
			if ( $update ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1398
				unstick_post( $post_data['ID'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
			}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1400
		} elseif ( isset( $post_data['sticky'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1401
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1402
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to make posts sticky.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1403
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1404
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
			$sticky = wp_validate_boolean( $post_data['sticky'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
			if ( $sticky ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
				stick_post( $post_data['ID'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1408
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1409
				unstick_post( $post_data['ID'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1410
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1411
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1412
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1414
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1415
	 * Helper method for wp_newPost() and wp_editPost(), containing shared logic.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1417
	 * @since 3.4.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1418
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1419
	 * @see wp_insert_post()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1420
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1421
	 * @param WP_User         $user           The post author if post_author isn't set in $content_struct.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1422
	 * @param array|IXR_Error $content_struct Post data to insert.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1423
	 * @return IXR_Error|string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1425
	protected function _insert_post( $user, $content_struct ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1426
		$defaults = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1427
			'post_status'    => 'draft',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1428
			'post_type'      => 'post',
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1429
			'post_author'    => 0,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1430
			'post_password'  => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1431
			'post_excerpt'   => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1432
			'post_content'   => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1433
			'post_title'     => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1434
			'post_date'      => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1435
			'post_date_gmt'  => '',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1436
			'post_format'    => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1437
			'post_name'      => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1438
			'post_thumbnail' => null,
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1439
			'post_parent'    => 0,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1440
			'ping_status'    => '',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1441
			'comment_status' => '',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1442
			'custom_fields'  => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1443
			'terms_names'    => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1444
			'terms'          => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1445
			'sticky'         => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1446
			'enclosure'      => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1447
			'ID'             => null,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1448
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1449
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1450
		$post_data = wp_parse_args( array_intersect_key( $content_struct, $defaults ), $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1451
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
		$post_type = get_post_type_object( $post_data['post_type'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1453
		if ( ! $post_type ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1454
			return new IXR_Error( 403, __( 'Invalid post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1455
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
		$update = ! empty( $post_data['ID'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
		if ( $update ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1460
			if ( ! get_post( $post_data['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
				return new IXR_Error( 401, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1462
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1463
			if ( ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1465
			}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1466
			if ( get_post_type( $post_data['ID'] ) !== $post_data['post_type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
				return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1468
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1469
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1470
			if ( ! current_user_can( $post_type->cap->create_posts ) || ! current_user_can( $post_type->cap->edit_posts ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1472
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1474
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
		switch ( $post_data['post_status'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1476
			case 'draft':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
			case 'pending':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
			case 'private':
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1480
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1481
					return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1482
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
			case 'publish':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
			case 'future':
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1486
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1487
					return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1488
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
			default:
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1491
				if ( ! get_post_status_object( $post_data['post_status'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
					$post_data['post_status'] = 'draft';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1493
				}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1494
				break;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1495
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1496
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1497
		if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1498
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1499
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
		$post_data['post_author'] = absint( $post_data['post_author'] );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1502
		if ( ! empty( $post_data['post_author'] ) && $post_data['post_author'] !== $user->ID ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1503
			if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1504
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1505
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1506
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1507
			$author = get_userdata( $post_data['post_author'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1508
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1509
			if ( ! $author ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1510
				return new IXR_Error( 404, __( 'Invalid author ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1511
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1512
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
			$post_data['post_author'] = $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1515
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1516
		if ( 'open' !== $post_data['comment_status'] && 'closed' !== $post_data['comment_status'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1517
			unset( $post_data['comment_status'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1518
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1519
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1520
		if ( 'open' !== $post_data['ping_status'] && 'closed' !== $post_data['ping_status'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1521
			unset( $post_data['ping_status'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1522
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1523
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1524
		// Do some timestamp voodoo.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1525
		if ( ! empty( $post_data['post_date_gmt'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1526
			// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1527
			$date_created = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1528
		} elseif ( ! empty( $post_data['post_date'] ) ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1529
			$date_created = $post_data['post_date']->getIso();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1530
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1531
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1532
		// Default to not flagging the post date to be edited unless it's intentional.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1533
		$post_data['edit_date'] = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1534
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1535
		if ( ! empty( $date_created ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1536
			$post_data['post_date']     = iso8601_to_datetime( $date_created );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1537
			$post_data['post_date_gmt'] = iso8601_to_datetime( $date_created, 'gmt' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1538
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1539
			// Flag the post date to be edited.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1540
			$post_data['edit_date'] = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1541
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1542
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1543
		if ( ! isset( $post_data['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
			$post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1545
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1546
		$post_id = $post_data['ID'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1548
		if ( 'post' === $post_data['post_type'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1549
			$error = $this->_toggle_sticky( $post_data, $update );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1550
			if ( $error ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1551
				return $error;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1555
		if ( isset( $post_data['post_thumbnail'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1556
			// Empty value deletes, non-empty value adds/updates.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1557
			if ( ! $post_data['post_thumbnail'] ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1558
				delete_post_thumbnail( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1559
			} elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1560
				return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1561
			}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1562
			set_post_thumbnail( $post_id, $post_data['post_thumbnail'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1563
			unset( $content_struct['post_thumbnail'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1564
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1566
		if ( isset( $post_data['custom_fields'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1567
			$this->set_custom_fields( $post_id, $post_data['custom_fields'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1568
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1569
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1570
		if ( isset( $post_data['terms'] ) || isset( $post_data['terms_names'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
			$post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1573
			// Accumulate term IDs from terms and terms_names.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1574
			$terms = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1576
			// First validate the terms specified by ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
			if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1578
				$taxonomies = array_keys( $post_data['terms'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1580
				// Validating term IDs.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
				foreach ( $taxonomies as $taxonomy ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1582
					if ( ! array_key_exists( $taxonomy, $post_type_taxonomies ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1583
						return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1584
					}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1585
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1586
					if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->assign_terms ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1587
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1588
					}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1589
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1590
					$term_ids           = $post_data['terms'][ $taxonomy ];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1591
					$terms[ $taxonomy ] = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
					foreach ( $term_ids as $term_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
						$term = get_term_by( 'id', $term_id, $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1595
						if ( ! $term ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1596
							return new IXR_Error( 403, __( 'Invalid term ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1597
						}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1598
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1599
						$terms[ $taxonomy ][] = (int) $term_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1600
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1604
			// Now validate terms specified by name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
			if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
				$taxonomies = array_keys( $post_data['terms_names'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1608
				foreach ( $taxonomies as $taxonomy ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1609
					if ( ! array_key_exists( $taxonomy, $post_type_taxonomies ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
						return new IXR_Error( 401, __( 'Sorry, one of the given taxonomies is not supported by the post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1611
					}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1612
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1613
					if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->assign_terms ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1615
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1616
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1617
					/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1618
					 * For hierarchical taxonomies, we can't assign a term when multiple terms
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1619
					 * in the hierarchy share the same name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1620
					 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
					$ambiguous_terms = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1622
					if ( is_taxonomy_hierarchical( $taxonomy ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1623
						$tax_term_names = get_terms(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1624
							array(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1625
								'taxonomy'   => $taxonomy,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1626
								'fields'     => 'names',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1627
								'hide_empty' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1628
							)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1629
						);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1630
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1631
						// Count the number of terms with the same name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
						$tax_term_names_count = array_count_values( $tax_term_names );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1634
						// Filter out non-ambiguous term names.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1635
						$ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1637
						$ambiguous_terms = array_keys( $ambiguous_tax_term_counts );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1639
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1640
					$term_names = $post_data['terms_names'][ $taxonomy ];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1641
					foreach ( $term_names as $term_name ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1642
						if ( in_array( $term_name, $ambiguous_terms, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1643
							return new IXR_Error( 401, __( 'Ambiguous term name used in a hierarchical taxonomy. Please use term ID instead.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1644
						}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1645
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1646
						$term = get_term_by( 'name', $term_name, $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
						if ( ! $term ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1649
							// Term doesn't exist, so check that the user is allowed to create new terms.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1650
							if ( ! current_user_can( $post_type_taxonomies[ $taxonomy ]->cap->edit_terms ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
								return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1652
							}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1654
							// Create the new term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
							$term_info = wp_insert_term( $term_name, $taxonomy );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1656
							if ( is_wp_error( $term_info ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
								return new IXR_Error( 500, $term_info->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1658
							}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1659
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1660
							$terms[ $taxonomy ][] = (int) $term_info['term_id'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
						} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1662
							$terms[ $taxonomy ][] = (int) $term->term_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
						}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1665
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1666
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1668
			$post_data['tax_input'] = $terms;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
			unset( $post_data['terms'], $post_data['terms_names'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1670
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1672
		if ( isset( $post_data['post_format'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1673
			$format = set_post_format( $post_id, $post_data['post_format'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1674
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1675
			if ( is_wp_error( $format ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1676
				return new IXR_Error( 500, $format->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1677
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1678
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1679
			unset( $post_data['post_format'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1682
		// Handle enclosures.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
		$enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1684
		$this->add_enclosure_if_new( $post_id, $enclosure );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1685
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1686
		$this->attach_uploads( $post_id, $post_data['post_content'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1688
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1689
		 * Filters post data array to be inserted via XML-RPC.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1690
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1691
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1692
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1693
		 * @param array $post_data      Parsed array of post data.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1694
		 * @param array $content_struct Post data array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1695
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1696
		$post_data = apply_filters( 'xmlrpc_wp_insert_post_data', $post_data, $content_struct );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1698
		// Remove all null values to allow for using the insert/update post default values for those keys instead.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1699
		$post_data = array_filter(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1700
			$post_data,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1701
			static function ( $value ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1702
				return null !== $value;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1703
			}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1704
		);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1705
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1706
		$post_id = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1707
		if ( is_wp_error( $post_id ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1708
			return new IXR_Error( 500, $post_id->get_error_message() );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1709
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1710
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1711
		if ( ! $post_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1712
			if ( $update ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1713
				return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1714
			} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1715
				return new IXR_Error( 401, __( 'Sorry, the post could not be created.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1716
			}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1717
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1719
		return (string) $post_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1723
	 * Edits a post for any registered post type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
	 * The $content_struct parameter only needs to contain fields that
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1726
	 * should be changed. All other fields will retain their existing values.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1728
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1730
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1731
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1732
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1733
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1734
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1735
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1736
	 *     @type int    $3 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1737
	 *     @type array  $4 Extra content arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1738
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1739
	 * @return true|IXR_Error True on success, IXR_Error on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1740
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1741
	public function wp_editPost( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1742
		if ( ! $this->minimum_args( $args, 5 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1744
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1746
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1747
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1748
		$username       = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1749
		$password       = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1750
		$post_id        = (int) $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1751
		$content_struct = $args[4];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1752
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1753
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1754
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1755
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1756
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1757
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1758
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1759
		do_action( 'xmlrpc_call', 'wp.editPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
		$post = get_post( $post_id, ARRAY_A );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1762
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1763
		if ( empty( $post['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1765
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
		if ( isset( $content_struct['if_not_modified_since'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
			// If the post has been modified since the date provided, return an error.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1769
			if ( mysql2date( 'U', $post['post_modified_gmt'] ) > $content_struct['if_not_modified_since']->getTimestamp() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
				return new IXR_Error( 409, __( 'There is a revision of this post that is more recent.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1772
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1774
		// Convert the date field back to IXR form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
		$post['post_date'] = $this->_convert_date( $post['post_date'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1777
		/*
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1778
		 * Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1779
		 * since _insert_post() will ignore the non-GMT date if the GMT date is set.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1780
		 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1781
		if ( '0000-00-00 00:00:00' === $post['post_date_gmt'] || isset( $content_struct['post_date'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
			unset( $post['post_date_gmt'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1783
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1784
			$post['post_date_gmt'] = $this->_convert_date( $post['post_date_gmt'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1785
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1786
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1787
		/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1788
		 * If the API client did not provide 'post_date', then we must not perpetuate the value that
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1789
		 * was stored in the database, or it will appear to be an intentional edit. Conveying it here
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1790
		 * as if it was coming from the API client will cause an otherwise zeroed out 'post_date_gmt'
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1791
		 * to get set with the value that was originally stored in the database when the draft was created.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1792
		 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1793
		if ( ! isset( $content_struct['post_date'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1794
			unset( $post['post_date'] );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1795
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1796
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
		$this->escape( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
		$merged_content_struct = array_merge( $post, $content_struct );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
		$retval = $this->_insert_post( $user, $merged_content_struct );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1801
		if ( $retval instanceof IXR_Error ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1802
			return $retval;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1803
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1804
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1805
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1806
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1807
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1808
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1809
	 * Deletes a post for any registered post type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1811
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1813
	 * @see wp_delete_post()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1814
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1815
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1816
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1817
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1818
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1819
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1820
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1821
	 *     @type int    $3 Post ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1822
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1823
	 * @return true|IXR_Error True on success, IXR_Error instance on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1825
	public function wp_deletePost( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1826
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1827
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1828
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1829
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1830
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1832
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1833
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1834
		$post_id  = (int) $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1835
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1836
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1837
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1838
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1839
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1840
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1841
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1842
		do_action( 'xmlrpc_call', 'wp.deletePost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1843
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
		$post = get_post( $post_id, ARRAY_A );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1845
		if ( empty( $post['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1846
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1847
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1848
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1849
		if ( ! current_user_can( 'delete_post', $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1851
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1852
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
		$result = wp_delete_post( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1854
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1855
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1856
			return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1857
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1858
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1860
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1862
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1863
	 * Retrieves a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1864
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1866
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1867
	 * The optional $fields parameter specifies what fields will be included
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1868
	 * in the response array. This should be a list of field names. 'post_id' will
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1869
	 * always be included in the response regardless of the value of $fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1870
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1871
	 * Instead of, or in addition to, individual field names, conceptual group
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1872
	 * names can be used to specify multiple fields. The available conceptual
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1873
	 * groups are 'post' (all basic fields), 'taxonomies', 'custom_fields',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1874
	 * and 'enclosure'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1876
	 * @see get_post()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1877
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1878
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1879
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1880
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1881
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1882
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1883
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1884
	 *     @type int    $3 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1885
	 *     @type array  $4 Optional. The subset of post type fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1886
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1887
	 * @return array|IXR_Error Array contains (based on $fields parameter):
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1888
	 *  - 'post_id'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1889
	 *  - 'post_title'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1890
	 *  - 'post_date'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
	 *  - 'post_date_gmt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1892
	 *  - 'post_modified'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1893
	 *  - 'post_modified_gmt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
	 *  - 'post_status'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1895
	 *  - 'post_type'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1896
	 *  - 'post_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
	 *  - 'post_author'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1898
	 *  - 'post_password'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1899
	 *  - 'post_excerpt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
	 *  - 'post_content'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
	 *  - 'link'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
	 *  - 'comment_status'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
	 *  - 'ping_status'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1904
	 *  - 'sticky'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
	 *  - 'custom_fields'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
	 *  - 'terms'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
	 *  - 'categories'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1908
	 *  - 'tags'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1909
	 *  - 'enclosure'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1910
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1911
	public function wp_getPost( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1912
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1913
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1914
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1917
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1918
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1919
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1920
		$post_id  = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1922
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1924
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1925
			/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1926
			 * Filters the default post query fields used by the given XML-RPC method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1927
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1928
			 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1929
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1930
			 * @param array  $fields An array of post fields to retrieve. By default,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1931
			 *                       contains 'post', 'terms', and 'custom_fields'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1932
			 * @param string $method Method name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1933
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1934
			$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPost' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1935
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1936
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1937
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1938
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1940
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1942
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1943
		do_action( 'xmlrpc_call', 'wp.getPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
		$post = get_post( $post_id, ARRAY_A );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1946
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1947
		if ( empty( $post['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1948
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1949
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1950
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1951
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1952
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1953
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1954
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1955
		return $this->_prepare_post( $post, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1956
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1957
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1959
	 * Retrieves posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1961
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1963
	 * @see wp_get_recent_posts()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1964
	 * @see wp_getPost() for more on `$fields`
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1965
	 * @see get_posts() for more on `$filter` values
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1966
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1967
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1968
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1969
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1970
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1971
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1972
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1973
	 *     @type array  $3 Optional. Modifies the query used to retrieve posts. Accepts 'post_type',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1974
	 *                     'post_status', 'number', 'offset', 'orderby', 's', and 'order'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1975
	 *                     Default empty array.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1976
	 *     @type array  $4 Optional. The subset of post type fields to return in the response array.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1977
	 * }
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1978
	 * @return array|IXR_Error Array containing a collection of posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1979
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1980
	public function wp_getPosts( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1981
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1982
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1983
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1985
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1986
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1987
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1988
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1989
		$filter   = isset( $args[3] ) ? $args[3] : array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1991
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1993
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1994
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1995
			$fields = apply_filters( 'xmlrpc_default_post_fields', array( 'post', 'terms', 'custom_fields' ), 'wp.getPosts' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1996
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1997
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1998
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1999
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2000
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2001
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2002
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2003
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2004
		do_action( 'xmlrpc_call', 'wp.getPosts', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2006
		$query = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2007
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
		if ( isset( $filter['post_type'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
			$post_type = get_post_type_object( $filter['post_type'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2010
			if ( ! ( (bool) $post_type ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2011
				return new IXR_Error( 403, __( 'Invalid post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2012
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2013
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
			$post_type = get_post_type_object( 'post' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2015
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2017
		if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2018
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2019
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2020
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2021
		$query['post_type'] = $post_type->name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2022
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2023
		if ( isset( $filter['post_status'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2024
			$query['post_status'] = $filter['post_status'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2025
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2026
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2027
		if ( isset( $filter['number'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2028
			$query['numberposts'] = absint( $filter['number'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2029
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2030
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2031
		if ( isset( $filter['offset'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2032
			$query['offset'] = absint( $filter['offset'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2033
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2034
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2035
		if ( isset( $filter['orderby'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
			$query['orderby'] = $filter['orderby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2038
			if ( isset( $filter['order'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
				$query['order'] = $filter['order'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2040
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2041
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2042
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2043
		if ( isset( $filter['s'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2044
			$query['s'] = $filter['s'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2045
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2047
		$posts_list = wp_get_recent_posts( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2048
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2049
		if ( ! $posts_list ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2050
			return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2051
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2052
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2053
		// Holds all the posts data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
		$struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
		foreach ( $posts_list as $post ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2057
			if ( ! current_user_can( 'edit_post', $post['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2058
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2059
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2060
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2061
			$struct[] = $this->_prepare_post( $post, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2062
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2063
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2065
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2066
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2067
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2068
	 * Creates a new term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2069
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2070
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2071
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2072
	 * @see wp_insert_term()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2073
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2074
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2075
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2076
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2077
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2078
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2079
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2080
	 *     @type array  $3 Content struct for adding a new term. The struct must contain
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2081
	 *                     the term 'name' and 'taxonomy'. Optional accepted values include
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2082
	 *                     'parent', 'description', and 'slug'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2083
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2084
	 * @return int|IXR_Error The term ID on success, or an IXR_Error object on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2085
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2086
	public function wp_newTerm( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2087
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2089
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2090
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2091
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2092
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2093
		$username       = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2094
		$password       = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2095
		$content_struct = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2096
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2097
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2098
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2099
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2100
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2101
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2102
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2103
		do_action( 'xmlrpc_call', 'wp.newTerm', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2104
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2105
		if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2106
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2107
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2108
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2109
		$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2110
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2111
		if ( ! current_user_can( $taxonomy->cap->edit_terms ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2112
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to create terms in this taxonomy.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2113
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2115
		$taxonomy = (array) $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2117
		// Hold the data of the term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2118
		$term_data = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2120
		$term_data['name'] = trim( $content_struct['name'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2121
		if ( empty( $term_data['name'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2122
			return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2123
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2124
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2125
		if ( isset( $content_struct['parent'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2126
			if ( ! $taxonomy['hierarchical'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
				return new IXR_Error( 403, __( 'This taxonomy is not hierarchical.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2128
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2129
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2130
			$parent_term_id = (int) $content_struct['parent'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2131
			$parent_term    = get_term( $parent_term_id, $taxonomy['name'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2132
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2133
			if ( is_wp_error( $parent_term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2134
				return new IXR_Error( 500, $parent_term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2135
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2136
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2137
			if ( ! $parent_term ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2138
				return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2139
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2141
			$term_data['parent'] = $content_struct['parent'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2143
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2144
		if ( isset( $content_struct['description'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2145
			$term_data['description'] = $content_struct['description'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2146
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2147
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2148
		if ( isset( $content_struct['slug'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2149
			$term_data['slug'] = $content_struct['slug'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2150
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2151
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2152
		$term = wp_insert_term( $term_data['name'], $taxonomy['name'], $term_data );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2153
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2154
		if ( is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2155
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2156
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2157
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2158
		if ( ! $term ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2159
			return new IXR_Error( 500, __( 'Sorry, the term could not be created.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2160
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2161
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2162
		// Add term meta.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2163
		if ( isset( $content_struct['custom_fields'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2164
			$this->set_term_custom_fields( $term['term_id'], $content_struct['custom_fields'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2165
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2167
		return (string) $term['term_id'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2168
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2170
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2171
	 * Edits a term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2172
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2173
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2174
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2175
	 * @see wp_update_term()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2176
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2177
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2178
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2179
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2180
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2181
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2182
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2183
	 *     @type int    $3 Term ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2184
	 *     @type array  $4 Content struct for editing a term. The struct must contain the
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2185
	 *                     term 'taxonomy'. Optional accepted values include 'name', 'parent',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2186
	 *                     'description', and 'slug'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2187
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2188
	 * @return true|IXR_Error True on success, IXR_Error instance on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2189
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2190
	public function wp_editTerm( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2191
		if ( ! $this->minimum_args( $args, 5 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2192
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2193
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2194
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2195
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2196
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2197
		$username       = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2198
		$password       = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2199
		$term_id        = (int) $args[3];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2200
		$content_struct = $args[4];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2201
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2202
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2203
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2204
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2205
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2206
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2207
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2208
		do_action( 'xmlrpc_call', 'wp.editTerm', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2209
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2210
		if ( ! taxonomy_exists( $content_struct['taxonomy'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2211
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2212
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2213
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2214
		$taxonomy = get_taxonomy( $content_struct['taxonomy'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2216
		$taxonomy = (array) $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2217
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2218
		// Hold the data of the term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2219
		$term_data = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2220
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2221
		$term = get_term( $term_id, $content_struct['taxonomy'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2222
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2223
		if ( is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2225
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2226
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2227
		if ( ! $term ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2228
			return new IXR_Error( 404, __( 'Invalid term ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2229
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2230
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2231
		if ( ! current_user_can( 'edit_term', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2232
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this term.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2233
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2234
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2235
		if ( isset( $content_struct['name'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2236
			$term_data['name'] = trim( $content_struct['name'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2237
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2238
			if ( empty( $term_data['name'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2239
				return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2240
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2241
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2242
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2243
		if ( ! empty( $content_struct['parent'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2244
			if ( ! $taxonomy['hierarchical'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2245
				return new IXR_Error( 403, __( 'Cannot set parent term, taxonomy is not hierarchical.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2246
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
			$parent_term_id = (int) $content_struct['parent'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2249
			$parent_term    = get_term( $parent_term_id, $taxonomy['name'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2250
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2251
			if ( is_wp_error( $parent_term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2252
				return new IXR_Error( 500, $parent_term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2253
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2254
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2255
			if ( ! $parent_term ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2256
				return new IXR_Error( 403, __( 'Parent term does not exist.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2257
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2259
			$term_data['parent'] = $content_struct['parent'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2261
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2262
		if ( isset( $content_struct['description'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
			$term_data['description'] = $content_struct['description'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2264
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2265
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2266
		if ( isset( $content_struct['slug'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2267
			$term_data['slug'] = $content_struct['slug'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2268
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2269
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2270
		$term = wp_update_term( $term_id, $taxonomy['name'], $term_data );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2271
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2272
		if ( is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2273
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2274
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2275
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2276
		if ( ! $term ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2277
			return new IXR_Error( 500, __( 'Sorry, editing the term failed.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2278
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2279
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2280
		// Update term meta.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2281
		if ( isset( $content_struct['custom_fields'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2282
			$this->set_term_custom_fields( $term_id, $content_struct['custom_fields'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2283
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2284
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2285
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2286
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2287
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2288
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2289
	 * Deletes a term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2290
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2291
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2292
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2293
	 * @see wp_delete_term()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2294
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2295
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2296
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2297
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2298
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2299
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2300
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2301
	 *     @type string $3 Taxonomy name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2302
	 *     @type int    $4 Term ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2303
	 * }
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2304
	 * @return true|IXR_Error True on success, IXR_Error instance on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2305
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2306
	public function wp_deleteTerm( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2307
		if ( ! $this->minimum_args( $args, 5 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2309
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2310
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2311
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2312
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2313
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2314
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2315
		$taxonomy = $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2316
		$term_id  = (int) $args[4];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2317
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2318
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2319
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2320
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2321
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2322
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2323
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2324
		do_action( 'xmlrpc_call', 'wp.deleteTerm', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2325
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2326
		if ( ! taxonomy_exists( $taxonomy ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2327
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2328
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2329
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2330
		$taxonomy = get_taxonomy( $taxonomy );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2331
		$term     = get_term( $term_id, $taxonomy->name );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2332
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2333
		if ( is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2334
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2335
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2336
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2337
		if ( ! $term ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2338
			return new IXR_Error( 404, __( 'Invalid term ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2339
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2340
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2341
		if ( ! current_user_can( 'delete_term', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2342
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this term.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2343
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2345
		$result = wp_delete_term( $term_id, $taxonomy->name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2346
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2347
		if ( is_wp_error( $result ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2349
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2350
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2351
		if ( ! $result ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2352
			return new IXR_Error( 500, __( 'Sorry, deleting the term failed.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2353
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2354
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2355
		return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2356
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2357
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2358
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2359
	 * Retrieves a term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2360
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2361
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2362
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2363
	 * @see get_term()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2364
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2365
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2366
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2367
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2368
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2369
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2370
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2371
	 *     @type string $3 Taxonomy name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2372
	 *     @type int    $4 Term ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2373
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2374
	 * @return array|IXR_Error IXR_Error on failure, array on success, containing:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2375
	 *  - 'term_id'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2376
	 *  - 'name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
	 *  - 'slug'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
	 *  - 'term_group'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
	 *  - 'term_taxonomy_id'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
	 *  - 'taxonomy'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
	 *  - 'description'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2382
	 *  - 'parent'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2383
	 *  - 'count'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2384
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2385
	public function wp_getTerm( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2386
		if ( ! $this->minimum_args( $args, 5 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2387
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2388
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2390
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2392
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2393
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2394
		$taxonomy = $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2395
		$term_id  = (int) $args[4];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2396
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2397
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2398
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2399
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2400
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2401
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2402
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2403
		do_action( 'xmlrpc_call', 'wp.getTerm', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2404
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2405
		if ( ! taxonomy_exists( $taxonomy ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2406
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2407
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2408
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
		$taxonomy = get_taxonomy( $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2411
		$term = get_term( $term_id, $taxonomy->name, ARRAY_A );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2412
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2413
		if ( is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
			return new IXR_Error( 500, $term->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2415
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2416
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2417
		if ( ! $term ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2418
			return new IXR_Error( 404, __( 'Invalid term ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2419
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2420
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2421
		if ( ! current_user_can( 'assign_term', $term_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2422
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign this term.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2423
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2425
		return $this->_prepare_term( $term );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2426
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2427
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2428
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2429
	 * Retrieves all terms for a taxonomy.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2430
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2431
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2432
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2433
	 * The optional $filter parameter modifies the query used to retrieve terms.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2434
	 * Accepted keys are 'number', 'offset', 'orderby', 'order', 'hide_empty', and 'search'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2435
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2436
	 * @see get_terms()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2437
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2438
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2439
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2440
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2441
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2442
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2443
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2444
	 *     @type string $3 Taxonomy name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2445
	 *     @type array  $4 Optional. Modifies the query used to retrieve posts. Accepts 'number',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2446
	 *                     'offset', 'orderby', 'order', 'hide_empty', and 'search'. Default empty array.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2447
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2448
	 * @return array|IXR_Error An associative array of terms data on success, IXR_Error instance otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2449
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2450
	public function wp_getTerms( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2451
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2452
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2453
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2454
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2455
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2456
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2457
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2458
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2459
		$taxonomy = $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2460
		$filter   = isset( $args[4] ) ? $args[4] : array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2461
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2462
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2463
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2465
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2466
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2467
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2468
		do_action( 'xmlrpc_call', 'wp.getTerms', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2469
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2470
		if ( ! taxonomy_exists( $taxonomy ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2471
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2472
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2473
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2474
		$taxonomy = get_taxonomy( $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2475
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2476
		if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2477
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2478
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2479
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2480
		$query = array( 'taxonomy' => $taxonomy->name );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2481
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2482
		if ( isset( $filter['number'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
			$query['number'] = absint( $filter['number'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2484
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2485
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2486
		if ( isset( $filter['offset'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
			$query['offset'] = absint( $filter['offset'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2488
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2490
		if ( isset( $filter['orderby'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2491
			$query['orderby'] = $filter['orderby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2492
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2493
			if ( isset( $filter['order'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
				$query['order'] = $filter['order'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2495
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2496
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2497
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2498
		if ( isset( $filter['hide_empty'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2499
			$query['hide_empty'] = $filter['hide_empty'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2500
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2501
			$query['get'] = 'all';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2502
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2503
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2504
		if ( isset( $filter['search'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2505
			$query['search'] = $filter['search'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2506
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2507
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2508
		$terms = get_terms( $query );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2509
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2510
		if ( is_wp_error( $terms ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
			return new IXR_Error( 500, $terms->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2512
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2514
		$struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2516
		foreach ( $terms as $term ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2517
			$struct[] = $this->_prepare_term( $term );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2518
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2519
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2520
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2521
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2522
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2523
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2524
	 * Retrieves a taxonomy.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2525
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2526
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2527
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2528
	 * @see get_taxonomy()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2529
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2530
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2531
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2532
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2533
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2534
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2535
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2536
	 *     @type string $3 Taxonomy name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2537
	 *     @type array  $4 Optional. Array of taxonomy fields to limit to in the return.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2538
	 *                     Accepts 'labels', 'cap', 'menu', and 'object_type'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2539
	 *                     Default empty array.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2540
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2541
	 * @return array|IXR_Error An array of taxonomy data on success, IXR_Error instance otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2542
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2543
	public function wp_getTaxonomy( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2544
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2545
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2546
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2547
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2548
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2549
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2550
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2551
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2552
		$taxonomy = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2553
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2554
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2555
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2556
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2557
			/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2558
			 * Filters the default taxonomy query fields used by the given XML-RPC method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2559
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2560
			 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2561
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2562
			 * @param array  $fields An array of taxonomy fields to retrieve. By default,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2563
			 *                       contains 'labels', 'cap', and 'object_type'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2564
			 * @param string $method The method name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2565
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2566
			$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomy' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2567
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2568
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2569
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2570
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2571
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2572
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2573
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2574
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2575
		do_action( 'xmlrpc_call', 'wp.getTaxonomy', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2576
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2577
		if ( ! taxonomy_exists( $taxonomy ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2578
			return new IXR_Error( 403, __( 'Invalid taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2579
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2580
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2581
		$taxonomy = get_taxonomy( $taxonomy );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2582
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2583
		if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2584
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign terms in this taxonomy.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2585
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2586
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2587
		return $this->_prepare_taxonomy( $taxonomy, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2588
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2589
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2590
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2591
	 * Retrieves all taxonomies.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2592
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2593
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2594
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2595
	 * @see get_taxonomies()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2596
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2597
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2598
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2599
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2600
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2601
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2602
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2603
	 *     @type array  $3 Optional. An array of arguments for retrieving taxonomies.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2604
	 *     @type array  $4 Optional. The subset of taxonomy fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2605
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2606
	 * @return array|IXR_Error An associative array of taxonomy data with returned fields determined
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2607
	 *                         by `$fields`, or an IXR_Error instance on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2608
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2609
	public function wp_getTaxonomies( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2610
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2611
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2612
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2613
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2614
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2615
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2616
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2617
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2618
		$filter   = isset( $args[3] ) ? $args[3] : array( 'public' => true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2619
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2620
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2621
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2622
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2623
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2624
			$fields = apply_filters( 'xmlrpc_default_taxonomy_fields', array( 'labels', 'cap', 'object_type' ), 'wp.getTaxonomies' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2625
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2626
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2627
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2628
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2629
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2630
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2631
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2632
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2633
		do_action( 'xmlrpc_call', 'wp.getTaxonomies', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2634
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
		$taxonomies = get_taxonomies( $filter, 'objects' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2636
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2637
		// Holds all the taxonomy data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2638
		$struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2639
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2640
		foreach ( $taxonomies as $taxonomy ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2641
			// Capability check for post types.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2642
			if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2643
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2644
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2645
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2646
			$struct[] = $this->_prepare_taxonomy( $taxonomy, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2647
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2648
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2649
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2650
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2651
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2652
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2653
	 * Retrieves a user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2654
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2655
	 * The optional $fields parameter specifies what fields will be included
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2656
	 * in the response array. This should be a list of field names. 'user_id' will
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2657
	 * always be included in the response regardless of the value of $fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2658
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2659
	 * Instead of, or in addition to, individual field names, conceptual group
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2660
	 * names can be used to specify multiple fields. The available conceptual
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2661
	 * groups are 'basic' and 'all'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2662
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2663
	 * @uses get_userdata()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2664
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2665
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2666
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2667
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2668
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2669
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2670
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2671
	 *     @type int    $3 User ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2672
	 *     @type array  $4 Optional. Array of fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2673
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2674
	 * @return array|IXR_Error Array contains (based on $fields parameter):
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2675
	 *  - 'user_id'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2676
	 *  - 'username'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2677
	 *  - 'first_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2678
	 *  - 'last_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2679
	 *  - 'registered'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2680
	 *  - 'bio'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2681
	 *  - 'email'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2682
	 *  - 'nickname'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2683
	 *  - 'nicename'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2684
	 *  - 'url'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2685
	 *  - 'display_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2686
	 *  - 'roles'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2687
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2688
	public function wp_getUser( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2689
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2690
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2691
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2692
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2693
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2694
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2695
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2696
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2697
		$user_id  = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2698
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2699
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2700
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2701
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2702
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2703
			 * Filters the default user query fields used by the given XML-RPC method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2704
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2705
			 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2706
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2707
			 * @param array  $fields An array of user fields to retrieve. By default, contains 'all'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2708
			 * @param string $method The method name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2709
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2710
			$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUser' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2711
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2712
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2713
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2714
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2715
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2716
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2717
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2718
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2719
		do_action( 'xmlrpc_call', 'wp.getUser', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2720
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2721
		if ( ! current_user_can( 'edit_user', $user_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2722
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this user.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2723
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2724
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2725
		$user_data = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2726
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2727
		if ( ! $user_data ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2728
			return new IXR_Error( 404, __( 'Invalid user ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2729
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2731
		return $this->_prepare_user( $user_data, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2732
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2733
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2734
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2735
	 * Retrieves users.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2736
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2737
	 * The optional $filter parameter modifies the query used to retrieve users.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2738
	 * Accepted keys are 'number' (default: 50), 'offset' (default: 0), 'role',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2739
	 * 'who', 'orderby', and 'order'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2740
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2741
	 * The optional $fields parameter specifies what fields will be included
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2742
	 * in the response array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2743
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2744
	 * @uses get_users()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2745
	 * @see wp_getUser() for more on $fields and return values
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2746
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2747
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2748
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2749
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2750
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2751
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2752
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2753
	 *     @type array  $3 Optional. Arguments for the user query.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2754
	 *     @type array  $4 Optional. Fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2755
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2756
	 * @return array|IXR_Error users data
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2757
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2758
	public function wp_getUsers( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2759
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2760
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2761
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2762
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2763
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2764
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2765
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2766
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2767
		$filter   = isset( $args[3] ) ? $args[3] : array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2768
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2769
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2770
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2771
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2772
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2773
			$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getUsers' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2774
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2775
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2776
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2777
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2778
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2779
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2780
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2781
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2782
		do_action( 'xmlrpc_call', 'wp.getUsers', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2783
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2784
		if ( ! current_user_can( 'list_users' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2785
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to list users.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2786
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2787
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2788
		$query = array( 'fields' => 'all_with_meta' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2789
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2790
		$query['number'] = ( isset( $filter['number'] ) ) ? absint( $filter['number'] ) : 50;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2791
		$query['offset'] = ( isset( $filter['offset'] ) ) ? absint( $filter['offset'] ) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2792
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2793
		if ( isset( $filter['orderby'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2794
			$query['orderby'] = $filter['orderby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2795
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2796
			if ( isset( $filter['order'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2797
				$query['order'] = $filter['order'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2798
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2799
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2800
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2801
		if ( isset( $filter['role'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2802
			if ( get_role( $filter['role'] ) === null ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2803
				return new IXR_Error( 403, __( 'Invalid role.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2804
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2805
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2806
			$query['role'] = $filter['role'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2807
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2808
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2809
		if ( isset( $filter['who'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2810
			$query['who'] = $filter['who'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2811
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2812
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2813
		$users = get_users( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2814
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2815
		$_users = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2816
		foreach ( $users as $user_data ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2817
			if ( current_user_can( 'edit_user', $user_data->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2818
				$_users[] = $this->_prepare_user( $user_data, $fields );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2819
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2820
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2821
		return $_users;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2822
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2823
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2824
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2825
	 * Retrieves information about the requesting user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2826
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2827
	 * @uses get_userdata()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2828
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2829
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2830
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2831
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2832
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2833
	 *     @type string $1 Username
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2834
	 *     @type string $2 Password
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2835
	 *     @type array  $3 Optional. Fields to return.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2836
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2837
	 * @return array|IXR_Error (@see wp_getUser)
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2838
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2839
	public function wp_getProfile( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2840
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2841
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2842
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2843
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2844
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2845
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2846
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2847
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2848
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2849
		if ( isset( $args[3] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2850
			$fields = $args[3];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2851
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2852
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2853
			$fields = apply_filters( 'xmlrpc_default_user_fields', array( 'all' ), 'wp.getProfile' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2854
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2855
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2856
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2857
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2858
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2859
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2860
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2861
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2862
		do_action( 'xmlrpc_call', 'wp.getProfile', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2863
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2864
		if ( ! current_user_can( 'edit_user', $user->ID ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2865
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2866
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2867
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2868
		$user_data = get_userdata( $user->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2869
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2870
		return $this->_prepare_user( $user_data, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2871
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2872
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2873
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2874
	 * Edits user's profile.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2875
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2876
	 * @uses wp_update_user()
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2877
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2878
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2879
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2880
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2881
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2882
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2883
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2884
	 *     @type array  $3 Content struct. It can optionally contain:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2885
	 *      - 'first_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2886
	 *      - 'last_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2887
	 *      - 'website'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2888
	 *      - 'display_name'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2889
	 *      - 'nickname'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2890
	 *      - 'nicename'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2891
	 *      - 'bio'
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2892
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2893
	 * @return true|IXR_Error True, on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2894
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2895
	public function wp_editProfile( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2896
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2897
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2898
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2899
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2900
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2901
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2902
		$username       = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2903
		$password       = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2904
		$content_struct = $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2905
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2906
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2907
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2908
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2909
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2910
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2911
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2912
		do_action( 'xmlrpc_call', 'wp.editProfile', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2913
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2914
		if ( ! current_user_can( 'edit_user', $user->ID ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2915
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2916
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2917
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2918
		// Holds data of the user.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2919
		$user_data       = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2920
		$user_data['ID'] = $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2921
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2922
		// Only set the user details if they were given.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2923
		if ( isset( $content_struct['first_name'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2924
			$user_data['first_name'] = $content_struct['first_name'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2925
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2926
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2927
		if ( isset( $content_struct['last_name'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2928
			$user_data['last_name'] = $content_struct['last_name'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2929
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2930
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2931
		if ( isset( $content_struct['url'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2932
			$user_data['user_url'] = $content_struct['url'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2933
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2934
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2935
		if ( isset( $content_struct['display_name'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2936
			$user_data['display_name'] = $content_struct['display_name'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2937
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2938
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2939
		if ( isset( $content_struct['nickname'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2940
			$user_data['nickname'] = $content_struct['nickname'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2941
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2942
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2943
		if ( isset( $content_struct['nicename'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2944
			$user_data['user_nicename'] = $content_struct['nicename'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2945
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2946
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2947
		if ( isset( $content_struct['bio'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2948
			$user_data['description'] = $content_struct['bio'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2949
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2950
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2951
		$result = wp_update_user( $user_data );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2952
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2953
		if ( is_wp_error( $result ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2954
			return new IXR_Error( 500, $result->get_error_message() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2955
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2956
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2957
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2958
			return new IXR_Error( 500, __( 'Sorry, the user could not be updated.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2959
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2960
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2961
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2962
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2963
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2964
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2965
	 * Retrieves a page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2966
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2967
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2968
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2969
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2970
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2971
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2972
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2973
	 *     @type int    $1 Page ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2974
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2975
	 *     @type string $3 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2976
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2977
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2978
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2979
	public function wp_getPage( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2980
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2981
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2982
		$page_id  = (int) $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2983
		$username = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2984
		$password = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2985
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2986
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2987
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2988
			return $this->error;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2989
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2990
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2991
		$page = get_post( $page_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2992
		if ( ! $page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2993
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2994
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2995
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2996
		if ( ! current_user_can( 'edit_page', $page_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2997
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2998
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2999
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3000
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3001
		do_action( 'xmlrpc_call', 'wp.getPage', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3002
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3003
		// If we found the page then format the data.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3004
		if ( $page->ID && ( 'page' === $page->post_type ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3005
			return $this->_prepare_page( $page );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3006
		} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3007
			// If the page doesn't exist, indicate that.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3008
			return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3009
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3010
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3011
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3012
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3013
	 * Retrieves Pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3014
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3015
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3016
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3017
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3018
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3019
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3020
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3021
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3022
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3023
	 *     @type int    $3 Optional. Number of pages. Default 10.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3024
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3025
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3026
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3027
	public function wp_getPages( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3028
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3029
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3030
		$username  = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3031
		$password  = $args[2];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3032
		$num_pages = isset( $args[3] ) ? (int) $args[3] : 10;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3033
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3034
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3035
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3036
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3037
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3038
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3039
		if ( ! current_user_can( 'edit_pages' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3040
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3041
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3042
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3043
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3044
		do_action( 'xmlrpc_call', 'wp.getPages', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3045
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3046
		$pages     = get_posts(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3047
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3048
				'post_type'   => 'page',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3049
				'post_status' => 'any',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3050
				'numberposts' => $num_pages,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3051
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3052
		);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3053
		$num_pages = count( $pages );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3054
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3055
		// If we have pages, put together their info.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3056
		if ( $num_pages >= 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3057
			$pages_struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3058
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3059
			foreach ( $pages as $page ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3060
				if ( current_user_can( 'edit_page', $page->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3061
					$pages_struct[] = $this->_prepare_page( $page );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3062
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3063
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3064
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3065
			return $pages_struct;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3066
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3067
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3068
		return array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3069
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3070
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3071
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3072
	 * Creates a new page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3073
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3074
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3075
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3076
	 * @see wp_xmlrpc_server::mw_newPost()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3077
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3078
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3079
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3080
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3081
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3082
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3083
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3084
	 *     @type array  $3 Content struct.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3085
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3086
	 * @return int|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3087
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3088
	public function wp_newPage( $args ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3089
		// Items not escaped here will be escaped in wp_newPost().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3090
		$username = $this->escape( $args[1] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3091
		$password = $this->escape( $args[2] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3092
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3093
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3094
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3095
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3096
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3097
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3098
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3099
		do_action( 'xmlrpc_call', 'wp.newPage', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3100
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3101
		// Mark this as content for a page.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3102
		$args[3]['post_type'] = 'page';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3103
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3104
		// Let mw_newPost() do all of the heavy lifting.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3105
		return $this->mw_newPost( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3106
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3108
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3109
	 * Deletes a page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3110
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3111
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3112
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3113
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3114
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3115
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3116
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3117
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3118
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3119
	 *     @type int    $3 Page ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3120
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3121
	 * @return true|IXR_Error True, if success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3122
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3123
	public function wp_deletePage( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3124
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3125
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3126
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3127
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3128
		$page_id  = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3129
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3130
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3131
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3132
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3133
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3134
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3135
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3136
		do_action( 'xmlrpc_call', 'wp.deletePage', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3137
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3138
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3139
		 * Get the current page based on the 'page_id' and
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3140
		 * make sure it is a page and not a post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3141
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3142
		$actual_page = get_post( $page_id, ARRAY_A );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3143
		if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3144
			return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3145
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3147
		// Make sure the user can delete pages.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3148
		if ( ! current_user_can( 'delete_page', $page_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3149
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3150
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3151
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3152
		// Attempt to delete the page.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3153
		$result = wp_delete_post( $page_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3154
		if ( ! $result ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3155
			return new IXR_Error( 500, __( 'Failed to delete the page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3156
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3157
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3158
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3159
		 * Fires after a page has been successfully deleted via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3160
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3161
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3162
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3163
		 * @param int   $page_id ID of the deleted page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3164
		 * @param array $args    An array of arguments to delete the page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3165
		 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3166
		do_action( 'xmlrpc_call_success_wp_deletePage', $page_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3167
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3168
		return true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3169
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3170
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3171
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3172
	 * Edits a page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3173
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3174
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3175
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3176
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3177
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3178
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3179
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3180
	 *     @type int    $1 Page ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3181
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3182
	 *     @type string $3 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3183
	 *     @type string $4 Content.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3184
	 *     @type int    $5 Publish flag. 0 for draft, 1 for publish.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3185
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3186
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3187
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3188
	public function wp_editPage( $args ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3189
		// Items will be escaped in mw_editPost().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3190
		$page_id  = (int) $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3191
		$username = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3192
		$password = $args[3];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3193
		$content  = $args[4];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3194
		$publish  = $args[5];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3195
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3196
		$escaped_username = $this->escape( $username );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3197
		$escaped_password = $this->escape( $password );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3198
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3199
		$user = $this->login( $escaped_username, $escaped_password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3200
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3201
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3202
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3203
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3204
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3205
		do_action( 'xmlrpc_call', 'wp.editPage', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3206
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3207
		// Get the page data and make sure it is a page.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3208
		$actual_page = get_post( $page_id, ARRAY_A );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3209
		if ( ! $actual_page || ( 'page' !== $actual_page['post_type'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3210
			return new IXR_Error( 404, __( 'Sorry, no such page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3211
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3212
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3213
		// Make sure the user is allowed to edit pages.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3214
		if ( ! current_user_can( 'edit_page', $page_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3215
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this page.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3216
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3217
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3218
		// Mark this as content for a page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3219
		$content['post_type'] = 'page';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3220
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3221
		// Arrange args in the way mw_editPost() understands.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3222
		$args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3223
			$page_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3224
			$username,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3225
			$password,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3226
			$content,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3227
			$publish,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3228
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3229
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3230
		// Let mw_editPost() do all of the heavy lifting.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3231
		return $this->mw_editPost( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3232
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3233
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3234
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3235
	 * Retrieves page list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3236
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3237
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3238
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3239
	 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3240
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3241
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3242
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3243
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3244
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3245
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3246
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3247
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3248
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3249
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3250
	public function wp_getPageList( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3251
		global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3252
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3253
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3254
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3255
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3256
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3257
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3258
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3259
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3260
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3261
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3262
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3263
		if ( ! current_user_can( 'edit_pages' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3264
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit pages.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3265
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3266
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3267
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3268
		do_action( 'xmlrpc_call', 'wp.getPageList', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3269
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3270
		// Get list of page IDs and titles.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3271
		$page_list = $wpdb->get_results(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3272
			"
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3273
			SELECT ID page_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3274
				post_title page_title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3275
				post_parent page_parent_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3276
				post_date_gmt,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3277
				post_date,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3278
				post_status
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3279
			FROM {$wpdb->posts}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3280
			WHERE post_type = 'page'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3281
			ORDER BY ID
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3282
		"
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3283
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3284
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3285
		// The date needs to be formatted properly.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3286
		$num_pages = count( $page_list );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3287
		for ( $i = 0; $i < $num_pages; $i++ ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3288
			$page_list[ $i ]->dateCreated      = $this->_convert_date( $page_list[ $i ]->post_date );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3289
			$page_list[ $i ]->date_created_gmt = $this->_convert_date_gmt( $page_list[ $i ]->post_date_gmt, $page_list[ $i ]->post_date );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3290
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3291
			unset( $page_list[ $i ]->post_date_gmt );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3292
			unset( $page_list[ $i ]->post_date );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3293
			unset( $page_list[ $i ]->post_status );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3294
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3295
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3296
		return $page_list;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3297
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3298
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3299
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3300
	 * Retrieves authors list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3301
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3302
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3303
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3304
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3305
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3306
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3307
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3308
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3309
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3310
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3311
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3312
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3313
	public function wp_getAuthors( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3314
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3315
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3316
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3317
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3318
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3319
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3320
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3321
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3322
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3323
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3324
		if ( ! current_user_can( 'edit_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3325
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3326
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3327
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3328
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3329
		do_action( 'xmlrpc_call', 'wp.getAuthors', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3330
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3331
		$authors = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3332
		foreach ( get_users( array( 'fields' => array( 'ID', 'user_login', 'display_name' ) ) ) as $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3333
			$authors[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3334
				'user_id'      => $user->ID,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3335
				'user_login'   => $user->user_login,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3336
				'display_name' => $user->display_name,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3337
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3338
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3339
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3340
		return $authors;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3341
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3343
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3344
	 * Gets the list of all tags.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3345
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3346
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3347
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3348
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3349
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3350
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3351
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3352
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3353
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3354
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3355
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3356
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3357
	public function wp_getTags( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3358
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3359
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3360
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3361
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3362
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3363
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3364
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3365
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3366
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3367
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3368
		if ( ! current_user_can( 'edit_posts' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3369
			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view tags.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3370
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3371
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3372
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3373
		do_action( 'xmlrpc_call', 'wp.getKeywords', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3374
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3375
		$tags = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3376
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3377
		$all_tags = get_tags();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3378
		if ( $all_tags ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3379
			foreach ( (array) $all_tags as $tag ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3380
				$struct             = array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3381
				$struct['tag_id']   = $tag->term_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3382
				$struct['name']     = $tag->name;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3383
				$struct['count']    = $tag->count;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3384
				$struct['slug']     = $tag->slug;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3385
				$struct['html_url'] = esc_html( get_tag_link( $tag->term_id ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3386
				$struct['rss_url']  = esc_html( get_tag_feed_link( $tag->term_id ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3387
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3388
				$tags[] = $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3389
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3390
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3391
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3392
		return $tags;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3393
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3395
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3396
	 * Creates a new category.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3397
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3398
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3399
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3400
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3401
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3402
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3403
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3404
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3405
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3406
	 *     @type array  $3 Category.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3407
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3408
	 * @return int|IXR_Error Category ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3409
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3410
	public function wp_newCategory( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3411
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3412
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3413
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3414
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3415
		$category = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3416
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3417
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3418
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3419
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3420
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3421
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3422
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3423
		do_action( 'xmlrpc_call', 'wp.newCategory', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3425
		// Make sure the user is allowed to add a category.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3426
		if ( ! current_user_can( 'manage_categories' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3427
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3428
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3429
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3430
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3431
		 * If no slug was provided, make it empty
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3432
		 * so that WordPress will generate one.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3433
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3434
		if ( empty( $category['slug'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3435
			$category['slug'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3436
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3437
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3438
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3439
		 * If no parent_id was provided, make it empty
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3440
		 * so that it will be a top-level page (no parent).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3441
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3442
		if ( ! isset( $category['parent_id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3443
			$category['parent_id'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3444
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3445
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3446
		// If no description was provided, make it empty.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3447
		if ( empty( $category['description'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3448
			$category['description'] = '';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3449
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3451
		$new_category = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3452
			'cat_name'             => $category['name'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3453
			'category_nicename'    => $category['slug'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3454
			'category_parent'      => $category['parent_id'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3455
			'category_description' => $category['description'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3456
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3457
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3458
		$cat_id = wp_insert_category( $new_category, true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3459
		if ( is_wp_error( $cat_id ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3460
			if ( 'term_exists' === $cat_id->get_error_code() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3461
				return (int) $cat_id->get_error_data();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3462
			} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3463
				return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3464
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3465
		} elseif ( ! $cat_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3466
			return new IXR_Error( 500, __( 'Sorry, the category could not be created.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3467
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3468
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3469
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3470
		 * Fires after a new category has been successfully created via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3471
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3472
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3473
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3474
		 * @param int   $cat_id ID of the new category.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3475
		 * @param array $args   An array of new category arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3476
		 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3477
		do_action( 'xmlrpc_call_success_wp_newCategory', $cat_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3478
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3479
		return $cat_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3480
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3481
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3482
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3483
	 * Deletes a category.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3484
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3485
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3486
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3487
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3488
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3489
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3490
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3491
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3492
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3493
	 *     @type int    $3 Category ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3494
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3495
	 * @return bool|IXR_Error See wp_delete_term() for return info.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3496
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3497
	public function wp_deleteCategory( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3498
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3499
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3500
		$username    = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3501
		$password    = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3502
		$category_id = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3503
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3504
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3505
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3506
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3507
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3508
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3509
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3510
		do_action( 'xmlrpc_call', 'wp.deleteCategory', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3511
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3512
		if ( ! current_user_can( 'delete_term', $category_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3513
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3514
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3516
		$status = wp_delete_term( $category_id, 'category' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3517
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3518
		if ( true === $status ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3519
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3520
			 * Fires after a category has been successfully deleted via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3521
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3522
			 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3523
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3524
			 * @param int   $category_id ID of the deleted category.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3525
			 * @param array $args        An array of arguments to delete the category.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3526
			 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3527
			do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3528
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3529
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3530
		return $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3531
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3532
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3533
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3534
	 * Retrieves category list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3535
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3536
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3537
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3538
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3539
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3540
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3541
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3542
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3543
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3544
	 *     @type array  $3 Category
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3545
	 *     @type int    $4 Max number of results.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3546
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3547
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3548
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3549
	public function wp_suggestCategories( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3550
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3551
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3552
		$username    = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3553
		$password    = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3554
		$category    = $args[3];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3555
		$max_results = (int) $args[4];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3556
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3557
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3558
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3559
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3560
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3561
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3562
		if ( ! current_user_can( 'edit_posts' ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3563
			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3564
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3565
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3566
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3567
		do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3568
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3569
		$category_suggestions = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3570
		$args                 = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3571
			'get'        => 'all',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3572
			'number'     => $max_results,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3573
			'name__like' => $category,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3574
		);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3575
		foreach ( (array) get_categories( $args ) as $cat ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3576
			$category_suggestions[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3577
				'category_id'   => $cat->term_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3578
				'category_name' => $cat->name,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3579
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3580
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3581
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3582
		return $category_suggestions;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3583
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3584
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3585
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3586
	 * Retrieves a comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3587
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3588
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3589
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3590
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3591
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3592
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3593
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3594
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3595
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3596
	 *     @type int    $3 Comment ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3597
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3598
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3599
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3600
	public function wp_getComment( $args ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3601
		$this->escape( $args );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3602
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3603
		$username   = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3604
		$password   = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3605
		$comment_id = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3606
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3607
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3608
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3609
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3610
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3611
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3612
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3613
		do_action( 'xmlrpc_call', 'wp.getComment', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3614
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3615
		$comment = get_comment( $comment_id );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3616
		if ( ! $comment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3617
			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3618
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3619
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3620
		if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3621
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3622
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3623
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3624
		return $this->_prepare_comment( $comment );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3625
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3626
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3627
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3628
	 * Retrieves comments.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3629
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3630
	 * Besides the common blog_id (unused), username, and password arguments,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3631
	 * it takes a filter array as the last argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3632
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3633
	 * Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3634
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3635
	 * The defaults are as follows:
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3636
	 * - 'status'  - Default is ''. Filter by status (e.g., 'approve', 'hold')
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3637
	 * - 'post_id' - Default is ''. The post where the comment is posted.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3638
	 *               Empty string shows all comments.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3639
	 * - 'number'  - Default is 10. Total number of media items to retrieve.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3640
	 * - 'offset'  - Default is 0. See WP_Query::query() for more.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3641
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3642
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3643
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3644
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3645
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3646
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3647
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3648
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3649
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3650
	 *     @type array  $3 Optional. Query arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3651
	 * }
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3652
	 * @return array|IXR_Error Array containing a collection of comments.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3653
	 *                         See wp_xmlrpc_server::wp_getComment() for a description
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3654
	 *                         of each item contents.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3655
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3656
	public function wp_getComments( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3657
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3658
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3659
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3660
		$password = $args[2];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3661
		$struct   = isset( $args[3] ) ? $args[3] : array();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3662
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3663
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3664
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3665
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3666
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3667
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3668
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3669
		do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3670
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3671
		if ( isset( $struct['status'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3672
			$status = $struct['status'];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3673
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3674
			$status = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3675
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3676
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3677
		if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3678
			return new IXR_Error( 401, __( 'Invalid comment status.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3679
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3680
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3681
		$post_id = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3682
		if ( isset( $struct['post_id'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3683
			$post_id = absint( $struct['post_id'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3684
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3685
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3686
		$post_type = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3687
		if ( isset( $struct['post_type'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3688
			$post_type_object = get_post_type_object( $struct['post_type'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3689
			if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3690
				return new IXR_Error( 404, __( 'Invalid post type.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3691
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3692
			$post_type = $struct['post_type'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3693
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3694
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3695
		$offset = 0;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3696
		if ( isset( $struct['offset'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3697
			$offset = absint( $struct['offset'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3698
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3699
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3700
		$number = 10;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3701
		if ( isset( $struct['number'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3702
			$number = absint( $struct['number'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3703
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3704
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3705
		$comments = get_comments(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3706
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3707
				'status'    => $status,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3708
				'post_id'   => $post_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3709
				'offset'    => $offset,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3710
				'number'    => $number,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3711
				'post_type' => $post_type,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3712
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3713
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3714
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3715
		$comments_struct = array();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3716
		if ( is_array( $comments ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3717
			foreach ( $comments as $comment ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3718
				$comments_struct[] = $this->_prepare_comment( $comment );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3719
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3720
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3721
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3722
		return $comments_struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3723
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3724
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3725
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3726
	 * Deletes a comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3727
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3728
	 * By default, the comment will be moved to the Trash instead of deleted.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3729
	 * See wp_delete_comment() for more information on this behavior.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3730
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3731
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3732
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3733
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3734
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3735
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3736
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3737
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3738
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3739
	 *     @type int    $3 Comment ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3740
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3741
	 * @return bool|IXR_Error See wp_delete_comment().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3742
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3743
	public function wp_deleteComment( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3744
		$this->escape( $args );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3745
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3746
		$username   = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3747
		$password   = $args[2];
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3748
		$comment_id = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3749
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3750
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3751
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3752
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3753
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3754
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3755
		if ( ! get_comment( $comment_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3756
			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3757
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3758
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3759
		if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3760
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3761
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3762
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3763
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3764
		do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3765
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3766
		$status = wp_delete_comment( $comment_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3767
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3768
		if ( true === $status ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3769
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3770
			 * Fires after a comment has been successfully deleted via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3771
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3772
			 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3773
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3774
			 * @param int   $comment_id ID of the deleted comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3775
			 * @param array $args       An array of arguments to delete the comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3776
			 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3777
			do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3778
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3779
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3780
		return $status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3781
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3782
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3783
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3784
	 * Edits a comment.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3785
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3786
	 * Besides the common blog_id (unused), username, and password arguments,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3787
	 * it takes a comment_id integer and a content_struct array as the last argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3788
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3789
	 * The allowed keys in the content_struct array are:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3790
	 *  - 'author'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3791
	 *  - 'author_url'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3792
	 *  - 'author_email'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3793
	 *  - 'content'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3794
	 *  - 'date_created_gmt'
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3795
	 *  - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3796
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3797
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3798
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3799
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3800
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3801
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3802
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3803
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3804
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3805
	 *     @type int    $3 Comment ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3806
	 *     @type array  $4 Content structure.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3807
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3808
	 * @return true|IXR_Error True, on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3809
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3810
	public function wp_editComment( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3811
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3812
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3813
		$username       = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3814
		$password       = $args[2];
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3815
		$comment_id     = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3816
		$content_struct = $args[4];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3817
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3818
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3819
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3820
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3821
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3822
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3823
		if ( ! get_comment( $comment_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3824
			return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3825
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3826
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3827
		if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3828
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3829
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3830
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3831
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3832
		do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3833
		$comment = array(
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3834
			'comment_ID' => $comment_id,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3835
		);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3836
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3837
		if ( isset( $content_struct['status'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3838
			$statuses = get_comment_statuses();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3839
			$statuses = array_keys( $statuses );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3840
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3841
			if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3842
				return new IXR_Error( 401, __( 'Invalid comment status.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3843
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3844
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3845
			$comment['comment_approved'] = $content_struct['status'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3846
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3847
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3848
		// Do some timestamp voodoo.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3849
		if ( ! empty( $content_struct['date_created_gmt'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3850
			// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3851
			$date_created = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3852
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3853
			$comment['comment_date']     = get_date_from_gmt( $date_created );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  3854
			$comment['comment_date_gmt'] = iso8601_to_datetime( $date_created, 'gmt' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3855
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3856
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3857
		if ( isset( $content_struct['content'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3858
			$comment['comment_content'] = $content_struct['content'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3859
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3860
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3861
		if ( isset( $content_struct['author'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3862
			$comment['comment_author'] = $content_struct['author'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3863
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3864
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3865
		if ( isset( $content_struct['author_url'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3866
			$comment['comment_author_url'] = $content_struct['author_url'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3867
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3868
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3869
		if ( isset( $content_struct['author_email'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3870
			$comment['comment_author_email'] = $content_struct['author_email'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3871
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3872
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3873
		$result = wp_update_comment( $comment, true );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3874
		if ( is_wp_error( $result ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3875
			return new IXR_Error( 500, $result->get_error_message() );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3876
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3877
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3878
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3879
			return new IXR_Error( 500, __( 'Sorry, the comment could not be updated.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3880
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3881
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3882
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3883
		 * Fires after a comment has been successfully updated via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3884
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3885
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3886
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3887
		 * @param int   $comment_id ID of the updated comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3888
		 * @param array $args       An array of arguments to update the comment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3889
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3890
		do_action( 'xmlrpc_call_success_wp_editComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3891
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3892
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3893
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3894
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3895
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3896
	 * Creates a new comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3897
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3898
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3899
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3900
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3901
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3902
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3903
	 *     @type int        $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3904
	 *     @type string     $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3905
	 *     @type string     $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3906
	 *     @type string|int $3 Post ID or URL.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3907
	 *     @type array      $4 Content structure.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3908
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3909
	 * @return int|IXR_Error See wp_new_comment().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3910
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3911
	public function wp_newComment( $args ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3912
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3913
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3914
		$username       = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3915
		$password       = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3916
		$post           = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3917
		$content_struct = $args[4];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3918
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3919
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3920
		 * Filters whether to allow anonymous comments over XML-RPC.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3921
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3922
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3923
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3924
		 * @param bool $allow Whether to allow anonymous commenting via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3925
		 *                    Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3926
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3927
		$allow_anon = apply_filters( 'xmlrpc_allow_anonymous_comments', false );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3928
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3929
		$user = $this->login( $username, $password );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3930
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3931
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3932
			$logged_in = false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3933
			if ( $allow_anon && get_option( 'comment_registration' ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3934
				return new IXR_Error( 403, __( 'Sorry, you must be logged in to comment.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3935
			} elseif ( ! $allow_anon ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3936
				return $this->error;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3937
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3938
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3939
			$logged_in = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3940
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3941
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3942
		if ( is_numeric( $post ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3943
			$post_id = absint( $post );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3944
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3945
			$post_id = url_to_postid( $post );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3946
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3947
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3948
		if ( ! $post_id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3949
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3950
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3951
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3952
		if ( ! get_post( $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3953
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3954
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3955
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3956
		if ( ! comments_open( $post_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3957
			return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3958
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3959
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3960
		if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3961
			'publish' === get_post_status( $post_id ) &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3962
			! current_user_can( 'edit_post', $post_id ) &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3963
			post_password_required( $post_id )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3964
		) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3965
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3966
		}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3967
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3968
		if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3969
			'private' === get_post_status( $post_id ) &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3970
			! current_user_can( 'read_post', $post_id )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3971
		) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3972
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3973
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3974
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3975
		$comment = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3976
			'comment_post_ID' => $post_id,
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3977
			'comment_content' => trim( $content_struct['content'] ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3978
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3979
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3980
		if ( $logged_in ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3981
			$display_name = $user->display_name;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3982
			$user_email   = $user->user_email;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3983
			$user_url     = $user->user_url;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3984
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3985
			$comment['comment_author']       = $this->escape( $display_name );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3986
			$comment['comment_author_email'] = $this->escape( $user_email );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3987
			$comment['comment_author_url']   = $this->escape( $user_url );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3988
			$comment['user_id']              = $user->ID;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3989
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3990
			$comment['comment_author'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3991
			if ( isset( $content_struct['author'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3992
				$comment['comment_author'] = $content_struct['author'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3993
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3994
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3995
			$comment['comment_author_email'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3996
			if ( isset( $content_struct['author_email'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3997
				$comment['comment_author_email'] = $content_struct['author_email'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3998
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3999
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4000
			$comment['comment_author_url'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4001
			if ( isset( $content_struct['author_url'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4002
				$comment['comment_author_url'] = $content_struct['author_url'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4003
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4004
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4005
			$comment['user_id'] = 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4006
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4007
			if ( get_option( 'require_name_email' ) ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4008
				if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4009
					return new IXR_Error( 403, __( 'Comment author name and email are required.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4010
				} elseif ( ! is_email( $comment['comment_author_email'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4011
					return new IXR_Error( 403, __( 'A valid email address is required.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4012
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4013
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4014
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4015
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4016
		$comment['comment_parent'] = isset( $content_struct['comment_parent'] ) ? absint( $content_struct['comment_parent'] ) : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4017
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4018
		/** This filter is documented in wp-includes/comment.php */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4019
		$allow_empty = apply_filters( 'allow_empty_comment', false, $comment );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4020
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4021
		if ( ! $allow_empty && '' === $comment['comment_content'] ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4022
			return new IXR_Error( 403, __( 'Comment is required.' ) );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4023
		}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4024
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4025
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4026
		do_action( 'xmlrpc_call', 'wp.newComment', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4027
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4028
		$comment_id = wp_new_comment( $comment, true );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4029
		if ( is_wp_error( $comment_id ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4030
			return new IXR_Error( 403, $comment_id->get_error_message() );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4031
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4032
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4033
		if ( ! $comment_id ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  4034
			return new IXR_Error( 403, __( 'An error occurred while processing your comment. Please ensure all fields are filled correctly and try again.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4035
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4036
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4037
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4038
		 * Fires after a new comment has been successfully created via XML-RPC.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4039
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4040
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4041
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4042
		 * @param int   $comment_id ID of the new comment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4043
		 * @param array $args       An array of new comment arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4044
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4045
		do_action( 'xmlrpc_call_success_wp_newComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4046
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4047
		return $comment_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4048
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4049
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4050
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4051
	 * Retrieves all of the comment status.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4052
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4053
	 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4054
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4055
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4056
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4057
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4058
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4059
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4060
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4061
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4062
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4063
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4064
	public function wp_getCommentStatusList( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4065
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4066
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4067
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4068
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4069
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4070
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4071
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4072
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4073
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4074
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4075
		if ( ! current_user_can( 'publish_posts' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4076
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4077
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4078
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4079
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4080
		do_action( 'xmlrpc_call', 'wp.getCommentStatusList', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4081
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4082
		return get_comment_statuses();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4083
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4084
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4085
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4086
	 * Retrieves comment counts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4087
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4088
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4089
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4090
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4091
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4092
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4093
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4094
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4095
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4096
	 *     @type int    $3 Post ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4097
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4098
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4099
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4100
	public function wp_getCommentCount( $args ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4101
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4102
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4103
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4104
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4105
		$post_id  = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4106
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4107
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4108
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4109
			return $this->error;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4110
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4111
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4112
		$post = get_post( $post_id, ARRAY_A );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4113
		if ( empty( $post['ID'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4114
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4115
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4116
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4117
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4118
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details of this post.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4119
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4120
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4121
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4122
		do_action( 'xmlrpc_call', 'wp.getCommentCount', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4124
		$count = wp_count_comments( $post_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4125
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4126
		return array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4127
			'approved'            => $count->approved,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4128
			'awaiting_moderation' => $count->moderated,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4129
			'spam'                => $count->spam,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4130
			'total_comments'      => $count->total_comments,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4131
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4132
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4134
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4135
	 * Retrieves post statuses.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4136
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4137
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4138
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4139
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4140
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4141
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4142
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4143
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4144
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4145
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4146
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4147
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4148
	public function wp_getPostStatusList( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4149
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4150
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4151
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4152
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4153
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4154
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4155
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4156
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4157
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4158
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4159
		if ( ! current_user_can( 'edit_posts' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4160
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4161
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4162
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4163
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4164
		do_action( 'xmlrpc_call', 'wp.getPostStatusList', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4166
		return get_post_statuses();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4167
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4169
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4170
	 * Retrieves page statuses.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4171
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4172
	 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4173
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4174
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4175
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4176
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4177
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4178
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4179
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4180
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4181
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4182
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4183
	public function wp_getPageStatusList( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4184
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4185
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4186
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4187
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4188
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4189
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4190
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4191
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4192
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4193
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4194
		if ( ! current_user_can( 'edit_pages' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4195
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4196
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4197
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4198
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4199
		do_action( 'xmlrpc_call', 'wp.getPageStatusList', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4200
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4201
		return get_page_statuses();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4202
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4203
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4204
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4205
	 * Retrieves page templates.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4206
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4207
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4208
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4209
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4210
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4211
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4212
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4213
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4214
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4215
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4216
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4217
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4218
	public function wp_getPageTemplates( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4219
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4220
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4221
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4222
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4223
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4224
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4225
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4226
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4227
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4228
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4229
		if ( ! current_user_can( 'edit_pages' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4230
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4231
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4232
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4233
		$templates            = get_page_templates();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4234
		$templates['Default'] = 'default';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4235
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4236
		return $templates;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4237
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4239
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4240
	 * Retrieves blog options.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4241
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4242
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4243
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4244
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4245
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4246
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4247
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4248
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4249
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4250
	 *     @type array  $3 Optional. Options.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4251
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4252
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4253
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4254
	public function wp_getOptions( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4255
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4256
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4257
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4258
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4259
		$options  = isset( $args[3] ) ? (array) $args[3] : array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4260
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4261
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4262
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4263
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4264
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4265
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4266
		// If no specific options where asked for, return all of them.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4267
		if ( count( $options ) === 0 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4268
			$options = array_keys( $this->blog_options );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4269
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4270
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4271
		return $this->_getOptions( $options );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4272
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4273
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4274
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4275
	 * Retrieves blog options value from list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4276
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4277
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4278
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4279
	 * @param array $options Options to retrieve.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4280
	 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4281
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4282
	public function _getOptions( $options ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4283
		$data       = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4284
		$can_manage = current_user_can( 'manage_options' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4285
		foreach ( $options as $option ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4286
			if ( array_key_exists( $option, $this->blog_options ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4287
				$data[ $option ] = $this->blog_options[ $option ];
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4288
				// Is the value static or dynamic?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4289
				if ( isset( $data[ $option ]['option'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4290
					$data[ $option ]['value'] = get_option( $data[ $option ]['option'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4291
					unset( $data[ $option ]['option'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4292
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4293
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4294
				if ( ! $can_manage ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4295
					$data[ $option ]['readonly'] = true;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4296
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4297
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4298
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4300
		return $data;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4301
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4302
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4303
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4304
	 * Updates blog options.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4305
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4306
	 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4307
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4308
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4309
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4310
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4311
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4312
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4313
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4314
	 *     @type array  $3 Options.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4315
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4316
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4317
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4318
	public function wp_setOptions( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4319
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4320
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4321
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4322
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4323
		$options  = (array) $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4324
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4325
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4326
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4327
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4328
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4329
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4330
		if ( ! current_user_can( 'manage_options' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4331
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to update options.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4332
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4333
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4334
		$option_names = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4335
		foreach ( $options as $o_name => $o_value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4336
			$option_names[] = $o_name;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4337
			if ( ! array_key_exists( $o_name, $this->blog_options ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4338
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4339
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4340
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  4341
			if ( $this->blog_options[ $o_name ]['readonly'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4342
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4343
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4344
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4345
			update_option( $this->blog_options[ $o_name ]['option'], wp_unslash( $o_value ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4346
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4347
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4348
		// Now return the updated values.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4349
		return $this->_getOptions( $option_names );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4350
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4351
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4352
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4353
	 * Retrieves a media item by ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4354
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4355
	 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4356
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4357
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4358
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4359
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4360
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4361
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4362
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4363
	 *     @type int    $3 Attachment ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4364
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4365
	 * @return array|IXR_Error Associative array contains:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4366
	 *  - 'date_created_gmt'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4367
	 *  - 'parent'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4368
	 *  - 'link'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4369
	 *  - 'thumbnail'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4370
	 *  - 'title'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4371
	 *  - 'caption'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4372
	 *  - 'description'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4373
	 *  - 'metadata'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4374
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4375
	public function wp_getMediaItem( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4376
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4377
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4378
		$username      = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4379
		$password      = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4380
		$attachment_id = (int) $args[3];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4381
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4382
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4383
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4384
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4385
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4386
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4387
		if ( ! current_user_can( 'upload_files' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4388
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to upload files.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4389
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4390
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4391
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4392
		do_action( 'xmlrpc_call', 'wp.getMediaItem', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4393
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4394
		$attachment = get_post( $attachment_id );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4395
		if ( ! $attachment || 'attachment' !== $attachment->post_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4396
			return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4397
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4398
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4399
		return $this->_prepare_media_item( $attachment );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4400
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4401
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4402
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4403
	 * Retrieves a collection of media library items (or attachments).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4404
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4405
	 * Besides the common blog_id (unused), username, and password arguments,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4406
	 * it takes a filter array as the last argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4407
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4408
	 * Accepted 'filter' keys are 'parent_id', 'mime_type', 'offset', and 'number'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4409
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4410
	 * The defaults are as follows:
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4411
	 * - 'number'    - Default is 5. Total number of media items to retrieve.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4412
	 * - 'offset'    - Default is 0. See WP_Query::query() for more.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4413
	 * - 'parent_id' - Default is ''. The post where the media item is attached.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4414
	 *                 Empty string shows all media items. 0 shows unattached media items.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4415
	 * - 'mime_type' - Default is ''. Filter by mime type (e.g., 'image/jpeg', 'application/pdf')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4416
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4417
	 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4418
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4419
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4420
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4421
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4422
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4423
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4424
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4425
	 *     @type array  $3 Optional. Query arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4426
	 * }
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4427
	 * @return array|IXR_Error Array containing a collection of media items.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4428
	 *                         See wp_xmlrpc_server::wp_getMediaItem() for a description
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4429
	 *                         of each item contents.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4430
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4431
	public function wp_getMediaLibrary( $args ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4432
		$this->escape( $args );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4433
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4434
		$username = $args[1];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4435
		$password = $args[2];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4436
		$struct   = isset( $args[3] ) ? $args[3] : array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4437
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4438
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4439
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4440
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4441
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4442
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4443
		if ( ! current_user_can( 'upload_files' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4444
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4445
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4446
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4447
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4448
		do_action( 'xmlrpc_call', 'wp.getMediaLibrary', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4449
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4450
		$parent_id = ( isset( $struct['parent_id'] ) ) ? absint( $struct['parent_id'] ) : '';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4451
		$mime_type = ( isset( $struct['mime_type'] ) ) ? $struct['mime_type'] : '';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4452
		$offset    = ( isset( $struct['offset'] ) ) ? absint( $struct['offset'] ) : 0;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4453
		$number    = ( isset( $struct['number'] ) ) ? absint( $struct['number'] ) : -1;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4454
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4455
		$attachments = get_posts(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4456
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4457
				'post_type'      => 'attachment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4458
				'post_parent'    => $parent_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4459
				'offset'         => $offset,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4460
				'numberposts'    => $number,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4461
				'post_mime_type' => $mime_type,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4462
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4463
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4464
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4465
		$attachments_struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4466
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4467
		foreach ( $attachments as $attachment ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4468
			$attachments_struct[] = $this->_prepare_media_item( $attachment );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4469
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4470
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4471
		return $attachments_struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4472
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4473
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4474
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4475
	 * Retrieves a list of post formats used by the site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4476
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4477
	 * @since 3.1.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4478
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4479
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4480
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4481
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4482
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4483
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4484
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4485
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4486
	 * @return array|IXR_Error List of post formats, otherwise IXR_Error object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4487
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4488
	public function wp_getPostFormats( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4489
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4490
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4491
		$username = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4492
		$password = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4493
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4494
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4495
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4496
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4497
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4498
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4499
		if ( ! current_user_can( 'edit_posts' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4500
			return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4501
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4502
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4503
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4504
		do_action( 'xmlrpc_call', 'wp.getPostFormats', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4505
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4506
		$formats = get_post_format_strings();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4507
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4508
		// Find out if they want a list of currently supports formats.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4509
		if ( isset( $args[3] ) && is_array( $args[3] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4510
			if ( $args[3]['show-supported'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4511
				if ( current_theme_supports( 'post-formats' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4512
					$supported = get_theme_support( 'post-formats' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4513
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4514
					$data              = array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4515
					$data['all']       = $formats;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4516
					$data['supported'] = $supported[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4517
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4518
					$formats = $data;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4519
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4520
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4521
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4522
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4523
		return $formats;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4524
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4525
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4526
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4527
	 * Retrieves a post type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4528
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4529
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4530
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4531
	 * @see get_post_type_object()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4532
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4533
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4534
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4535
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4536
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4537
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4538
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4539
	 *     @type string $3 Post type name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4540
	 *     @type array  $4 Optional. Fields to fetch.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4541
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4542
	 * @return array|IXR_Error Array contains:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4543
	 *  - 'labels'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4544
	 *  - 'description'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4545
	 *  - 'capability_type'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4546
	 *  - 'cap'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4547
	 *  - 'map_meta_cap'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4548
	 *  - 'hierarchical'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4549
	 *  - 'menu_position'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4550
	 *  - 'taxonomies'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4551
	 *  - 'supports'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4552
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4553
	public function wp_getPostType( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4554
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4555
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4556
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4557
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4558
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4559
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4560
		$username       = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4561
		$password       = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4562
		$post_type_name = $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4563
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4564
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4565
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4566
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4567
			/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4568
			 * Filters the default post type query fields used by the given XML-RPC method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4569
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4570
			 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4571
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4572
			 * @param array  $fields An array of post type fields to retrieve. By default,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4573
			 *                       contains 'labels', 'cap', and 'taxonomies'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4574
			 * @param string $method The method name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4575
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4576
			$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostType' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4577
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4578
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4579
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4580
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4581
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4582
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4583
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4584
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4585
		do_action( 'xmlrpc_call', 'wp.getPostType', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4586
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4587
		if ( ! post_type_exists( $post_type_name ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4588
			return new IXR_Error( 403, __( 'Invalid post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4589
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4590
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4591
		$post_type = get_post_type_object( $post_type_name );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4592
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4593
		if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4594
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4595
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4596
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4597
		return $this->_prepare_post_type( $post_type, $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4598
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4599
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4600
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4601
	 * Retrieves post types.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4602
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4603
	 * @since 3.4.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4604
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4605
	 * @see get_post_types()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4606
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4607
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4608
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4609
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4610
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4611
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4612
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4613
	 *     @type array  $3 Optional. Query arguments.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4614
	 *     @type array  $4 Optional. Fields to fetch.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4615
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4616
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4617
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4618
	public function wp_getPostTypes( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4619
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4620
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4621
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4622
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4623
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4624
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4625
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4626
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4627
		$filter   = isset( $args[3] ) ? $args[3] : array( 'public' => true );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4628
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4629
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4630
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4631
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4632
			/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4633
			$fields = apply_filters( 'xmlrpc_default_posttype_fields', array( 'labels', 'cap', 'taxonomies' ), 'wp.getPostTypes' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4634
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4635
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4636
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4637
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4638
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4639
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4640
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4641
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4642
		do_action( 'xmlrpc_call', 'wp.getPostTypes', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4643
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4644
		$post_types = get_post_types( $filter, 'objects' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4645
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4646
		$struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4647
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4648
		foreach ( $post_types as $post_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4649
			if ( ! current_user_can( $post_type->cap->edit_posts ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4650
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4651
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4652
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4653
			$struct[ $post_type->name ] = $this->_prepare_post_type( $post_type, $fields );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4654
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4655
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4656
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4657
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4658
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4659
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4660
	 * Retrieves revisions for a specific post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4661
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4662
	 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4663
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4664
	 * The optional $fields parameter specifies what fields will be included
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4665
	 * in the response array.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4666
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4667
	 * @uses wp_get_post_revisions()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4668
	 * @see wp_getPost() for more on $fields
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4669
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4670
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4671
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4672
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4673
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4674
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4675
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4676
	 *     @type int    $3 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4677
	 *     @type array  $4 Optional. Fields to fetch.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4678
	 * }
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4679
	 * @return array|IXR_Error Array containing a collection of posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4680
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4681
	public function wp_getRevisions( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4682
		if ( ! $this->minimum_args( $args, 4 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4683
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4684
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4685
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4686
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4687
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4688
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4689
		$password = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4690
		$post_id  = (int) $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4691
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4692
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4693
			$fields = $args[4];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4694
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4695
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4696
			 * Filters the default revision query fields used by the given XML-RPC method.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4697
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4698
			 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4699
			 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4700
			 * @param array  $field  An array of revision fields to retrieve. By default,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4701
			 *                       contains 'post_date' and 'post_date_gmt'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4702
			 * @param string $method The method name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4703
			 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4704
			$fields = apply_filters( 'xmlrpc_default_revision_fields', array( 'post_date', 'post_date_gmt' ), 'wp.getRevisions' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4705
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4706
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4707
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4708
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4709
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4710
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4711
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4712
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4713
		do_action( 'xmlrpc_call', 'wp.getRevisions', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4714
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4715
		$post = get_post( $post_id );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4716
		if ( ! $post ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4717
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4718
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4719
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4720
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4721
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4722
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4723
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4724
		// Check if revisions are enabled.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4725
		if ( ! wp_revisions_enabled( $post ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4726
			return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4727
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4728
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4729
		$revisions = wp_get_post_revisions( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4730
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4731
		if ( ! $revisions ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4732
			return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4733
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4734
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4735
		$struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4736
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4737
		foreach ( $revisions as $revision ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4738
			if ( ! current_user_can( 'read_post', $revision->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4739
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4740
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4741
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4742
			// Skip autosaves.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4743
			if ( wp_is_post_autosave( $revision ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4744
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4745
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4746
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4747
			$struct[] = $this->_prepare_post( get_object_vars( $revision ), $fields );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4748
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4749
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4750
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4751
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4752
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4753
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4754
	 * Restores a post revision.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4755
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4756
	 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4757
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4758
	 * @uses wp_restore_post_revision()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4759
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4760
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4761
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4762
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4763
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4764
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4765
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4766
	 *     @type int    $3 Revision ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4767
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4768
	 * @return bool|IXR_Error false if there was an error restoring, true if success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4769
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4770
	public function wp_restoreRevision( $args ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4771
		if ( ! $this->minimum_args( $args, 3 ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4772
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4773
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4774
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4775
		$this->escape( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4776
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4777
		$username    = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4778
		$password    = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4779
		$revision_id = (int) $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4780
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4781
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4782
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4783
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4784
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4785
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4786
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4787
		do_action( 'xmlrpc_call', 'wp.restoreRevision', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4788
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4789
		$revision = wp_get_post_revision( $revision_id );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4790
		if ( ! $revision ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4791
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4792
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4793
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4794
		if ( wp_is_post_autosave( $revision ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4795
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4796
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4797
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4798
		$post = get_post( $revision->post_parent );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4799
		if ( ! $post ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4800
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4801
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4802
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4803
		if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4804
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4805
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4806
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4807
		// Check if revisions are disabled.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4808
		if ( ! wp_revisions_enabled( $post ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4809
			return new IXR_Error( 401, __( 'Sorry, revisions are disabled.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4810
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4811
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4812
		$post = wp_restore_post_revision( $revision_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4813
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4814
		return (bool) $post;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4815
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4816
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4817
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4818
	 * Blogger API functions.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4819
	 * Specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4820
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4821
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4822
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4823
	 * Retrieves blogs that user owns.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4824
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4825
	 * Will make more sense once we support multiple blogs.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4826
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4827
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4828
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4829
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4830
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4831
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4832
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4833
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4834
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4835
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4836
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4837
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4838
	public function blogger_getUsersBlogs( $args ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4839
		if ( ! $this->minimum_args( $args, 3 ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4840
			return $this->error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4841
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4842
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4843
		if ( is_multisite() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4844
			return $this->_multisite_getUsersBlogs( $args );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4845
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4846
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4847
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4848
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4849
		$username = $args[1];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4850
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4851
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4852
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4853
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4854
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4855
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4856
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4857
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4858
		do_action( 'xmlrpc_call', 'blogger.getUsersBlogs', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4859
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4860
		$is_admin = current_user_can( 'manage_options' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4861
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4862
		$struct = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4863
			'isAdmin'  => $is_admin,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4864
			'url'      => get_option( 'home' ) . '/',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4865
			'blogid'   => '1',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4866
			'blogName' => get_option( 'blogname' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4867
			'xmlrpc'   => site_url( 'xmlrpc.php', 'rpc' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4868
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4869
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4870
		return array( $struct );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4871
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4872
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4873
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4874
	 * Private function for retrieving a users blogs for multisite setups.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4875
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4876
	 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4877
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4878
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4879
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4880
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4881
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4882
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4883
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4884
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4885
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4886
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4887
	protected function _multisite_getUsersBlogs( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4888
		$current_blog = get_site();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4889
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4890
		$domain = $current_blog->domain;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4891
		$path   = $current_blog->path . 'xmlrpc.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4892
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4893
		$blogs = $this->wp_getUsersBlogs( $args );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4894
		if ( $blogs instanceof IXR_Error ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4895
			return $blogs;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4896
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4897
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  4898
		if ( $_SERVER['HTTP_HOST'] === $domain && $_SERVER['REQUEST_URI'] === $path ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4899
			return $blogs;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4900
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4901
			foreach ( (array) $blogs as $blog ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4902
				if ( str_contains( $blog['url'], $_SERVER['HTTP_HOST'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4903
					return array( $blog );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4904
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4905
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4906
			return array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4907
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4908
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4909
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4910
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4911
	 * Retrieves user's data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4912
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4913
	 * Gives your client some info about you, so you don't have to.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4914
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4915
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4916
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4917
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4918
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4919
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4920
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4921
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4922
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4923
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4924
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4925
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4926
	public function blogger_getUserInfo( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4927
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4928
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4929
		$username = $args[1];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4930
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4931
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4932
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4933
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4934
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4935
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4936
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4937
		if ( ! current_user_can( 'edit_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4938
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to access user data on this site.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4939
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4940
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4941
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4942
		do_action( 'xmlrpc_call', 'blogger.getUserInfo', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4943
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4944
		$struct = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4945
			'nickname'  => $user->nickname,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4946
			'userid'    => $user->ID,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4947
			'url'       => $user->user_url,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4948
			'lastname'  => $user->last_name,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4949
			'firstname' => $user->first_name,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4950
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4951
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4952
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4953
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4954
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4955
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4956
	 * Retrieves a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4957
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4958
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4959
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4960
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4961
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4962
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4963
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4964
	 *     @type int    $1 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4965
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4966
	 *     @type string $3 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4967
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4968
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4969
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4970
	public function blogger_getPost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4971
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4972
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4973
		$post_id  = (int) $args[1];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4974
		$username = $args[2];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4975
		$password = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4976
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4977
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4978
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4979
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4980
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4981
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4982
		$post_data = get_post( $post_id, ARRAY_A );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4983
		if ( ! $post_data ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4984
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4985
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4986
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4987
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4988
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4989
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4990
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4991
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4992
		do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4993
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4994
		$categories = implode( ',', wp_get_post_categories( $post_id ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4995
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4996
		$content  = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4997
		$content .= '<category>' . $categories . '</category>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4998
		$content .= wp_unslash( $post_data['post_content'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4999
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5000
		$struct = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5001
			'userid'      => $post_data['post_author'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5002
			'dateCreated' => $this->_convert_date( $post_data['post_date'] ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5003
			'content'     => $content,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5004
			'postid'      => (string) $post_data['ID'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5005
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5006
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5007
		return $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5008
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5009
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5010
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5011
	 * Retrieves the list of recent posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5012
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5013
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5014
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5015
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5016
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5017
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5018
	 *     @type string $0 App key (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5019
	 *     @type int    $1 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5020
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5021
	 *     @type string $3 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5022
	 *     @type int    $4 Optional. Number of posts.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5023
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5024
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5025
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5026
	public function blogger_getRecentPosts( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5027
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5028
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5029
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5030
		// $args[0] = appkey - ignored.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5031
		$username = $args[2];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5032
		$password = $args[3];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5033
		if ( isset( $args[4] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5034
			$query = array( 'numberposts' => absint( $args[4] ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5035
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5036
			$query = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5037
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5038
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5039
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5040
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5041
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5042
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5043
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5044
		if ( ! current_user_can( 'edit_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5045
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5046
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5047
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5048
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5049
		do_action( 'xmlrpc_call', 'blogger.getRecentPosts', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5050
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5051
		$posts_list = wp_get_recent_posts( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5052
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5053
		if ( ! $posts_list ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5054
			$this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5055
			return $this->error;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5056
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5057
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5058
		$recent_posts = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5059
		foreach ( $posts_list as $entry ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5060
			if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5061
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5062
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5063
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5064
			$post_date  = $this->_convert_date( $entry['post_date'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5065
			$categories = implode( ',', wp_get_post_categories( $entry['ID'] ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5066
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5067
			$content  = '<title>' . wp_unslash( $entry['post_title'] ) . '</title>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5068
			$content .= '<category>' . $categories . '</category>';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5069
			$content .= wp_unslash( $entry['post_content'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5070
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5071
			$recent_posts[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5072
				'userid'      => $entry['post_author'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5073
				'dateCreated' => $post_date,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5074
				'content'     => $content,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5075
				'postid'      => (string) $entry['ID'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5076
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5077
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5078
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5079
		return $recent_posts;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5080
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5081
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5082
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5083
	 * Deprecated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5084
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5085
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5086
	 * @deprecated 3.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5087
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5088
	 * @param array $args Unused.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5089
	 * @return IXR_Error Error object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5090
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5091
	public function blogger_getTemplate( $args ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5092
		return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5093
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5094
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5095
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5096
	 * Deprecated.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5097
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5098
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5099
	 * @deprecated 3.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5100
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5101
	 * @param array $args Unused.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5102
	 * @return IXR_Error Error object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5103
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5104
	public function blogger_setTemplate( $args ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5105
		return new IXR_Error( 403, __( 'Sorry, this method is not supported.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5106
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5108
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5109
	 * Creates a new post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5110
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5111
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5112
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5113
	 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5114
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5115
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5116
	 *     @type string $0 App key (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5117
	 *     @type int    $1 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5118
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5119
	 *     @type string $3 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5120
	 *     @type string $4 Content.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5121
	 *     @type int    $5 Publish flag. 0 for draft, 1 for publish.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5122
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5123
	 * @return int|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5124
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5125
	public function blogger_newPost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5126
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5128
		$username = $args[2];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5129
		$password = $args[3];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5130
		$content  = $args[4];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5131
		$publish  = $args[5];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5132
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5133
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5134
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5135
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5136
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5137
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5138
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5139
		do_action( 'xmlrpc_call', 'blogger.newPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5140
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5141
		$cap = ( $publish ) ? 'publish_posts' : 'edit_posts';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5142
		if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) || ! current_user_can( $cap ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5143
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5144
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5145
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5146
		$post_status = ( $publish ) ? 'publish' : 'draft';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5148
		$post_author = $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5149
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5150
		$post_title    = xmlrpc_getposttitle( $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5151
		$post_category = xmlrpc_getpostcategory( $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5152
		$post_content  = xmlrpc_removepostdata( $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5153
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5154
		$post_date     = current_time( 'mysql' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5155
		$post_date_gmt = current_time( 'mysql', 1 );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5156
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5157
		$post_data = compact(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5158
			'post_author',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5159
			'post_date',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5160
			'post_date_gmt',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5161
			'post_content',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5162
			'post_title',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5163
			'post_category',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5164
			'post_status'
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5165
		);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5166
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5167
		$post_id = wp_insert_post( $post_data );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5168
		if ( is_wp_error( $post_id ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5169
			return new IXR_Error( 500, $post_id->get_error_message() );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5170
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5171
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5172
		if ( ! $post_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5173
			return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5174
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5175
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5176
		$this->attach_uploads( $post_id, $post_content );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5177
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5178
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5179
		 * Fires after a new post has been successfully created via the XML-RPC Blogger API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5180
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5181
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5182
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5183
		 * @param int   $post_id ID of the new post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5184
		 * @param array $args    An array of new post arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5185
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5186
		do_action( 'xmlrpc_call_success_blogger_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5187
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5188
		return $post_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5189
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5190
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5191
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5192
	 * Edits a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5193
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5194
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5195
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5196
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5197
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5198
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5199
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5200
	 *     @type int    $1 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5201
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5202
	 *     @type string $3 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5203
	 *     @type string $4 Content
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5204
	 *     @type int    $5 Publish flag. 0 for draft, 1 for publish.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5205
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5206
	 * @return true|IXR_Error true when done.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5207
	 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5208
	public function blogger_editPost( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5209
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5210
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5211
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5212
		$post_id  = (int) $args[1];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5213
		$username = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5214
		$password = $args[3];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5215
		$content  = $args[4];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5216
		$publish  = $args[5];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5217
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5218
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5219
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5220
			return $this->error;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5221
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5222
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5223
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5224
		do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5225
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5226
		$actual_post = get_post( $post_id, ARRAY_A );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5227
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5228
		if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5229
			return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5230
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5231
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5232
		$this->escape( $actual_post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5233
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5234
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5235
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5236
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5237
		if ( 'publish' === $actual_post['post_status'] && ! current_user_can( 'publish_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5238
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5239
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5240
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5241
		$postdata                  = array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5242
		$postdata['ID']            = $actual_post['ID'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5243
		$postdata['post_content']  = xmlrpc_removepostdata( $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5244
		$postdata['post_title']    = xmlrpc_getposttitle( $content );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5245
		$postdata['post_category'] = xmlrpc_getpostcategory( $content );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5246
		$postdata['post_status']   = $actual_post['post_status'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5247
		$postdata['post_excerpt']  = $actual_post['post_excerpt'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5248
		$postdata['post_status']   = $publish ? 'publish' : 'draft';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5249
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5250
		$result = wp_update_post( $postdata );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5251
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5252
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5253
			return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5254
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5255
		$this->attach_uploads( $actual_post['ID'], $postdata['post_content'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5256
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5257
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5258
		 * Fires after a post has been successfully updated via the XML-RPC Blogger API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5259
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5260
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5261
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5262
		 * @param int   $post_id ID of the updated post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5263
		 * @param array $args    An array of arguments for the post to edit.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5264
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5265
		do_action( 'xmlrpc_call_success_blogger_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5266
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5267
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5268
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5269
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5270
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5271
	 * Deletes a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5272
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5273
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5274
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5275
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5276
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5277
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5278
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5279
	 *     @type int    $1 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5280
	 *     @type string $2 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5281
	 *     @type string $3 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5282
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5283
	 * @return true|IXR_Error True when post is deleted.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5284
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5285
	public function blogger_deletePost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5286
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5287
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5288
		$post_id  = (int) $args[1];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5289
		$username = $args[2];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5290
		$password = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5291
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5292
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5293
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5294
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5295
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5296
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5297
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5298
		do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5299
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5300
		$actual_post = get_post( $post_id, ARRAY_A );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5301
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5302
		if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5303
			return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5304
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5305
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5306
		if ( ! current_user_can( 'delete_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5307
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5308
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5309
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5310
		$result = wp_delete_post( $post_id );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5311
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5312
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5313
			return new IXR_Error( 500, __( 'Sorry, the post could not be deleted.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5314
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5315
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5316
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5317
		 * Fires after a post has been successfully deleted via the XML-RPC Blogger API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5318
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5319
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5320
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5321
		 * @param int   $post_id ID of the deleted post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5322
		 * @param array $args    An array of arguments to delete the post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5323
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5324
		do_action( 'xmlrpc_call_success_blogger_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5325
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5326
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5327
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5328
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5329
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5330
	 * MetaWeblog API functions.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5331
	 * Specs on wherever Dave Winer wants them to be.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5332
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5333
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5334
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5335
	 * Creates a new post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5336
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5337
	 * The 'content_struct' argument must contain:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5338
	 *  - title
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5339
	 *  - description
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5340
	 *  - mt_excerpt
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5341
	 *  - mt_text_more
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5342
	 *  - mt_keywords
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5343
	 *  - mt_tb_ping_urls
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5344
	 *  - categories
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5345
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5346
	 * Also, it can optionally contain:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5347
	 *  - wp_slug
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5348
	 *  - wp_password
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5349
	 *  - wp_page_parent_id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5350
	 *  - wp_page_order
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5351
	 *  - wp_author_id
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5352
	 *  - post_status | page_status - can be 'draft', 'private', 'publish', or 'pending'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5353
	 *  - mt_allow_comments - can be 'open' or 'closed'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5354
	 *  - mt_allow_pings - can be 'open' or 'closed'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5355
	 *  - date_created_gmt
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5356
	 *  - dateCreated
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5357
	 *  - wp_post_thumbnail
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5358
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5359
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5360
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5361
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5362
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5363
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5364
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5365
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5366
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5367
	 *     @type array  $3 Content structure.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5368
	 *     @type int    $4 Optional. Publish flag. 0 for draft, 1 for publish. Default 0.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5369
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5370
	 * @return int|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5371
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5372
	public function mw_newPost( $args ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5373
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5374
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5375
		$username       = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5376
		$password       = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5377
		$content_struct = $args[3];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5378
		$publish        = isset( $args[4] ) ? $args[4] : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5379
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5380
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5381
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5382
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5383
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5384
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5385
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5386
		do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5387
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5388
		$page_template = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5389
		if ( ! empty( $content_struct['post_type'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5390
			if ( 'page' === $content_struct['post_type'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5391
				if ( $publish ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5392
					$cap = 'publish_pages';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5393
				} elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5394
					$cap = 'publish_pages';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5395
				} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5396
					$cap = 'edit_pages';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5397
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5398
				$error_message = __( 'Sorry, you are not allowed to publish pages on this site.' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5399
				$post_type     = 'page';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5400
				if ( ! empty( $content_struct['wp_page_template'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5401
					$page_template = $content_struct['wp_page_template'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5402
				}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5403
			} elseif ( 'post' === $content_struct['post_type'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5404
				if ( $publish ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5405
					$cap = 'publish_posts';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5406
				} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5407
					$cap = 'publish_posts';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5408
				} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5409
					$cap = 'edit_posts';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5410
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5411
				$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5412
				$post_type     = 'post';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5413
			} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5414
				// No other 'post_type' values are allowed here.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5415
				return new IXR_Error( 401, __( 'Invalid post type.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5416
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5417
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5418
			if ( $publish ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5419
				$cap = 'publish_posts';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5420
			} elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5421
				$cap = 'publish_posts';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5422
			} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5423
				$cap = 'edit_posts';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5424
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5425
			$error_message = __( 'Sorry, you are not allowed to publish posts on this site.' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5426
			$post_type     = 'post';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5427
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5428
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5429
		if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5430
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5431
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5432
		if ( ! current_user_can( $cap ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5433
			return new IXR_Error( 401, $error_message );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5434
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5435
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5436
		// Check for a valid post format if one was given.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5437
		if ( isset( $content_struct['wp_post_format'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5438
			$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5439
			if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5440
				return new IXR_Error( 404, __( 'Invalid post format.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5441
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5442
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5443
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5444
		// Let WordPress generate the 'post_name' (slug) unless
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5445
		// one has been provided.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5446
		$post_name = null;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5447
		if ( isset( $content_struct['wp_slug'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5448
			$post_name = $content_struct['wp_slug'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5449
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5451
		// Only use a password if one was given.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5452
		$post_password = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5453
		if ( isset( $content_struct['wp_password'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5454
			$post_password = $content_struct['wp_password'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5455
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5456
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5457
		// Only set a post parent if one was given.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5458
		$post_parent = 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5459
		if ( isset( $content_struct['wp_page_parent_id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5460
			$post_parent = $content_struct['wp_page_parent_id'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5461
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5462
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5463
		// Only set the 'menu_order' if it was given.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5464
		$menu_order = 0;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5465
		if ( isset( $content_struct['wp_page_order'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5466
			$menu_order = $content_struct['wp_page_order'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5467
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5468
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5469
		$post_author = $user->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5470
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5471
		// If an author ID was provided then use it instead.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5472
		if ( isset( $content_struct['wp_author_id'] ) && ( $user->ID !== (int) $content_struct['wp_author_id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5473
			switch ( $post_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5474
				case 'post':
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5475
					if ( ! current_user_can( 'edit_others_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5476
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to create posts as this user.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5477
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5478
					break;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5479
				case 'page':
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5480
					if ( ! current_user_can( 'edit_others_pages' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5481
						return new IXR_Error( 401, __( 'Sorry, you are not allowed to create pages as this user.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5482
					}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5483
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5484
				default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5485
					return new IXR_Error( 401, __( 'Invalid post type.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5486
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5487
			$author = get_userdata( $content_struct['wp_author_id'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5488
			if ( ! $author ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5489
				return new IXR_Error( 404, __( 'Invalid author ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5490
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5491
			$post_author = $content_struct['wp_author_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5492
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5493
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5494
		$post_title   = isset( $content_struct['title'] ) ? $content_struct['title'] : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5495
		$post_content = isset( $content_struct['description'] ) ? $content_struct['description'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5496
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5497
		$post_status = $publish ? 'publish' : 'draft';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5498
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5499
		if ( isset( $content_struct[ "{$post_type}_status" ] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5500
			switch ( $content_struct[ "{$post_type}_status" ] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5501
				case 'draft':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5502
				case 'pending':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5503
				case 'private':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5504
				case 'publish':
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5505
					$post_status = $content_struct[ "{$post_type}_status" ];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5506
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5507
				default:
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5508
					// Deliberably left empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5509
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5510
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5511
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5512
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5513
		$post_excerpt = isset( $content_struct['mt_excerpt'] ) ? $content_struct['mt_excerpt'] : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5514
		$post_more    = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5515
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5516
		$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5517
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5518
		if ( isset( $content_struct['mt_allow_comments'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5519
			if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5520
				switch ( $content_struct['mt_allow_comments'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5521
					case 'closed':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5522
						$comment_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5523
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5524
					case 'open':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5525
						$comment_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5526
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5527
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5528
						$comment_status = get_default_comment_status( $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5529
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5530
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5531
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5532
				switch ( (int) $content_struct['mt_allow_comments'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5533
					case 0:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5534
					case 2:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5535
						$comment_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5536
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5537
					case 1:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5538
						$comment_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5539
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5540
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5541
						$comment_status = get_default_comment_status( $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5542
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5543
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5544
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5545
		} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5546
			$comment_status = get_default_comment_status( $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5547
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5548
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5549
		if ( isset( $content_struct['mt_allow_pings'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5550
			if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5551
				switch ( $content_struct['mt_allow_pings'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5552
					case 'closed':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5553
						$ping_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5554
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5555
					case 'open':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5556
						$ping_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5557
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5558
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5559
						$ping_status = get_default_comment_status( $post_type, 'pingback' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5560
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5561
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5562
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5563
				switch ( (int) $content_struct['mt_allow_pings'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5564
					case 0:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5565
						$ping_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5566
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5567
					case 1:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5568
						$ping_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5569
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5570
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5571
						$ping_status = get_default_comment_status( $post_type, 'pingback' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5572
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5573
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5574
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5575
		} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5576
			$ping_status = get_default_comment_status( $post_type, 'pingback' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5577
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5578
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5579
		if ( $post_more ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5580
			$post_content .= '<!--more-->' . $post_more;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5581
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5582
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5583
		$to_ping = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5584
		if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5585
			$to_ping = $content_struct['mt_tb_ping_urls'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5586
			if ( is_array( $to_ping ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5587
				$to_ping = implode( ' ', $to_ping );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5588
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5589
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5590
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5591
		// Do some timestamp voodoo.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5592
		if ( ! empty( $content_struct['date_created_gmt'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5593
			// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5594
			$date_created = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5595
		} elseif ( ! empty( $content_struct['dateCreated'] ) ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5596
			$date_created = $content_struct['dateCreated']->getIso();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5597
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5598
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5599
		$post_date     = '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5600
		$post_date_gmt = '';
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5601
		if ( ! empty( $date_created ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5602
			$post_date     = iso8601_to_datetime( $date_created );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5603
			$post_date_gmt = iso8601_to_datetime( $date_created, 'gmt' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5604
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5605
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5606
		$post_category = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5607
		if ( isset( $content_struct['categories'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5608
			$catnames = $content_struct['categories'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5609
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5610
			if ( is_array( $catnames ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5611
				foreach ( $catnames as $cat ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5612
					$post_category[] = get_cat_ID( $cat );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5613
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5614
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5615
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5616
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5617
		$postdata = compact(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5618
			'post_author',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5619
			'post_date',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5620
			'post_date_gmt',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5621
			'post_content',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5622
			'post_title',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5623
			'post_category',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5624
			'post_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5625
			'post_excerpt',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5626
			'comment_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5627
			'ping_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5628
			'to_ping',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5629
			'post_type',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5630
			'post_name',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5631
			'post_password',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5632
			'post_parent',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5633
			'menu_order',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5634
			'tags_input',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5635
			'page_template'
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5636
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5637
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5638
		$post_id        = get_default_post_to_edit( $post_type, true )->ID;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5639
		$postdata['ID'] = $post_id;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5640
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5641
		// Only posts can be sticky.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5642
		if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5643
			$data           = $postdata;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5644
			$data['sticky'] = $content_struct['sticky'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5645
			$error          = $this->_toggle_sticky( $data );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5646
			if ( $error ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5647
				return $error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5648
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5649
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5650
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5651
		if ( isset( $content_struct['custom_fields'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5652
			$this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5653
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5654
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5655
		if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5656
			if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5657
				return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5658
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5659
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5660
			unset( $content_struct['wp_post_thumbnail'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5661
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5662
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5663
		// Handle enclosures.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5664
		$enclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5665
		$this->add_enclosure_if_new( $post_id, $enclosure );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5666
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5667
		$this->attach_uploads( $post_id, $post_content );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5668
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5669
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5670
		 * Handle post formats if assigned, value is validated earlier
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5671
		 * in this function.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5672
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5673
		if ( isset( $content_struct['wp_post_format'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5674
			set_post_format( $post_id, $content_struct['wp_post_format'] );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5675
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5676
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5677
		$post_id = wp_insert_post( $postdata, true );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5678
		if ( is_wp_error( $post_id ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5679
			return new IXR_Error( 500, $post_id->get_error_message() );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5680
		}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5681
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5682
		if ( ! $post_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5683
			return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5684
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5685
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5686
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5687
		 * Fires after a new post has been successfully created via the XML-RPC MovableType API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5688
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5689
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5690
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5691
		 * @param int   $post_id ID of the new post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5692
		 * @param array $args    An array of arguments to create the new post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5693
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5694
		do_action( 'xmlrpc_call_success_mw_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5695
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5696
		return (string) $post_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5697
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5698
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5699
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5700
	 * Adds an enclosure to a post if it's new.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5701
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5702
	 * @since 2.8.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5703
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5704
	 * @param int   $post_id   Post ID.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5705
	 * @param array $enclosure Enclosure data.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5706
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5707
	public function add_enclosure_if_new( $post_id, $enclosure ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5708
		if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5709
			$encstring  = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5710
			$found      = false;
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5711
			$enclosures = get_post_meta( $post_id, 'enclosure' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5712
			if ( $enclosures ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5713
				foreach ( $enclosures as $enc ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5714
					// This method used to omit the trailing new line. #23219
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5715
					if ( rtrim( $enc, "\n" ) === rtrim( $encstring, "\n" ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5716
						$found = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5717
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5718
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5719
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5720
			}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5721
			if ( ! $found ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5722
				add_post_meta( $post_id, 'enclosure', $encstring );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5723
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5724
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5725
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5726
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5727
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5728
	 * Attaches an upload to a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5729
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5730
	 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5731
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5732
	 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5733
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5734
	 * @param int    $post_id      Post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5735
	 * @param string $post_content Post Content for attachment.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5736
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5737
	public function attach_uploads( $post_id, $post_content ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5738
		global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5739
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5740
		// Find any unattached files.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5741
		$attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5742
		if ( is_array( $attachments ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5743
			foreach ( $attachments as $file ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5744
				if ( ! empty( $file->guid ) && str_contains( $post_content, $file->guid ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5745
					$wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5746
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5747
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5748
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5749
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5750
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5751
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5752
	 * Edits a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5753
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5754
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5755
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5756
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5757
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5758
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5759
	 *     @type int    $0 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5760
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5761
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5762
	 *     @type array  $3 Content structure.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5763
	 *     @type int    $4 Optional. Publish flag. 0 for draft, 1 for publish. Default 0.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5764
	 * }
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5765
	 * @return true|IXR_Error True on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5766
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5767
	public function mw_editPost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5768
		$this->escape( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5769
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5770
		$post_id        = (int) $args[0];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5771
		$username       = $args[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5772
		$password       = $args[2];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5773
		$content_struct = $args[3];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5774
		$publish        = isset( $args[4] ) ? $args[4] : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5775
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5776
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5777
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5778
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5779
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5780
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5781
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  5782
		do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5783
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5784
		$postdata = get_post( $post_id, ARRAY_A );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5785
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5786
		/*
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5787
		 * If there is no post data for the give post ID, stop now and return an error.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5788
		 * Otherwise a new post will be created (which was the old behavior).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5789
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5790
		if ( ! $postdata || empty( $postdata['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5791
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5792
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5793
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5794
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5795
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5796
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5797
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5798
		// Use wp.editPost to edit post types other than post and page.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5799
		if ( ! in_array( $postdata['post_type'], array( 'post', 'page' ), true ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5800
			return new IXR_Error( 401, __( 'Invalid post type.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5801
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5802
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5803
		// Thwart attempt to change the post type.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5804
		if ( ! empty( $content_struct['post_type'] ) && ( $content_struct['post_type'] !== $postdata['post_type'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5805
			return new IXR_Error( 401, __( 'The post type may not be changed.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5806
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5807
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5808
		// Check for a valid post format if one was given.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5809
		if ( isset( $content_struct['wp_post_format'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5810
			$content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5811
			if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5812
				return new IXR_Error( 404, __( 'Invalid post format.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5813
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5814
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5815
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5816
		$this->escape( $postdata );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5817
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5818
		$post_id        = $postdata['ID'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5819
		$post_content   = $postdata['post_content'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5820
		$post_title     = $postdata['post_title'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5821
		$post_excerpt   = $postdata['post_excerpt'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5822
		$post_password  = $postdata['post_password'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5823
		$post_parent    = $postdata['post_parent'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5824
		$post_type      = $postdata['post_type'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5825
		$menu_order     = $postdata['menu_order'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5826
		$ping_status    = $postdata['ping_status'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5827
		$comment_status = $postdata['comment_status'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5828
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5829
		// Let WordPress manage slug if none was provided.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5830
		$post_name = $postdata['post_name'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5831
		if ( isset( $content_struct['wp_slug'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5832
			$post_name = $content_struct['wp_slug'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5833
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5834
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5835
		// Only use a password if one was given.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5836
		if ( isset( $content_struct['wp_password'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5837
			$post_password = $content_struct['wp_password'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5838
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5839
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5840
		// Only set a post parent if one was given.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5841
		if ( isset( $content_struct['wp_page_parent_id'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5842
			$post_parent = $content_struct['wp_page_parent_id'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5843
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5844
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5845
		// Only set the 'menu_order' if it was given.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5846
		if ( isset( $content_struct['wp_page_order'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5847
			$menu_order = $content_struct['wp_page_order'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5848
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5849
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5850
		$page_template = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5851
		if ( ! empty( $content_struct['wp_page_template'] ) && 'page' === $post_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5852
			$page_template = $content_struct['wp_page_template'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5853
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5854
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5855
		$post_author = $postdata['post_author'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5856
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5857
		// If an author ID was provided then use it instead.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5858
		if ( isset( $content_struct['wp_author_id'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5859
			// Check permissions if attempting to switch author to or from another user.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  5860
			if ( $user->ID !== (int) $content_struct['wp_author_id'] || $user->ID !== (int) $post_author ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5861
				switch ( $post_type ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5862
					case 'post':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5863
						if ( ! current_user_can( 'edit_others_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5864
							return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the post author as this user.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5865
						}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5866
						break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5867
					case 'page':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5868
						if ( ! current_user_can( 'edit_others_pages' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5869
							return new IXR_Error( 401, __( 'Sorry, you are not allowed to change the page author as this user.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5870
						}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5871
						break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5872
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5873
						return new IXR_Error( 401, __( 'Invalid post type.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5874
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5875
				$post_author = $content_struct['wp_author_id'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5876
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5877
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5878
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5879
		if ( isset( $content_struct['mt_allow_comments'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5880
			if ( ! is_numeric( $content_struct['mt_allow_comments'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5881
				switch ( $content_struct['mt_allow_comments'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5882
					case 'closed':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5883
						$comment_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5884
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5885
					case 'open':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5886
						$comment_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5887
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5888
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5889
						$comment_status = get_default_comment_status( $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5890
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5891
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5892
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5893
				switch ( (int) $content_struct['mt_allow_comments'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5894
					case 0:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5895
					case 2:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5896
						$comment_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5897
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5898
					case 1:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5899
						$comment_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5900
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5901
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5902
						$comment_status = get_default_comment_status( $post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5903
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5904
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5905
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5906
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5907
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5908
		if ( isset( $content_struct['mt_allow_pings'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5909
			if ( ! is_numeric( $content_struct['mt_allow_pings'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5910
				switch ( $content_struct['mt_allow_pings'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5911
					case 'closed':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5912
						$ping_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5913
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5914
					case 'open':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5915
						$ping_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5916
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5917
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5918
						$ping_status = get_default_comment_status( $post_type, 'pingback' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5919
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5920
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5921
			} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5922
				switch ( (int) $content_struct['mt_allow_pings'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5923
					case 0:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5924
						$ping_status = 'closed';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5925
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5926
					case 1:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5927
						$ping_status = 'open';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5928
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5929
					default:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5930
						$ping_status = get_default_comment_status( $post_type, 'pingback' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5931
						break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5932
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5933
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5934
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5935
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5936
		if ( isset( $content_struct['title'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5937
			$post_title = $content_struct['title'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5938
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5939
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5940
		if ( isset( $content_struct['description'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5941
			$post_content = $content_struct['description'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5942
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5943
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5944
		$post_category = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5945
		if ( isset( $content_struct['categories'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5946
			$catnames = $content_struct['categories'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5947
			if ( is_array( $catnames ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5948
				foreach ( $catnames as $cat ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5949
					$post_category[] = get_cat_ID( $cat );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5950
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5951
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5952
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5953
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5954
		if ( isset( $content_struct['mt_excerpt'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5955
			$post_excerpt = $content_struct['mt_excerpt'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5956
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5957
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5958
		$post_more = isset( $content_struct['mt_text_more'] ) ? $content_struct['mt_text_more'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5959
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5960
		$post_status = $publish ? 'publish' : 'draft';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5961
		if ( isset( $content_struct[ "{$post_type}_status" ] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5962
			switch ( $content_struct[ "{$post_type}_status" ] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5963
				case 'draft':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5964
				case 'pending':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5965
				case 'private':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5966
				case 'publish':
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5967
					$post_status = $content_struct[ "{$post_type}_status" ];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5968
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5969
				default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5970
					$post_status = $publish ? 'publish' : 'draft';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5971
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5972
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5973
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5974
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5975
		$tags_input = isset( $content_struct['mt_keywords'] ) ? $content_struct['mt_keywords'] : array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5976
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5977
		if ( 'publish' === $post_status || 'private' === $post_status ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  5978
			if ( 'page' === $post_type && ! current_user_can( 'publish_pages' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5979
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this page.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5980
			} elseif ( ! current_user_can( 'publish_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5981
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  5982
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5983
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5984
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5985
		if ( $post_more ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5986
			$post_content = $post_content . '<!--more-->' . $post_more;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5987
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5988
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  5989
		$to_ping = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5990
		if ( isset( $content_struct['mt_tb_ping_urls'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5991
			$to_ping = $content_struct['mt_tb_ping_urls'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5992
			if ( is_array( $to_ping ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5993
				$to_ping = implode( ' ', $to_ping );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5994
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5995
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  5996
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5997
		// Do some timestamp voodoo.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  5998
		if ( ! empty( $content_struct['date_created_gmt'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  5999
			// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6000
			$date_created = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6001
		} elseif ( ! empty( $content_struct['dateCreated'] ) ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6002
			$date_created = $content_struct['dateCreated']->getIso();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6003
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6004
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6005
		// Default to not flagging the post date to be edited unless it's intentional.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6006
		$edit_date = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6007
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6008
		if ( ! empty( $date_created ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6009
			$post_date     = iso8601_to_datetime( $date_created );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6010
			$post_date_gmt = iso8601_to_datetime( $date_created, 'gmt' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6011
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6012
			// Flag the post date to be edited.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6013
			$edit_date = true;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6014
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6015
			$post_date     = $postdata['post_date'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6016
			$post_date_gmt = $postdata['post_date_gmt'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6017
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6018
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6019
		$newpost = array(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6020
			'ID' => $post_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6021
		);
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6022
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6023
		$newpost += compact(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6024
			'post_content',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6025
			'post_title',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6026
			'post_category',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6027
			'post_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6028
			'post_excerpt',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6029
			'comment_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6030
			'ping_status',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6031
			'edit_date',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6032
			'post_date',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6033
			'post_date_gmt',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6034
			'to_ping',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6035
			'post_name',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6036
			'post_password',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6037
			'post_parent',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6038
			'menu_order',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6039
			'post_author',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6040
			'tags_input',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6041
			'page_template'
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6042
		);
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6043
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6044
		// We've got all the data -- post it.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6045
		$result = wp_update_post( $newpost, true );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6046
		if ( is_wp_error( $result ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6047
			return new IXR_Error( 500, $result->get_error_message() );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6048
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6049
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6050
		if ( ! $result ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6051
			return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6052
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6053
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6054
		// Only posts can be sticky.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6055
		if ( 'post' === $post_type && isset( $content_struct['sticky'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6056
			$data              = $newpost;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6057
			$data['sticky']    = $content_struct['sticky'];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6058
			$data['post_type'] = 'post';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6059
			$error             = $this->_toggle_sticky( $data, true );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6060
			if ( $error ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6061
				return $error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6062
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6063
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6064
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6065
		if ( isset( $content_struct['custom_fields'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6066
			$this->set_custom_fields( $post_id, $content_struct['custom_fields'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6067
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6068
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6069
		if ( isset( $content_struct['wp_post_thumbnail'] ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6070
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6071
			// Empty value deletes, non-empty value adds/updates.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6072
			if ( empty( $content_struct['wp_post_thumbnail'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6073
				delete_post_thumbnail( $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6074
			} else {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6075
				if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6076
					return new IXR_Error( 404, __( 'Invalid attachment ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6077
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6078
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6079
			unset( $content_struct['wp_post_thumbnail'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6080
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6081
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6082
		// Handle enclosures.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6083
		$enclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null;
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6084
		$this->add_enclosure_if_new( $post_id, $enclosure );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6085
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6086
		$this->attach_uploads( $post_id, $post_content );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6087
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6088
		// Handle post formats if assigned, validation is handled earlier in this function.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6089
		if ( isset( $content_struct['wp_post_format'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6090
			set_post_format( $post_id, $content_struct['wp_post_format'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6091
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6092
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6093
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6094
		 * Fires after a post has been successfully updated via the XML-RPC MovableType API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6095
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6096
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6097
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6098
		 * @param int   $post_id ID of the updated post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6099
		 * @param array $args    An array of arguments to update the post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6100
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6101
		do_action( 'xmlrpc_call_success_mw_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6103
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6104
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6106
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6107
	 * Retrieves a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6108
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6109
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6110
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6111
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6112
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6113
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6114
	 *     @type int    $0 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6115
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6116
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6117
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6118
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6119
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6120
	public function mw_getPost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6121
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6122
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6123
		$post_id  = (int) $args[0];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6124
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6125
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6126
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6127
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6128
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6129
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6130
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6131
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6132
		$postdata = get_post( $post_id, ARRAY_A );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6133
		if ( ! $postdata ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6134
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6135
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6136
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6137
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6138
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6139
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6140
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6141
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6142
		do_action( 'xmlrpc_call', 'metaWeblog.getPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6143
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6144
		if ( '' !== $postdata['post_date'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6145
			$post_date         = $this->_convert_date( $postdata['post_date'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6146
			$post_date_gmt     = $this->_convert_date_gmt( $postdata['post_date_gmt'], $postdata['post_date'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6147
			$post_modified     = $this->_convert_date( $postdata['post_modified'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6148
			$post_modified_gmt = $this->_convert_date_gmt( $postdata['post_modified_gmt'], $postdata['post_modified'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6149
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6150
			$categories = array();
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6151
			$cat_ids    = wp_get_post_categories( $post_id );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6152
			foreach ( $cat_ids as $cat_id ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6153
				$categories[] = get_cat_name( $cat_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6154
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6156
			$tagnames = array();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6157
			$tags     = wp_get_post_tags( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6158
			if ( ! empty( $tags ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6159
				foreach ( $tags as $tag ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6160
					$tagnames[] = $tag->name;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6161
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6162
				$tagnames = implode( ', ', $tagnames );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6163
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6164
				$tagnames = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6165
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6166
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6167
			$post = get_extended( $postdata['post_content'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6168
			$link = get_permalink( $postdata['ID'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6170
			// Get the author info.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6171
			$author = get_userdata( $postdata['post_author'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6172
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6173
			$allow_comments = ( 'open' === $postdata['comment_status'] ) ? 1 : 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6174
			$allow_pings    = ( 'open' === $postdata['ping_status'] ) ? 1 : 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6175
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6176
			// Consider future posts as published.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6177
			if ( 'future' === $postdata['post_status'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6178
				$postdata['post_status'] = 'publish';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6179
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6180
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6181
			// Get post format.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6182
			$post_format = get_post_format( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6183
			if ( empty( $post_format ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6184
				$post_format = 'standard';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6185
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6187
			$sticky = false;
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6188
			if ( is_sticky( $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6189
				$sticky = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6190
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6191
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6192
			$enclosure = array();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6193
			foreach ( (array) get_post_custom( $post_id ) as $key => $val ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6194
				if ( 'enclosure' === $key ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6195
					foreach ( (array) $val as $enc ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6196
						$encdata             = explode( "\n", $enc );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6197
						$enclosure['url']    = trim( htmlspecialchars( $encdata[0] ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6198
						$enclosure['length'] = (int) trim( $encdata[1] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6199
						$enclosure['type']   = trim( $encdata[2] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6200
						break 2;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6201
					}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6202
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6203
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6204
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6205
			$resp = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6206
				'dateCreated'            => $post_date,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6207
				'userid'                 => $postdata['post_author'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6208
				'postid'                 => $postdata['ID'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6209
				'description'            => $post['main'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6210
				'title'                  => $postdata['post_title'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6211
				'link'                   => $link,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6212
				'permaLink'              => $link,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6213
				// Commented out because no other tool seems to use this.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6214
				// 'content' => $entry['post_content'],
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6215
				'categories'             => $categories,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6216
				'mt_excerpt'             => $postdata['post_excerpt'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6217
				'mt_text_more'           => $post['extended'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6218
				'wp_more_text'           => $post['more_text'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6219
				'mt_allow_comments'      => $allow_comments,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6220
				'mt_allow_pings'         => $allow_pings,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6221
				'mt_keywords'            => $tagnames,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6222
				'wp_slug'                => $postdata['post_name'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6223
				'wp_password'            => $postdata['post_password'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6224
				'wp_author_id'           => (string) $author->ID,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6225
				'wp_author_display_name' => $author->display_name,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6226
				'date_created_gmt'       => $post_date_gmt,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6227
				'post_status'            => $postdata['post_status'],
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6228
				'custom_fields'          => $this->get_custom_fields( $post_id ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6229
				'wp_post_format'         => $post_format,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6230
				'sticky'                 => $sticky,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6231
				'date_modified'          => $post_modified,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6232
				'date_modified_gmt'      => $post_modified_gmt,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6233
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6234
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6235
			if ( ! empty( $enclosure ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6236
				$resp['enclosure'] = $enclosure;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6237
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6239
			$resp['wp_post_thumbnail'] = get_post_thumbnail_id( $postdata['ID'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6241
			return $resp;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6242
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6243
			return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6244
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6245
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6246
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6247
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6248
	 * Retrieves list of recent posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6249
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6250
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6251
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6252
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6253
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6254
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6255
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6256
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6257
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6258
	 *     @type int    $3 Optional. Number of posts.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6259
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6260
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6261
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6262
	public function mw_getRecentPosts( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6263
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6264
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6265
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6266
		$password = $args[2];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6267
		if ( isset( $args[3] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6268
			$query = array( 'numberposts' => absint( $args[3] ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6269
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6270
			$query = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6271
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6272
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6273
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6274
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6275
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6276
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6277
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6278
		if ( ! current_user_can( 'edit_posts' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6279
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit posts.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6280
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6281
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6282
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6283
		do_action( 'xmlrpc_call', 'metaWeblog.getRecentPosts', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6284
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6285
		$posts_list = wp_get_recent_posts( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6286
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6287
		if ( ! $posts_list ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6288
			return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6289
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6290
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6291
		$recent_posts = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6292
		foreach ( $posts_list as $entry ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6293
			if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6294
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6295
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6296
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6297
			$post_date         = $this->_convert_date( $entry['post_date'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6298
			$post_date_gmt     = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6299
			$post_modified     = $this->_convert_date( $entry['post_modified'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6300
			$post_modified_gmt = $this->_convert_date_gmt( $entry['post_modified_gmt'], $entry['post_modified'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6301
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6302
			$categories = array();
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6303
			$cat_ids    = wp_get_post_categories( $entry['ID'] );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6304
			foreach ( $cat_ids as $cat_id ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6305
				$categories[] = get_cat_name( $cat_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6306
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6307
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6308
			$tagnames = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6309
			$tags     = wp_get_post_tags( $entry['ID'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6310
			if ( ! empty( $tags ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6311
				foreach ( $tags as $tag ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6312
					$tagnames[] = $tag->name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6313
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6314
				$tagnames = implode( ', ', $tagnames );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6315
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6316
				$tagnames = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6317
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6318
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6319
			$post = get_extended( $entry['post_content'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6320
			$link = get_permalink( $entry['ID'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6321
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6322
			// Get the post author info.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6323
			$author = get_userdata( $entry['post_author'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6324
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6325
			$allow_comments = ( 'open' === $entry['comment_status'] ) ? 1 : 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6326
			$allow_pings    = ( 'open' === $entry['ping_status'] ) ? 1 : 0;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6327
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6328
			// Consider future posts as published.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6329
			if ( 'future' === $entry['post_status'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6330
				$entry['post_status'] = 'publish';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6331
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6332
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6333
			// Get post format.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6334
			$post_format = get_post_format( $entry['ID'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6335
			if ( empty( $post_format ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6336
				$post_format = 'standard';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6337
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6338
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6339
			$recent_posts[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6340
				'dateCreated'            => $post_date,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6341
				'userid'                 => $entry['post_author'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6342
				'postid'                 => (string) $entry['ID'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6343
				'description'            => $post['main'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6344
				'title'                  => $entry['post_title'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6345
				'link'                   => $link,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6346
				'permaLink'              => $link,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6347
				// Commented out because no other tool seems to use this.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6348
				// 'content' => $entry['post_content'],
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6349
				'categories'             => $categories,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6350
				'mt_excerpt'             => $entry['post_excerpt'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6351
				'mt_text_more'           => $post['extended'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6352
				'wp_more_text'           => $post['more_text'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6353
				'mt_allow_comments'      => $allow_comments,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6354
				'mt_allow_pings'         => $allow_pings,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6355
				'mt_keywords'            => $tagnames,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6356
				'wp_slug'                => $entry['post_name'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6357
				'wp_password'            => $entry['post_password'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6358
				'wp_author_id'           => (string) $author->ID,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6359
				'wp_author_display_name' => $author->display_name,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6360
				'date_created_gmt'       => $post_date_gmt,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6361
				'post_status'            => $entry['post_status'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6362
				'custom_fields'          => $this->get_custom_fields( $entry['ID'] ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6363
				'wp_post_format'         => $post_format,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6364
				'date_modified'          => $post_modified,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6365
				'date_modified_gmt'      => $post_modified_gmt,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6366
				'sticky'                 => ( 'post' === $entry['post_type'] && is_sticky( $entry['ID'] ) ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6367
				'wp_post_thumbnail'      => get_post_thumbnail_id( $entry['ID'] ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6368
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6369
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6370
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6371
		return $recent_posts;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6372
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6373
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6374
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6375
	 * Retrieves the list of categories on a given blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6376
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6377
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6378
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6379
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6380
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6381
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6382
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6383
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6384
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6385
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6386
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6387
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6388
	public function mw_getCategories( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6389
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6390
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6391
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6392
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6393
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6394
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6395
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6396
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6397
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6398
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6399
		if ( ! current_user_can( 'edit_posts' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6400
			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6401
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6402
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6403
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6404
		do_action( 'xmlrpc_call', 'metaWeblog.getCategories', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6405
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6406
		$categories_struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6407
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6408
		$cats = get_categories( array( 'get' => 'all' ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6409
		if ( $cats ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6410
			foreach ( $cats as $cat ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6411
				$struct                        = array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6412
				$struct['categoryId']          = $cat->term_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6413
				$struct['parentId']            = $cat->parent;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6414
				$struct['description']         = $cat->name;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6415
				$struct['categoryDescription'] = $cat->description;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6416
				$struct['categoryName']        = $cat->name;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6417
				$struct['htmlUrl']             = esc_html( get_category_link( $cat->term_id ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6418
				$struct['rssUrl']              = esc_html( get_category_feed_link( $cat->term_id, 'rss2' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6419
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6420
				$categories_struct[] = $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6421
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6422
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6423
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6424
		return $categories_struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6425
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6426
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6427
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6428
	 * Uploads a file, following your settings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6429
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6430
	 * Adapted from a patch by Johann Richard.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6431
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6432
	 * @link http://mycvs.org/archives/2004/06/30/file-upload-to-wordpress-in-ecto/
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6433
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6434
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6435
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6436
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6437
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6438
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6439
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6440
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6441
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6442
	 *     @type array  $3 Data.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6443
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6444
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6445
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6446
	public function mw_newMediaObject( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6447
		$username = $this->escape( $args[1] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6448
		$password = $this->escape( $args[2] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6449
		$data     = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6450
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6451
		$name = sanitize_file_name( $data['name'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6452
		$type = $data['type'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6453
		$bits = $data['bits'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6454
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6455
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6456
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6457
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6458
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6459
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6460
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6461
		do_action( 'xmlrpc_call', 'metaWeblog.newMediaObject', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6462
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6463
		if ( ! current_user_can( 'upload_files' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6464
			$this->error = new IXR_Error( 401, __( 'Sorry, you are not allowed to upload files.' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6465
			return $this->error;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6466
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6467
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6468
		if ( is_multisite() && upload_is_user_over_quota( false ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6469
			$this->error = new IXR_Error(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6470
				401,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6471
				sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6472
					/* translators: %s: Allowed space allocation. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6473
					__( 'Sorry, you have used your space allocation of %s. Please delete some files to upload more files.' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6474
					size_format( get_space_allowed() * MB_IN_BYTES )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6475
				)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6476
			);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6477
			return $this->error;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6478
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6479
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6480
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6481
		 * Filters whether to preempt the XML-RPC media upload.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6482
		 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  6483
		 * Returning a truthy value will effectively short-circuit the media upload,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6484
		 * returning that value as a 500 error instead.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6485
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6486
		 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6487
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6488
		 * @param bool $error Whether to pre-empt the media upload. Default false.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6489
		 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6490
		$upload_err = apply_filters( 'pre_upload_error', false );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6491
		if ( $upload_err ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6492
			return new IXR_Error( 500, $upload_err );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6493
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6494
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6495
		$upload = wp_upload_bits( $name, null, $bits );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6496
		if ( ! empty( $upload['error'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6497
			/* translators: 1: File name, 2: Error message. */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6498
			$error_string = sprintf( __( 'Could not write file %1$s (%2$s).' ), $name, $upload['error'] );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6499
			return new IXR_Error( 500, $error_string );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6500
		}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6501
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6502
		// Construct the attachment array.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6503
		$post_id = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6504
		if ( ! empty( $data['post_id'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6505
			$post_id = (int) $data['post_id'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6506
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6507
			if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6508
				return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6509
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6510
		}
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6511
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6512
		$attachment = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6513
			'post_title'     => $name,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6514
			'post_content'   => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6515
			'post_type'      => 'attachment',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6516
			'post_parent'    => $post_id,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6517
			'post_mime_type' => $type,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6518
			'guid'           => $upload['url'],
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6519
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6520
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6521
		// Save the data.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6522
		$attachment_id = wp_insert_attachment( $attachment, $upload['file'], $post_id );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6523
		wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $upload['file'] ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6524
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6525
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6526
		 * Fires after a new attachment has been added via the XML-RPC MovableType API.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6527
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6528
		 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6529
		 *
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6530
		 * @param int   $attachment_id ID of the new attachment.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6531
		 * @param array $args          An array of arguments to add the attachment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6532
		 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6533
		do_action( 'xmlrpc_call_success_mw_newMediaObject', $attachment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6534
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6535
		$struct = $this->_prepare_media_item( get_post( $attachment_id ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6536
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6537
		// Deprecated values.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6538
		$struct['id']   = $struct['attachment_id'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6539
		$struct['file'] = $struct['title'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6540
		$struct['url']  = $struct['link'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6541
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6542
		return $struct;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6543
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6544
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6545
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6546
	 * MovableType API functions.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6547
	 * Specs archive on http://web.archive.org/web/20050220091302/http://www.movabletype.org:80/docs/mtmanual_programmatic.html
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6548
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6549
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6550
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6551
	 * Retrieves the post titles of recent posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6552
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6553
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6554
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6555
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6556
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6557
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6558
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6559
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6560
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6561
	 *     @type int    $3 Optional. Number of posts.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6562
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6563
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6564
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6565
	public function mt_getRecentPostTitles( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6566
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6567
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6568
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6569
		$password = $args[2];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6570
		if ( isset( $args[3] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6571
			$query = array( 'numberposts' => absint( $args[3] ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6572
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6573
			$query = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6574
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6575
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6576
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6577
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6578
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6579
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6580
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6581
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6582
		do_action( 'xmlrpc_call', 'mt.getRecentPostTitles', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6583
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6584
		$posts_list = wp_get_recent_posts( $query );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6585
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6586
		if ( ! $posts_list ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6587
			$this->error = new IXR_Error( 500, __( 'No posts found or an error occurred while retrieving posts.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6588
			return $this->error;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6589
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6590
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6591
		$recent_posts = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6592
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6593
		foreach ( $posts_list as $entry ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6594
			if ( ! current_user_can( 'edit_post', $entry['ID'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6595
				continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6596
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6597
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6598
			$post_date     = $this->_convert_date( $entry['post_date'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6599
			$post_date_gmt = $this->_convert_date_gmt( $entry['post_date_gmt'], $entry['post_date'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6600
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6601
			$recent_posts[] = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6602
				'dateCreated'      => $post_date,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6603
				'userid'           => $entry['post_author'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6604
				'postid'           => (string) $entry['ID'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6605
				'title'            => $entry['post_title'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6606
				'post_status'      => $entry['post_status'],
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6607
				'date_created_gmt' => $post_date_gmt,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6608
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6609
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6610
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6611
		return $recent_posts;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6612
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6613
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6614
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6615
	 * Retrieves the list of all categories on a blog.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6616
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6617
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6618
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6619
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6620
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6621
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6622
	 *     @type int    $0 Blog ID (unused).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6623
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6624
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6625
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6626
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6627
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6628
	public function mt_getCategoryList( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6629
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6630
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6631
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6632
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6633
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6634
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6635
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6636
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6637
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6638
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6639
		if ( ! current_user_can( 'edit_posts' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6640
			return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6641
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6642
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6643
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6644
		do_action( 'xmlrpc_call', 'mt.getCategoryList', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6645
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6646
		$categories_struct = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6647
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6648
		$cats = get_categories(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6649
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6650
				'hide_empty'   => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6651
				'hierarchical' => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6652
			)
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6653
		);
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6654
		if ( $cats ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6655
			foreach ( $cats as $cat ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6656
				$struct                 = array();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6657
				$struct['categoryId']   = $cat->term_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6658
				$struct['categoryName'] = $cat->name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6659
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6660
				$categories_struct[] = $struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6661
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6662
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6663
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6664
		return $categories_struct;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6665
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6666
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6667
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6668
	 * Retrieves post categories.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6669
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6670
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6671
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6672
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6673
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6674
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6675
	 *     @type int    $0 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6676
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6677
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6678
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6679
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6680
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6681
	public function mt_getPostCategories( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6682
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6683
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6684
		$post_id  = (int) $args[0];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6685
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6686
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6687
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6688
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6689
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6690
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6691
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6692
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6693
		if ( ! get_post( $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6694
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6695
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6696
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6697
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6698
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6699
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6700
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6701
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6702
		do_action( 'xmlrpc_call', 'mt.getPostCategories', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6703
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6704
		$categories = array();
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6705
		$cat_ids    = wp_get_post_categories( (int) $post_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6706
		// First listed category will be the primary category.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6707
		$is_primary = true;
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6708
		foreach ( $cat_ids as $cat_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6709
			$categories[] = array(
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6710
				'categoryName' => get_cat_name( $cat_id ),
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6711
				'categoryId'   => (string) $cat_id,
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6712
				'isPrimary'    => $is_primary,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6713
			);
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6714
			$is_primary   = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6715
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6716
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6717
		return $categories;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6718
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6719
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6720
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6721
	 * Sets categories for a post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6722
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6723
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6724
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6725
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6726
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6727
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6728
	 *     @type int    $0 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6729
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6730
	 *     @type string $2 Password.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6731
	 *     @type array  $3 Categories.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6732
	 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6733
	 * @return true|IXR_Error True on success.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6734
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6735
	public function mt_setPostCategories( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6736
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6737
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6738
		$post_id    = (int) $args[0];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6739
		$username   = $args[1];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6740
		$password   = $args[2];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6741
		$categories = $args[3];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6742
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6743
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6744
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6745
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6746
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6747
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6748
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6749
		do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6750
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6751
		if ( ! get_post( $post_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6752
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6753
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6754
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6755
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6756
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6757
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6758
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6759
		$cat_ids = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6760
		foreach ( $categories as $cat ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6761
			$cat_ids[] = $cat['categoryId'];
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6762
		}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6763
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6764
		wp_set_post_categories( $post_id, $cat_ids );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6765
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6766
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6767
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6768
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6769
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6770
	 * Retrieves an array of methods supported by this server.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6771
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6772
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6773
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6774
	 * @return array
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6775
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6776
	public function mt_supportedMethods() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6777
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6778
		do_action( 'xmlrpc_call', 'mt.supportedMethods', array(), $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6779
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6780
		return array_keys( $this->methods );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6781
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6782
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6783
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6784
	 * Retrieves an empty array because we don't support per-post text filters.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6785
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6786
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6787
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6788
	public function mt_supportedTextFilters() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6789
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6790
		do_action( 'xmlrpc_call', 'mt.supportedTextFilters', array(), $this );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6791
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6792
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6793
		 * Filters the MoveableType text filters list for XML-RPC.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6794
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6795
		 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6796
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6797
		 * @param array $filters An array of text filters.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6798
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6799
		return apply_filters( 'xmlrpc_text_filters', array() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6800
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6801
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6802
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6803
	 * Retrieves trackbacks sent to a given post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6804
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6805
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6806
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6807
	 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6808
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6809
	 * @param int $post_id
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6810
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6811
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6812
	public function mt_getTrackbackPings( $post_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6813
		global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6814
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6815
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6816
		do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6817
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6818
		$actual_post = get_post( $post_id, ARRAY_A );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6819
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6820
		if ( ! $actual_post ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6821
			return new IXR_Error( 404, __( 'Sorry, no such post.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6822
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6823
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6824
		$comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6825
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6826
		if ( ! $comments ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6827
			return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6828
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6829
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6830
		$trackback_pings = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6831
		foreach ( $comments as $comment ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6832
			if ( 'trackback' === $comment->comment_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6833
				$content           = $comment->comment_content;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6834
				$title             = substr( $content, 8, ( strpos( $content, '</strong>' ) - 8 ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6835
				$trackback_pings[] = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6836
					'pingTitle' => $title,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6837
					'pingURL'   => $comment->comment_author_url,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6838
					'pingIP'    => $comment->comment_author_IP,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6839
				);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6840
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6841
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6842
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6843
		return $trackback_pings;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6844
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6845
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6846
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6847
	 * Sets a post's publish status to 'publish'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6848
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6849
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6850
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6851
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6852
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6853
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6854
	 *     @type int    $0 Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6855
	 *     @type string $1 Username.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6856
	 *     @type string $2 Password.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6857
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6858
	 * @return int|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6859
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6860
	public function mt_publishPost( $args ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6861
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6862
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6863
		$post_id  = (int) $args[0];
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6864
		$username = $args[1];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6865
		$password = $args[2];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6866
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6867
		$user = $this->login( $username, $password );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6868
		if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6869
			return $this->error;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6870
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6871
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6872
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6873
		do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6874
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6875
		$postdata = get_post( $post_id, ARRAY_A );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6876
		if ( ! $postdata ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6877
			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6878
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6879
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6880
		if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6881
			return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6882
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6883
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6884
		$postdata['post_status'] = 'publish';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6885
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6886
		// Retain old categories.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6887
		$postdata['post_category'] = wp_get_post_categories( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6888
		$this->escape( $postdata );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6889
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6890
		return wp_update_post( $postdata );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6891
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6892
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6893
	/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6894
	 * Pingback functions.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6895
	 * Specs on www.hixie.ch/specs/pingback/pingback
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6896
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6897
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6898
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6899
	 * Retrieves a pingback and registers it.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6900
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6901
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6902
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6903
	 * @global wpdb $wpdb WordPress database abstraction object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6904
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6905
	 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6906
	 *     Method arguments. Note: arguments must be ordered as documented.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6907
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6908
	 *     @type string $0 URL of page linked from.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6909
	 *     @type string $1 URL of page linked to.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6910
	 * }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6911
	 * @return string|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6912
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6913
	public function pingback_ping( $args ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6914
		global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6915
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6916
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6917
		do_action( 'xmlrpc_call', 'pingback.ping', $args, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6918
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6919
		$this->escape( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6920
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6921
		$pagelinkedfrom = str_replace( '&amp;', '&', $args[0] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6922
		$pagelinkedto   = str_replace( '&amp;', '&', $args[1] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6923
		$pagelinkedto   = str_replace( '&', '&amp;', $pagelinkedto );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6924
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6925
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  6926
		 * Filters the pingback source URI.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6927
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6928
		 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6929
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6930
		 * @param string $pagelinkedfrom URI of the page linked from.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6931
		 * @param string $pagelinkedto   URI of the page linked to.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6932
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6933
		$pagelinkedfrom = apply_filters( 'pingback_ping_source_uri', $pagelinkedfrom, $pagelinkedto );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6934
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6935
		if ( ! $pagelinkedfrom ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6936
			return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6937
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6938
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6939
		// Check if the page linked to is on our site.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6940
		$pos1 = strpos( $pagelinkedto, str_replace( array( 'http://www.', 'http://', 'https://www.', 'https://' ), '', get_option( 'home' ) ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6941
		if ( ! $pos1 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6942
			return $this->pingback_error( 0, __( 'Is there no link to us?' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6943
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6944
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6945
		/*
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6946
		 * Let's find which post is linked to.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6947
		 * FIXME: Does url_to_postid() cover all these cases already?
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6948
		 * If so, then let's use it and drop the old code.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6949
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6950
		$urltest = parse_url( $pagelinkedto );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6951
		$post_id = url_to_postid( $pagelinkedto );
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6952
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6953
		if ( $post_id ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  6954
			// $way
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6955
		} elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6956
			// The path defines the post_ID (archives/p/XXXX).
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6957
			$blah    = explode( '/', $match[0] );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6958
			$post_id = (int) $blah[1];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6959
		} elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6960
			// The query string defines the post_ID (?p=XXXX).
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6961
			$blah    = explode( '=', $match[0] );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6962
			$post_id = (int) $blah[1];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6963
		} elseif ( isset( $urltest['fragment'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6964
			// An #anchor is there, it's either...
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  6965
			if ( (int) $urltest['fragment'] ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6966
				// ...an integer #XXXX (simplest case),
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6967
				$post_id = (int) $urltest['fragment'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6968
			} elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6969
				// ...a post ID in the form 'post-###',
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6970
				$post_id = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6971
			} elseif ( is_string( $urltest['fragment'] ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6972
				// ...or a string #title, a little more complicated.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6973
				$title   = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6974
				$sql     = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6975
				$post_id = $wpdb->get_var( $sql );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6976
				if ( ! $post_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6977
					// Returning unknown error '0' is better than die()'ing.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6978
					return $this->pingback_error( 0, '' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6979
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6980
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6981
		} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6982
			// TODO: Attempt to extract a post ID from the given URL.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  6983
			return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6984
		}
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6985
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  6986
		$post_id = (int) $post_id;
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6987
		$post    = get_post( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6988
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6989
		if ( ! $post ) { // Post not found.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  6990
			return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6991
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6992
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  6993
		if ( url_to_postid( $pagelinkedfrom ) === $post_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6994
			return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6995
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  6996
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  6997
		// Check if pings are on.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  6998
		if ( ! pings_open( $post ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  6999
			return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7000
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7001
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7002
		// Let's check that the remote site didn't already pingback this entry.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7003
		if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_id, $pagelinkedfrom ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7004
			return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7005
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7006
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7007
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7008
		 * The remote site may have sent the pingback before it finished publishing its own content
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7009
		 * containing this pingback URL. If that happens then it won't be immediately possible to fetch
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7010
		 * the pinging post; adding a small delay reduces the likelihood of this happening.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7011
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7012
		 * While there are more robust methods than calling `sleep()` here (because `sleep()` merely
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7013
		 * mitigates the risk of requesting the remote post before it's available), this is effective
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7014
		 * enough for most cases and avoids introducing more complexity into this code.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7015
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7016
		 * One way to improve the reliability of this code might be to add failure-handling to the remote
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7017
		 * fetch and retry up to a set number of times if it receives a 404. This could also handle 401 and
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7018
		 * 403 responses to differentiate the "does not exist" failure from the "may not access" failure.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7019
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7020
		sleep( 1 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7021
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7022
		$remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7023
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  7024
		/** This filter is documented in wp-includes/class-wp-http.php */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7025
		$user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7026
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7027
		// Let's check the remote site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7028
		$http_api_args = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7029
			'timeout'             => 10,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7030
			'redirection'         => 0,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7031
			'limit_response_size' => 153600, // 150 KB
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7032
			'user-agent'          => "$user_agent; verifying pingback from $remote_ip",
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7033
			'headers'             => array(
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7034
				'X-Pingback-Forwarded-For' => $remote_ip,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7035
			),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7036
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7037
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7038
		$request                = wp_safe_remote_get( $pagelinkedfrom, $http_api_args );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7039
		$remote_source          = wp_remote_retrieve_body( $request );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7040
		$remote_source_original = $remote_source;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7041
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7042
		if ( ! $remote_source ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7043
			return $this->pingback_error( 16, __( 'The source URL does not exist.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7044
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7045
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7046
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7047
		 * Filters the pingback remote source.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7048
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7049
		 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7050
		 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7051
		 * @param string $remote_source Response source for the page linked from.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7052
		 * @param string $pagelinkedto  URL of the page linked to.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7053
		 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7054
		$remote_source = apply_filters( 'pre_remote_source', $remote_source, $pagelinkedto );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7055
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7056
		// Work around bug in strip_tags():
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7057
		$remote_source = str_replace( '<!DOC', '<DOC', $remote_source );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7058
		$remote_source = preg_replace( '/[\r\n\t ]+/', ' ', $remote_source ); // normalize spaces
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7059
		$remote_source = preg_replace( '/<\/*(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/', "\n\n", $remote_source );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7060
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7061
		preg_match( '|<title>([^<]*?)</title>|is', $remote_source, $matchtitle );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7062
		$title = isset( $matchtitle[1] ) ? $matchtitle[1] : '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7063
		if ( empty( $title ) ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  7064
			return $this->pingback_error( 32, __( 'A title on that page cannot be found.' ) );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7065
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7066
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7067
		// Remove all script and style tags including their content.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7068
		$remote_source = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $remote_source );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7069
		// Just keep the tag we need.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7070
		$remote_source = strip_tags( $remote_source, '<a>' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7071
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7072
		$p = explode( "\n\n", $remote_source );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7073
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7074
		$preg_target = preg_quote( $pagelinkedto, '|' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7075
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7076
		foreach ( $p as $para ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7077
			if ( str_contains( $para, $pagelinkedto ) ) { // It exists, but is it a link?
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7078
				preg_match( '|<a[^>]+?' . $preg_target . '[^>]*>([^>]+?)</a>|', $para, $context );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7079
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7080
				// If the URL isn't in a link context, keep looking.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7081
				if ( empty( $context ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7082
					continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7083
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7084
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7085
				/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7086
				 * We're going to use this fake tag to mark the context in a bit.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7087
				 * The marker is needed in case the link text appears more than once in the paragraph.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7088
				 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7089
				$excerpt = preg_replace( '|\</?wpcontext\>|', '', $para );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7090
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7091
				// prevent really long link text
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7092
				if ( strlen( $context[1] ) > 100 ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7093
					$context[1] = substr( $context[1], 0, 100 ) . '&#8230;';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7094
				}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7095
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7096
				$marker      = '<wpcontext>' . $context[1] . '</wpcontext>';  // Set up our marker.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7097
				$excerpt     = str_replace( $context[0], $marker, $excerpt ); // Swap out the link for our marker.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7098
				$excerpt     = strip_tags( $excerpt, '<wpcontext>' );         // Strip all tags but our context marker.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7099
				$excerpt     = trim( $excerpt );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7100
				$preg_marker = preg_quote( $marker, '|' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7101
				$excerpt     = preg_replace( "|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7102
				$excerpt     = strip_tags( $excerpt ); // YES, again, to remove the marker wrapper.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7103
				break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7104
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7105
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7106
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7107
		if ( empty( $context ) ) { // Link to target not found.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7108
			return $this->pingback_error( 17, __( 'The source URL does not contain a link to the target URL, and so cannot be used as a source.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7109
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7110
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7111
		$pagelinkedfrom = str_replace( '&', '&amp;', $pagelinkedfrom );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7112
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7113
		$context        = '[&#8230;] ' . esc_html( $excerpt ) . ' [&#8230;]';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7114
		$pagelinkedfrom = $this->escape( $pagelinkedfrom );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7115
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7116
		$comment_post_id      = (int) $post_id;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7117
		$comment_author       = $title;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7118
		$comment_author_email = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7119
		$this->escape( $comment_author );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7120
		$comment_author_url = $pagelinkedfrom;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7121
		$comment_content    = $context;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7122
		$this->escape( $comment_content );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7123
		$comment_type = 'pingback';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7124
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7125
		$commentdata = array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7126
			'comment_post_ID' => $comment_post_id,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7127
		);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7128
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7129
		$commentdata += compact(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7130
			'comment_author',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7131
			'comment_author_url',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7132
			'comment_author_email',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7133
			'comment_content',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7134
			'comment_type',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7135
			'remote_source',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7136
			'remote_source_original'
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7137
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7138
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7139
		$comment_id = wp_new_comment( $commentdata );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7140
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7141
		if ( is_wp_error( $comment_id ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7142
			return $this->pingback_error( 0, $comment_id->get_error_message() );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7143
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7144
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7145
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7146
		 * Fires after a post pingback has been sent.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7147
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7148
		 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7149
		 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7150
		 * @param int $comment_id Comment ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7151
		 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7152
		do_action( 'pingback_post', $comment_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7153
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7154
		/* translators: 1: URL of the page linked from, 2: URL of the page linked to. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7155
		return sprintf( __( 'Pingback from %1$s to %2$s registered. Keep the web talking! :-)' ), $pagelinkedfrom, $pagelinkedto );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7156
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7157
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7158
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7159
	 * Retrieves an array of URLs that pingbacked the given URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7160
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7161
	 * Specs on http://www.aquarionics.com/misc/archives/blogite/0198.html
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7162
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7163
	 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7164
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7165
	 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7166
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7167
	 * @param string $url
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7168
	 * @return array|IXR_Error
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7169
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7170
	public function pingback_extensions_getPingbacks( $url ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7171
		global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7172
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7173
		/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  7174
		do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks', $url, $this );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7175
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7176
		$url = $this->escape( $url );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7177
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7178
		$post_id = url_to_postid( $url );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7179
		if ( ! $post_id ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7180
			// We aren't sure that the resource is available and/or pingback enabled.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  7181
			return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7182
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7183
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7184
		$actual_post = get_post( $post_id, ARRAY_A );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7185
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7186
		if ( ! $actual_post ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7187
			// No such post = resource not found.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7188
			return $this->pingback_error( 32, __( 'The specified target URL does not exist.' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7189
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7190
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  7191
		$comments = $wpdb->get_results( $wpdb->prepare( "SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7192
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7193
		if ( ! $comments ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7194
			return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7195
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7196
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7197
		$pingbacks = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7198
		foreach ( $comments as $comment ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  7199
			if ( 'pingback' === $comment->comment_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7200
				$pingbacks[] = $comment->comment_author_url;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  7201
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7202
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7203
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7204
		return $pingbacks;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7205
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7206
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7207
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7208
	 * Sends a pingback error based on the given error code and message.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7209
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7210
	 * @since 3.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7211
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7212
	 * @param int    $code    Error code.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7213
	 * @param string $message Error message.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7214
	 * @return IXR_Error Error object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7215
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7216
	protected function pingback_error( $code, $message ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7217
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  7218
		 * Filters the XML-RPC pingback error return.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7219
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7220
		 * @since 3.5.1
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7221
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7222
		 * @param IXR_Error $error An IXR_Error object containing the error code and message.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  7223
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7224
		return apply_filters( 'xmlrpc_pingback_error', new IXR_Error( $code, $message ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7225
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  7226
}