ap_get_qameta( integer $post_id )
Description #
Get a qameta by post_id
Parameters #
- $post_idinteger (Required) Post ID.
Source #
File: includes/qameta.php
function ap_get_qameta( $post_id ) { global $wpdb; $qameta = $wpdb->get_row( $wpdb->prepare( "SELECT qm.*, p.post_type as ptype FROM {$wpdb->posts} p LEFT JOIN {$wpdb->ap_qameta} qm ON qm.post_id = p.ID WHERE p.ID = %d", $post_id ), ARRAY_A ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery // If null then append is_new. if ( empty( $qameta['post_id'] ) ) { $qameta = array( 'is_new' => true ); } $qameta = wp_parse_args( $qameta, ap_qameta_fields() ); $qameta['votes_net'] = $qameta['votes_up'] + $qameta['votes_down']; $qameta['activities'] = maybe_unserialize( $qameta['activities'] ); if ( empty( $qameta['activities'] ) ) { $qameta['activities'] = array(); } $qameta['fields'] = maybe_unserialize( $qameta['fields'] ); $qameta = (object) $qameta; return $qameta; }
Expand full source code Collapse full source code View on GitHub: includes/qameta.php:158
Add your comment