Filter hook 'content_save_pre'

in WP Core File wp-includes/customize/class-wp-customize-nav-menu-item-setting.php at line 725

View Source

content_save_pre

Filter Hook
Description
Sanitize an input. Note that parent::sanitize() erroneously does wp_unslash() on $value, but we remove that in this override. Otherwise the sanitized value.

Hook Information

File Location wp-includes/customize/class-wp-customize-nav-menu-item-setting.php View on GitHub
Hook Type Filter
Line Number 725

Hook Parameters

Type Name Description
array $value The menu item value to sanitize.

Usage Examples

Basic Usage
<?php
// Hook into content_save_pre
add_filter('content_save_pre', 'my_custom_filter', 10, 1);

function my_custom_filter($value) {
    // Your custom filtering logic here
    return $value;
}

Source Code Context

wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:725 - How this hook is used in WordPress core
<?php
 720  
 721  		/** This filter is documented in wp-includes/post.php */
 722  		$menu_item_value['attr_title'] = wp_unslash( apply_filters( 'excerpt_save_pre', wp_slash( $menu_item_value['attr_title'] ) ) );
 723  
 724  		/** This filter is documented in wp-includes/post.php */
 725  		$menu_item_value['description'] = wp_unslash( apply_filters( 'content_save_pre', wp_slash( $menu_item_value['description'] ) ) );
 726  
 727  		if ( '' !== $menu_item_value['url'] ) {
 728  			$menu_item_value['url'] = sanitize_url( $menu_item_value['url'] );
 729  			if ( '' === $menu_item_value['url'] ) {
 730  				return new WP_Error( 'invalid_url', __( 'Invalid URL.' ) ); // Fail sanitization if URL is invalid.

PHP Documentation

<?php
/**
	 * Sanitize an input.
	 *
	 * Note that parent::sanitize() erroneously does wp_unslash() on $value, but
	 * we remove that in this override.
	 *
	 * @since 4.3.0
	 * @since 5.9.0 Renamed `$menu_item_value` to `$value` for PHP 8 named parameter support.
	 *
	 * @param array $value The menu item value to sanitize.
	 * @return array|false|null|WP_Error Null or WP_Error if an input isn't valid. False if it is marked for deletion.
	 *                                   Otherwise the sanitized value.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
Related Hooks

Related hooks will be displayed here in future updates.