AP_Update_Helper::migrate_votes( integer $post_id )
Description #
Migrate votes data from ap_meta
table to ap_votes
table.
Parameters #
- $post_idinteger (Required) Post ID.
Source #
File: admin/update.php
public function migrate_votes( $post_id ) { global $wpdb; if ( ! $this->meta_table_exists ) { return; } $post_id = (int) $post_id; $old_votes = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}ap_meta WHERE apmeta_type IN ('vote_up', 'vote_down') AND apmeta_actionid = {$post_id}" ); // @codingStandardsIgnoreLine $apmeta_to_delete = []; foreach ( (array) $old_votes as $vote ) { ap_add_post_vote( $post_id, $vote->apmeta_userid, 'vote_up' === $vote->apmeta_type, $vote->apmeta_value ); $apmeta_to_delete[] = $vote->apmeta_id; // Delete post meta. delete_post_meta( $post_id, '_ap_vote' ); } // Delete all migrated data. $apmeta_to_delete = sanitize_comma_delimited( $apmeta_to_delete, 'int' ); $wpdb->query( "DELETE FROM {$wpdb->prefix}ap_meta WHERE apmeta_id IN ({$apmeta_to_delete})" ); // @codingStandardsIgnoreLine }
Expand full source code Collapse full source code View on GitHub: admin/update.php:183
Add your comment