ap_append_qameta( object $post )
Description #
Append post object with apmeta fields.
Parameters #
- $postobject (Required) Post Object.
Source #
File: includes/qameta.php
function ap_append_qameta( $post ) { // Convert object as array to prevent using __isset of WP_Post. $post_arr = (array) $post; if ( ! in_array( $post_arr['post_type'], array( 'question', 'answer' ), true ) || isset( $post_arr['ap_qameta_wrapped'] ) ) { return $post; } $exist = true; foreach ( ap_qameta_fields() as $fields_name => $val ) { if ( ! isset( $post_arr[ $fields_name ] ) ) { $exist = false; break; } } if ( ! $exist ) { $defaults = ap_get_qameta( $post->ID ); if ( ! empty( $defaults ) ) { foreach ( $defaults as $pkey => $value ) { if ( ! isset( $post_arr[ $pkey ] ) || empty( $post_arr[ $pkey ] ) ) { $post->$pkey = $value; } } } $post->terms = maybe_unserialize( $post->terms ); $post->activities = maybe_unserialize( $post->activities ); $post->votes_net = $post->votes_up - $post->votes_down; } return $post; }
Expand full source code Collapse full source code View on GitHub: includes/qameta.php:189
Add your comment