Make WordPress Core

Changeset 63677


Ignore:
Timestamp:
09/17/2026 05:57:46 PM (less than one hour ago)
Author:
desrosj
Message:

XML-RPC: Reject writes to internal-only builtin post types.

Merges r63660 to the 7.1 branch.

Props xknown, westonruter, jorbin, johnbillion.

Location:
branches/7.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/7.1

  • branches/7.1/src/wp-includes/class-wp-xmlrpc-server.php

    r63006 r63677  
    14631463                }
    14641464
     1465                // Reject writes to internal-only builtin post types (e.g. customize_changeset)
     1466                // whose intended write path is a dedicated helper, not a generic post API.
     1467                $is_internal_only = (
     1468                        empty( $post_type->public )
     1469                        && empty( $post_type->show_in_rest )
     1470                        && ! empty( $post_type->_builtin )
     1471                );
     1472
     1473                /**
     1474                 * Filters whether a post type accepts writes via XML-RPC.
     1475                 *
     1476                 * Defaults to false for internal-only builtin post types (public=false,
     1477                 * show_in_rest=false, _builtin=true), such as customize_changeset, whose
     1478                 * writes are meant to flow through dedicated helpers. Return true to opt
     1479                 * a post type back in.
     1480                 *
     1481                 * @since 7.1.1
     1482                 *
     1483                 * @param bool         $allowed   Whether the post type accepts XML-RPC writes.
     1484                 * @param WP_Post_Type $post_type The post type object.
     1485                 */
     1486                $allowed = apply_filters( 'xmlrpc_allow_post_type_writes', ! $is_internal_only, $post_type );
     1487
     1488                if ( ! $allowed ) {
     1489                        return new IXR_Error( 403, __( 'Sorry, this post type is not supported over XML-RPC.' ) );
     1490                }
     1491
    14651492                $update = ! empty( $post_data['ID'] );
    14661493
Note: See TracChangeset for help on using the changeset viewer.