Description

Implement "wp_insert_post_data" filter to sanitize the post_title

Originally developed by hooking into 'title_save_pre', hence the function name of the routine that we call, this filter hooks onto 'wp_insert_post_data' since we need the context of the post_type in order to decide what to do. Previously, this hook would filter ALL titles, which meant that we couldn't use shortcodes in other post types titles even if we wanted to.
It begs the question, "why do we need all the other filters?" Like these:

add_filter( 'title_save_pre', 'oiksc_oik_api_title_save_pre' );

add_filter( 'post_title', 'oiksc_oik_api_post_title', 10, 3 );

Usage

$array = oiksc_wp_insert_post_data( $data, $postarr );

Parameters

$data

( array ) required – the post_data

$postarr

( array ) required – even more data

Returns

array the filtered $data

Source

File name: oik-shortcodes/oik-shortcodes.phpLines:

1 to 15 of 15

functionoiksc_wp_insert_post_data($data,$postarr){//bw_trace2();
switch($data['post_type']){case"oik_shortcodes":case"shortcode_example":case"oik_api":case"oik_hook":$data['post_title']=oiksc_oik_api_title_save_pre($data['post_title']);break;default:// Let shortcodes be included in the title without modification
}return($data);}