This repository has been archived by the owner on May 4, 2018. It is now read-only.
forked from wp-premium/gravityforms
-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.php
103 lines (81 loc) · 3.27 KB
/
update.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
if ( ! class_exists( 'GFForms' ) ) {
die();
}
/**
* Class GFUpdate
*
* Handles Gravity Forms updates
*/
class GFUpdate {
public static function update_page() {
if ( ! GFCommon::current_user_can_any( 'gravityforms_view_updates' ) ) {
wp_die( esc_html__( "You don't have permissions to view this page", 'gravityforms' ) );
}
if ( ! GFCommon::ensure_wp_version() ) {
return;
}
GFCommon::cache_remote_message();
echo GFCommon::get_remote_message();
wp_print_styles( array( 'thickbox' ) );
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min';
?>
<link rel="stylesheet" href="<?php echo GFCommon::get_base_url() . "/css/admin{$min}.css?ver=" . GFForms::$version ?>" />
<div class="wrap <?php echo GFCommon::get_browser_class() ?>">
<h2><?php esc_html_e( 'Gravity Forms Updates', 'gravityforms' ) ?></h2>
<?php GFCommon::display_dismissible_message(); ?>
<?php
$version_info = GFCommon::get_version_info( false );
/**
* Fires after Gravity Forms checks for a new version
*/
do_action( 'gform_after_check_update' );
if ( version_compare( GFCommon::$version, $version_info['version'], '<' ) ) {
$plugin_file = 'gravityforms/gravityforms.php';
$upgrade_url = wp_nonce_url( 'update.php?action=upgrade-plugin&plugin=' . urlencode( $plugin_file ), 'upgrade-plugin_' . $plugin_file );
$message = __( 'There is a new version of Gravity Forms available.', 'gravityforms' );
if ( rgar( $version_info, 'is_valid_key' ) ) {
?>
<div class="gf_update_outdated alert_yellow">
<?php echo esc_html( $message ) . ' <p>' . sprintf( esc_html__( 'You can update to the latest version automatically or download the update and install it manually. %sUpdate Automatically%s %sDownload Update%s', 'gravityforms' ), "</p><a class='button-primary' href='{$upgrade_url}'>", '</a>', " <a class='button' href='{$version_info["url"]}'>", '</a>' ); ?>
</div>
<?php
} else {
?>
<div class="gf_update_expired alert_red">
<?php echo esc_html( $message ) . ' ' . sprintf( esc_html( '%sRegister%s your copy of Gravity Forms to receive access to automatic updates and support. Need a license key? %sPurchase one now%s.', 'gravityforms' ), '<a href="admin.php?page=gf_settings">', '</a>', '<a href="http://www.gravityforms.com">', '</a>' ); ?>
</div>
<?php
}
echo '<br/><br/>';
$changelog = RGForms::get_changelog();
echo $changelog;
} else {
?>
<div class="gf_update_current alert_green">
<?php esc_html_e( 'Your version of Gravity Forms is up to date.', 'gravityforms' ); ?>
</div>
<?php
}
/**
* Fires after the notifications that signal that Gravity Forms has an update/license key has expired or is needed
*/
do_action( 'gform_updates' );
?>
<div id='gform_upgrade_license' style="display:none;"></div>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery.post(ajaxurl, {
action : "gf_upgrade_license",
gf_upgrade_license: "<?php echo wp_create_nonce( 'gf_upgrade_license' ) ?>"},
function (data) {
if (data.trim().length > 0)
jQuery("#gform_upgrade_license").replaceWith(data);
}
);
});
</script>
</div>
<?php
}
}