AnsPress_Upgrader::migrate_votes( integer $post_id )
Description #
Migrate votes to new qameta table.
Parameters #
- $post_idinteger (Required) Post ID.
Source #
File: lib/class-anspress-upgrader.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 = array(); 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 all migrated data. $apmeta_to_delete = sanitize_comma_delimited( $apmeta_to_delete, 'int' ); if ( ! empty( $apmeta_to_delete ) ) { $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: lib/class-anspress-upgrader.php:178
Add your comment