PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 7.9.9
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v7.9.9
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
gamipress / includes / admin / upgrades / 1.2.7.php

1.2.7.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 7.9.9, at includes/admin/upgrades/1.2.7.php

66 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * 1.2.7 Upgrades
4 *
5 * @package GamiPress\Admin\Upgrades\1.2.7
6 * @since 1.2.7
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Return 1.2.7 as last required upgrade
13 *
14 * @return string
15 */
16 function gamipress_127_is_last_required_upgrade() {
17
18 return '1.2.7';
19
20 }
21 add_filter( 'gamipress_get_last_required_upgrade', 'gamipress_127_is_last_required_upgrade', 127 );
22
23 /**
24 * Process 1.2.7 upgrades
25 *
26 * @param string $stored_version
27 *
28 * @return string
29 */
30 function gamipress_127_upgrades( $stored_version ) {
31
32 if ( version_compare( $stored_version, '1.2.7', '>=' ) ) {
33 return $stored_version;
34 }
35
36 global $wpdb;
37
38 $postmeta = GamiPress()->db->postmeta;
39
40 // A bug of wrong points awards on newly created points types was discover and fixed, so old points awards need to be updated
41 $points_awards = $wpdb->get_results( $wpdb->prepare(
42 "SELECT p.post_id
43 FROM $postmeta AS p
44 WHERE p.meta_key = %s
45 AND p.meta_value = %s",
46 "_gamipress_points_type",
47 ""
48 ) );
49
50 foreach( $points_awards as $points_award ) {
51
52 // Get the points type ID
53 $points_type_id = gamipress_get_requirement_connected_id( $points_award->post_id );
54
55 if( $points_type_id ) {
56 // Update points award points type
57 update_post_meta( $points_award->post_id, '_gamipress_points_type', get_post_field( 'post_name', $points_type_id ) );
58 }
59 }
60
61 $stored_version = '1.2.7';
62
63 return $stored_version;
64
65 }
66 add_filter( 'gamipress_process_upgrades', 'gamipress_127_upgrades', 127 );