|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Upgrade Functions |
|
4
|
|
|
* |
|
5
|
|
|
* @package Give |
|
6
|
|
|
* @subpackage Functions/Upgrade |
|
7
|
|
|
* @copyright Copyright (c) 2016, WordImpress |
|
8
|
|
|
* @license https://opensource.org/licenses/gpl-license GNU Public License |
|
9
|
|
|
* @since 1.8 |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Check if the upgrade routine has been run for a specific action |
|
14
|
|
|
* |
|
15
|
|
|
* @since 1.0 |
|
16
|
|
|
* |
|
17
|
|
|
* @param string $upgrade_action The upgrade action to check completion for |
|
18
|
|
|
* |
|
19
|
|
|
* @return bool If the action has been added to the completed actions array |
|
20
|
|
|
*/ |
|
21
|
|
|
function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
22
|
|
|
|
|
23
|
|
|
if ( empty( $upgrade_action ) ) { |
|
24
|
|
|
return false; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
$completed_upgrades = give_get_completed_upgrades(); |
|
28
|
|
|
|
|
29
|
|
|
return in_array( $upgrade_action, $completed_upgrades ); |
|
30
|
|
|
|
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Adds an upgrade action to the completed upgrades array |
|
35
|
|
|
* |
|
36
|
|
|
* @since 1.0 |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $upgrade_action The action to add to the completed upgrades array |
|
39
|
|
|
* |
|
40
|
|
|
* @return bool If the function was successfully added |
|
41
|
|
|
*/ |
|
42
|
|
|
function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
43
|
|
|
|
|
44
|
|
|
if ( empty( $upgrade_action ) ) { |
|
45
|
|
|
return false; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
$completed_upgrades = give_get_completed_upgrades(); |
|
49
|
|
|
$completed_upgrades[] = $upgrade_action; |
|
50
|
|
|
|
|
51
|
|
|
// Remove any blanks, and only show uniques. |
|
52
|
|
|
$completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
53
|
|
|
|
|
54
|
|
|
return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Get's the array of completed upgrade actions |
|
59
|
|
|
* |
|
60
|
|
|
* @since 1.0 |
|
61
|
|
|
* @return array The array of completed upgrades |
|
62
|
|
|
*/ |
|
63
|
|
|
function give_get_completed_upgrades() { |
|
64
|
|
|
|
|
65
|
|
|
$completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
66
|
|
|
|
|
67
|
|
|
if ( false === $completed_upgrades ) { |
|
68
|
|
|
$completed_upgrades = array(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $completed_upgrades; |
|
72
|
|
|
|
|
73
|
|
|
} |