LLMS_Generator::add_custom_values( int $post_id, array $raw )
Add custom data to a post based on the ‘custom’ array
Description Description
Parameters Parameters
- $post_id
-
(int) (Required) WP Post ID.
- $raw
-
(array) (Required) raw data.
Return Return
(void)
Source Source
File: includes/class.llms.generator.php
public function add_custom_values( $post_id, $raw ) { if ( isset( $raw['custom'] ) ) { foreach ( $raw['custom'] as $custom_key => $custom_vals ) { foreach ( $custom_vals as $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, $custom_key, maybe_unserialize( $val ) ); } } } }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.30.2 | Skip JSON evaluation for non-string values; make publicly accessible. |
3.28.3 | Add extra slashes around JSON strings. |
3.16.11 | Introduced. |