LLMS_Abstract_Generator_Posts::add_custom_value( int $post_id, string $key, mixed $val )

Add a “custom” post meta data for a given post


Description Description

Automatically slashes JSON data when supplied.

Automatically unserializes serialized data so add_post_meta() can re-serialize.


Top ↑

Parameters Parameters

$post_id

(int) (Required) WP_Post ID.

$key

(string) (Required) Meta key.

$val

(mixed) (Required) Meta value.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/abstracts/llms-abstract-generator-posts.php

	protected function add_custom_value( $post_id, $key, $val ) {

		// If $val is a JSON string, add slashes before saving.
		if ( is_string( $val ) && null !== json_decode( $val, true ) ) {
			$val = wp_slash( $val );
		}

		add_post_meta( $post_id, $key, maybe_unserialize( $val ) );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.