| 1 |
<?php |
| 2 |
/** |
| 3 |
* 1.3.0 Upgrades |
| 4 |
* |
| 5 |
* @package GamiPress\Admin\Upgrades\1.3.0 |
| 6 |
* @since 1.3.0 |
| 7 |
*/ |
| 8 |
// Exit if accessed directly |
| 9 |
if( !defined( 'ABSPATH' ) ) exit; |
| 10 |
|
| 11 |
/** |
| 12 |
* Return 1.3.0 as last required upgrade |
| 13 |
* |
| 14 |
* @return string |
| 15 |
*/ |
| 16 |
function gamipress_130_is_last_required_upgrade() { |
| 17 |
|
| 18 |
return '1.3.0'; |
| 19 |
|
| 20 |
} |
| 21 |
add_filter( 'gamipress_get_last_required_upgrade', 'gamipress_130_is_last_required_upgrade', 130 ); |
| 22 |
|
| 23 |
/** |
| 24 |
* Process 1.3.0 upgrades |
| 25 |
* |
| 26 |
* @param string $stored_version |
| 27 |
* |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
function gamipress_130_upgrades( $stored_version ) { |
| 31 |
|
| 32 |
if ( version_compare( $stored_version, '1.3.0', '>=' ) ) { |
| 33 |
return $stored_version; |
| 34 |
} |
| 35 |
|
| 36 |
// Setup new default GamiPress options |
| 37 |
$gamipress_settings = ( $exists = get_option( 'gamipress_settings' ) ) ? $exists : array(); |
| 38 |
|
| 39 |
// Initialize achievement earned emails settings |
| 40 |
if ( ! isset( $gamipress_settings['achievement_earned_email_content'] ) ) { |
| 41 |
|
| 42 |
$gamipress_settings['achievement_earned_email_subject'] = __( '[{site_title}] {user_first}, you unlocked the {achievement_type} {achievement_title}', 'gamipress' ); |
| 43 |
$gamipress_settings['achievement_earned_email_content'] = '<h2>' . __( 'Congratulations {user_first}!', 'gamipress' ) . '</h2>' . "\n" |
| 44 |
. '{achievement_image}' . "\n" |
| 45 |
. __( 'You unlocked the {achievement_type} {achievement_title} by completing the following steps:', 'gamipress' ) . "\n" |
| 46 |
. '{achievement_steps}' . "\n\n" |
| 47 |
. __( 'Best regards', 'gamipress' ); |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
// Initialize step completed emails settings |
| 52 |
if ( ! isset( $gamipress_settings['step_completed_email_content'] ) ) { |
| 53 |
|
| 54 |
$gamipress_settings['step_completed_email_subject'] = __( '[{site_title}] {user_first}, you complete a step of the {achievement_type} {achievement_title}', 'gamipress' ); |
| 55 |
$gamipress_settings['step_completed_email_content'] = '<h2>' . __( 'Congratulations {user_first}!', 'gamipress' ) . '</h2>' . "\n" |
| 56 |
. '{achievement_image}' . "\n" |
| 57 |
. __( 'You completed the step "{label}" of the {achievement_type} {achievement_title}!', 'gamipress' ) . "\n\n" |
| 58 |
. __( 'You need to complete the following steps to completely unlock this {achievement_type}:', 'gamipress' ) . "\n" |
| 59 |
. '{achievement_steps}' . "\n\n" |
| 60 |
. __( 'Best regards', 'gamipress' ); |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
// Initialize points award completed emails settings |
| 65 |
if ( ! isset( $gamipress_settings['points_award_completed_email_content'] ) ) { |
| 66 |
|
| 67 |
$gamipress_settings['points_award_completed_email_subject'] = __( '[{site_title}] {user_first}, you got {points} {points_type}', 'gamipress' ); |
| 68 |
$gamipress_settings['points_award_completed_email_content'] = '<h2>' . __( 'Congratulations {user_first}!', 'gamipress' ) . '</h2>' . "\n" |
| 69 |
. __( 'You got {points} {points_type} for completing "{label}".', 'gamipress' ) . "\n" |
| 70 |
. __( 'Your new {points_type} balance is:', 'gamipress' ) . "\n" |
| 71 |
. '{points_balance}' . "\n\n" |
| 72 |
. __( 'Best regards', 'gamipress' ); |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
update_option( 'gamipress_settings', $gamipress_settings ); |
| 77 |
|
| 78 |
$stored_version = '1.3.0'; |
| 79 |
|
| 80 |
return $stored_version; |
| 81 |
|
| 82 |
} |
| 83 |
add_filter( 'gamipress_process_upgrades', 'gamipress_130_upgrades', 130 ); |