class-gf-installation-wizard-step-background-updates.php
4.13 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
class GF_Installation_Wizard_Step_Background_Updates extends GF_Installation_Wizard_Step {
protected $_name = 'background_updates';
// Defaults
public $defaults = array(
'background_updates' => 'enabled',
'accept_terms' => false,
);
function display() {
?>
<p>
<?php
esc_html_e( 'Gravity Forms will download important bug fixes, security enhancements and plugin updates automatically. Updates are extremely important to the security of your WordPress site.', 'gravityforms' );
?>
</p>
<p>
<strong>
<?php
esc_html_e( 'This feature is activated by default unless you opt to disable it below. We only recommend disabling background updates if you intend on managing updates manually.', 'gravityforms' );
?>
</strong>
</p>
<?php
$license_key_step_settings = get_option( 'gform_installation_wizard_license_key' );
$is_valid_license_key = $license_key_step_settings['is_valid_key'];
if ( ! $is_valid_license_key ) :
?>
<p>
<strong>
<?php esc_html_e( 'Updates will only be available if you have entered a valid License Key', 'gravityforms' ); ?>
</strong>
</p>
<?php
endif;
?>
<div>
<label>
<input type="radio" id="background_updates_enabled" value="enabled" <?php checked( 'enabled', $this->background_updates ); ?> name="background_updates"/>
<?php esc_html_e( 'Keep background updates enabled', 'gravityforms' ); ?>
</label>
</div>
<div>
<label>
<input type="radio" id="background_updates_disabled" value="disabled" <?php checked( 'disabled', $this->background_updates ); ?> name="background_updates"/>
<?php esc_html_e( 'Turn off background updates', 'gravityforms' ); ?>
</label>
</div>
<div id="accept_terms_container" style="display:none;">
<div id="are_you_sure" style="background: #fff none repeat scroll 0 0;box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);padding: 1px 12px;border-left: 4px solid #dd3d36;margin: 5px 0 15px;display: inline-block;">
<h3 style="margin-top:0.6em;"><i class="fa fa-exclamation-triangle gf_invalid"></i> <?php _e( 'Are you sure?', 'gravityforms' ); ?>
</h3>
<p>
<strong><?php esc_html_e( 'By disabling background updates your site may not get critical bug fixes and security enhancements. We only recommend doing this if you are experienced at managing a WordPress site and accept the risks involved in manually keeping your WordPress site updated.', 'gravityforms' ); ?></strong>
</p>
</div>
<label>
<input type="checkbox" id="accept_terms" value="1" <?php checked( 1, $this->accept_terms ); ?> name="accept_terms"/>
<?php esc_html_e( 'I Understand and Accept the Risk', 'gravityforms' ); ?> <span class="gfield_required">*</span>
</label>
<?php $this->validation_message( 'accept_terms' ); ?>
</div>
<script type="text/javascript">
(function($) {
$(document).ready(function() {
var backgroundUpdatesDisabled = $('#background_updates_disabled').is(':checked');
$('#accept_terms_container').toggle(backgroundUpdatesDisabled);
$('#background_updates_disabled').click(function(){
$("#accept_terms_container").slideDown();
});
$('#background_updates_enabled').click(function(){
$('#accept_terms').prop('checked', false);
$("#accept_terms_container").slideUp();
});
})
})(jQuery);
</script>
<?php
}
function get_title(){
return esc_html__( 'Background Updates', 'gravityforms' );
}
function validate() {
$valid = true;
if ( $this->background_updates == 'enabled' ) {
$this->accept_terms = false;
} elseif ( empty( $this->accept_terms ) ) {
$this->set_field_validation_result( 'accept_terms', esc_html__( 'Please accept the terms.' ) );
$valid = false;
}
return $valid;
}
function summary( $echo = true ){
$html = $this->background_updates !== 'disabled' ? esc_html__( 'Enabled', 'gravityforms' ) . ' <i class="fa fa-check gf_valid"></i>' : esc_html__( 'Disabled', 'gravityforms' ) . ' <i class="fa fa-times gf_invalid"></i>' ;
if ( $echo ) {
echo $html;
}
return $html;
}
function install(){
update_option( 'gform_enable_background_updates', $this->background_updates != 'disabled' );
}
}