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.
Parameters Parameters
- $post_id
-
(int) (Required) WP_Post ID.
- $key
-
(string) (Required) Meta key.
- $val
-
(mixed) (Required) Meta value.
Return Return
(void)
Source Source
File: includes/abstracts/llms-abstract-generator-posts.php
146 147 148 149 150 151 152 153 154 155 | 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 ) ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |