allow_custom_field_edits()Yoast 1.0

Allows editing of the meta fields through weblog editors like Marsedit.

Хуков нет.

Возвращает

Массив. Filtered capabilities.

Использование

allow_custom_field_edits( $required_capabilities, $capabilities, $args );
$required_capabilities(массив) (обязательный)
Capabilities that must all be true to allow action.
$capabilities(массив) (обязательный)
Array of capabilities to be checked, unused here.
$args(массив) (обязательный)
List of arguments for the specific capabilities to be checked.

Код allow_custom_field_edits() Yoast 22.4

function allow_custom_field_edits( $required_capabilities, $capabilities, $args ) {
	if ( ! in_array( $args[0], [ 'edit_post_meta', 'add_post_meta' ], true ) ) {
		return $required_capabilities;
	}

	// If this is provided, it is the post ID.
	if ( empty( $args[2] ) ) {
		return $required_capabilities;
	}

	// If this is provided, it is the custom field.
	if ( empty( $args[3] ) ) {
		return $required_capabilities;
	}

	// If the meta key is part of the plugin, grant capabilities accordingly.
	if ( strpos( $args[3], WPSEO_Meta::$meta_prefix ) === 0 && current_user_can( 'edit_post', $args[2] ) ) {
		$required_capabilities[ $args[0] ] = true;
	}

	return $required_capabilities;
}