_wp_customize_changeset_filter_insert_post_data

Filters changeset post data upon insert to ensure post_name is intact.

Description

_wp_customize_changeset_filter_insert_post_data( (array) $post_data, (array) $supplied_post_data ); 

This is needed to prevent the post_name from being dropped when the post is transitioned into pending status by a contributor.

Parameters (2)

0. $post_data (array)
An array of slashed post data.
1. $supplied_post_data (array)
An array of sanitized, but otherwise unmodified post data.

Usage

  1. if ( !function_exists( '_wp_customize_changeset_filter_insert_post_data' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // An array of slashed post data. 
  5. $post_data = array(); 
  6.  
  7. // An array of sanitized, but otherwise unmodified post data. 
  8. $supplied_post_data = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _wp_customize_changeset_filter_insert_post_data($post_data, $supplied_post_data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function _wp_customize_changeset_filter_insert_post_data( $post_data, $supplied_post_data ) { 
  2. if ( isset( $post_data['post_type'] ) && 'customize_changeset' === $post_data['post_type'] ) { 
  3.  
  4. // Prevent post_name from being dropped, such as when contributor saves a changeset post as pending. 
  5. if ( empty( $post_data['post_name'] ) && ! empty( $supplied_post_data['post_name'] ) ) { 
  6. $post_data['post_name'] = $supplied_post_data['post_name']; 
  7. return $post_data;