plugin install
This commit is contained in:
@@ -0,0 +1,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 of not enabling background updates.', '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.', 'gravityforms' ) );
|
||||
$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' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class GF_Installation_Wizard_Step_Complete extends GF_Installation_Wizard_Step {
|
||||
|
||||
protected $_name = 'complete';
|
||||
|
||||
function display() {
|
||||
|
||||
?>
|
||||
<p>
|
||||
<?php
|
||||
esc_html_e( "Congratulations! Click the 'Create A Form' button to get started.", 'gravityforms' );
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
function get_title(){
|
||||
return esc_html__( 'Installation Complete', 'gravityforms' );
|
||||
}
|
||||
|
||||
function get_next_button_text(){
|
||||
return esc_html__( 'Create A Form', 'gravityforms' );
|
||||
}
|
||||
|
||||
function get_previous_button_text(){
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
class GF_Installation_Wizard_Step_License_Key extends GF_Installation_Wizard_Step {
|
||||
public $required = true;
|
||||
|
||||
protected $_name = 'license_key';
|
||||
|
||||
public $defaults = array(
|
||||
'license_key' => '',
|
||||
'accept_terms' => false,
|
||||
);
|
||||
|
||||
function display() {
|
||||
|
||||
if ( ! $this->license_key && defined( 'GF_LICENSE_KEY' ) ) {
|
||||
$this->license_key = GF_LICENSE_KEY;
|
||||
}
|
||||
|
||||
?>
|
||||
<p>
|
||||
<?php echo sprintf( esc_html__( 'Enter your Gravity Forms License Key below. Your key unlocks access to automatic updates, the add-on installer, and support. You can find your key on the My Account page on the %sGravity Forms%s site.', 'gravityforms' ), '<a href="https://www.gravityforms.com">', '</a>' ); ?>
|
||||
|
||||
</p>
|
||||
<div>
|
||||
<input type="text" class="regular-text" id="license_key" value="<?php echo esc_attr( $this->license_key ); ?>" name="license_key" placeholder="<?php esc_attr_e('Enter Your License Key', 'gravityforms'); ?>" />
|
||||
<?php
|
||||
$key_error = $this->validation_message( 'license_key', false );
|
||||
if ( $key_error ) {
|
||||
echo $key_error;
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$message = $this->validation_message( 'accept_terms', false );
|
||||
if ( $message || $key_error || $this->accept_terms ) {
|
||||
?>
|
||||
<p>
|
||||
<?php esc_html_e( "If you don't enter a valid license key, you will not be able to update Gravity Forms when important bug fixes and security enhancements are released. This can be a serious security risk for your site.", 'gravityforms' ); ?>
|
||||
</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 the risks of not providing a valid license key.', 'gravityforms' ); ?> <span class="gfield_required">*</span>
|
||||
</label>
|
||||
<?php echo $message ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
function get_title() {
|
||||
return esc_html__( 'License Key', 'gravityforms' );
|
||||
}
|
||||
|
||||
function validate() {
|
||||
|
||||
$this->is_valid_key = true;
|
||||
$license_key = $this->license_key;
|
||||
|
||||
if ( empty ( $license_key ) ) {
|
||||
$message = esc_html__( 'Please enter a valid license key.', 'gravityforms' ) . '</span>';
|
||||
$this->set_field_validation_result( 'license_key', $message );
|
||||
$this->is_valid_key = false;
|
||||
} else {
|
||||
$key_info = GFCommon::get_key_info( $license_key );
|
||||
if ( empty( $key_info ) || ( ! $key_info['is_active'] ) ){
|
||||
$message = " <i class='fa fa-times gf_keystatus_invalid'></i> <span class='gf_keystatus_invalid_text'>" . __( 'Invalid or Expired Key : Please make sure you have entered the correct value and that your key is not expired.', 'gravityforms' ) . '</span>';
|
||||
$this->set_field_validation_result( 'license_key', $message );
|
||||
$this->is_valid_key = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->is_valid_key && ! $this->accept_terms ) {
|
||||
$this->set_field_validation_result( 'accept_terms', __( 'Please accept the terms', 'gravityforms' ) );
|
||||
}
|
||||
|
||||
$valid = $this->is_valid_key || ( ! $this->is_valid_key && $this->accept_terms );
|
||||
return $valid;
|
||||
}
|
||||
|
||||
function install() {
|
||||
if ( $this->license_key ) {
|
||||
|
||||
GFFormsModel::save_key( $this->license_key );
|
||||
|
||||
$version_info = GFCommon::get_version_info( false );
|
||||
}
|
||||
}
|
||||
|
||||
function get_previous_button_text() {
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
class GF_Installation_Wizard_Step_Settings extends GF_Installation_Wizard_Step {
|
||||
|
||||
protected $_name = 'settings';
|
||||
|
||||
public $defaults = array(
|
||||
'currency' => '',
|
||||
'enable_noconflict' => false,
|
||||
'enable_toolbar_menu' => true,
|
||||
'enable_akismet' => true,
|
||||
);
|
||||
|
||||
function display() {
|
||||
$disabled = apply_filters( 'gform_currency_disabled', false ) ? "disabled='disabled'" : ''
|
||||
?>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="gforms_currency"><?php esc_html_e( 'Currency', 'gravityforms' ); ?></label> <?php gform_tooltip( 'settings_currency' ) ?>
|
||||
</th>
|
||||
<td>
|
||||
<?php
|
||||
$disabled = apply_filters( 'gform_currency_disabled', false ) ? "disabled='disabled'" : ''
|
||||
?>
|
||||
|
||||
<select id="gforms_currency" name="currency" <?php echo $disabled ?>>
|
||||
<option value=""><?php esc_html_e( 'Select a Currency', 'gravityforms' ) ?></option>
|
||||
<?php
|
||||
$current_currency = $this->currency;
|
||||
|
||||
foreach ( RGCurrency::get_currencies() as $code => $currency ) {
|
||||
?>
|
||||
<option value="<?php echo esc_attr( $code ) ?>" <?php echo $current_currency == $code ? "selected='selected'" : '' ?>><?php echo esc_html( $currency['name'] ) ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php do_action( 'gform_currency_setting_message', '' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="gform_enable_noconflict"><?php esc_html_e( 'No-Conflict Mode', 'gravityforms' ); ?></label> <?php gform_tooltip( 'settings_noconflict' ) ?>
|
||||
</th>
|
||||
<td>
|
||||
<input type="radio" name="enable_noconflict" value="1" <?php echo $this->enable_noconflict == 1 ? "checked='checked'" : '' ?> id="gform_enable_noconflict" /> <?php esc_html_e( 'On', 'gravityforms' ); ?>
|
||||
<input type="radio" name="enable_noconflict" value="0" <?php echo $this->enable_noconflict == 1 ? '' : "checked='checked'" ?> id="gform_disable_noconflict" /> <?php esc_html_e( 'Off', 'gravityforms' ); ?>
|
||||
<br />
|
||||
<span class="gf_settings_description"><?php esc_html_e( 'Set this to ON to prevent extraneous scripts and styles from being printed on Gravity Forms admin pages, reducing conflicts with other plugins and themes.', 'gravityforms' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="gform_enable_toolbar_menu"><?php esc_html_e( 'Toolbar Menu', 'gravityforms' ); ?></label> <?php gform_tooltip( 'settings_toolbar_menu' ) ?>
|
||||
</th>
|
||||
<td>
|
||||
<input type="radio" name="enable_toolbar_menu" value="1" <?php checked( $this->enable_toolbar_menu, true ); ?> id="gform_enable_toolbar_menu" /> <?php esc_html_e( 'On', 'gravityforms' ); ?>
|
||||
<input type="radio" name="enable_toolbar_menu" value="0" <?php checked( $this->enable_toolbar_menu, false );?> id="gform_disable_toolbar_menu" /> <?php esc_html_e( 'Off', 'gravityforms' ); ?>
|
||||
<br />
|
||||
<span class="gf_settings_description"><?php esc_html_e( 'Set this to ON to display the Forms menu in the WordPress top toolbar. The Forms menu will display the latest ten forms recently opened in the form editor.', 'gravityforms' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ( GFCommon::has_akismet() ) { ?>
|
||||
<tr valign="top">
|
||||
<th scope="row">
|
||||
<label for="gforms_enable_akismet"><?php esc_html_e( 'Akismet Integration', 'gravityforms' ); ?></label> <?php gform_tooltip( 'settings_akismet' ) ?>
|
||||
</th>
|
||||
<td>
|
||||
<input type="radio" name="enable_akismet" value="1" <?php checked( $this->enable_akismet, true ) ?> id="gforms_enable_akismet" /> <?php esc_html_e( 'Yes', 'gravityforms' ); ?>
|
||||
<input type="radio" name="enable_akismet" value="0" <?php checked( $this->enable_akismet, false ) ?> /> <?php esc_html_e( 'No', 'gravityforms' ); ?>
|
||||
<br />
|
||||
<span class="gf_settings_description"><?php esc_html_e( 'Protect your form entries from spam using Akismet.', 'gravityforms' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
function get_title() {
|
||||
return esc_html__( 'Global Settings', 'gravityforms' );
|
||||
}
|
||||
|
||||
function install() {
|
||||
update_option( 'gform_enable_noconflict', (bool) $this->enable_noconflict );
|
||||
update_option( 'rg_gforms_enable_akismet', (bool) $this->enable_akismet );
|
||||
update_option( 'rg_gforms_currency', $this->currency );
|
||||
update_option( 'gform_enable_toolbar_menu', (bool) $this->enable_toolbar_menu );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
abstract class GF_Installation_Wizard_Step extends stdClass {
|
||||
|
||||
protected $_name = '';
|
||||
|
||||
protected $_field_validation_results = array();
|
||||
protected $_validation_summary = '';
|
||||
|
||||
public $defaults = array();
|
||||
private $_step_values;
|
||||
|
||||
function __construct( $values = array() ){
|
||||
if ( empty ( $this->_name ) ) {
|
||||
throw new Exception( 'Name not set' );
|
||||
}
|
||||
$this->_step_values = empty ( $values ) ? $this->defaults : $values;
|
||||
}
|
||||
|
||||
function get_name(){
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
function is( $key ) {
|
||||
return $key == $this->get_name();
|
||||
}
|
||||
|
||||
function get_title(){
|
||||
return '';
|
||||
}
|
||||
|
||||
public function __set( $key, $value ) {
|
||||
$this->_step_values[ $key ] = $value;
|
||||
}
|
||||
|
||||
public function __isset( $key ) {
|
||||
return isset( $this->_step_values[ $key ] );
|
||||
}
|
||||
|
||||
public function __unset( $key ) {
|
||||
unset( $this->_step_values[ $key ] );
|
||||
}
|
||||
|
||||
function &__get( $key ){
|
||||
if ( ! isset( $this->_step_values[ $key ] ) ) {
|
||||
$this->_step_values[ $key ] = '';
|
||||
}
|
||||
return $this->_step_values[ $key ];
|
||||
}
|
||||
|
||||
function get_values(){
|
||||
$set_values = $this->_step_values ? $this->_step_values : array();
|
||||
$values = array_merge( $this->defaults, $set_values);
|
||||
return $values;
|
||||
}
|
||||
|
||||
function display(){
|
||||
}
|
||||
|
||||
function validate(){
|
||||
// Assign $this->_validation_result;
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_field_validation_result( $key ){
|
||||
if ( ! isset( $this->_field_validation_results[ $key ] ) ) {
|
||||
$this->_field_validation_results[ $key ] = '';
|
||||
}
|
||||
return $this->_field_validation_results[ $key ];
|
||||
}
|
||||
|
||||
function set_field_validation_result( $key, $text ){
|
||||
$this->_field_validation_results[ $key ] = $text;
|
||||
}
|
||||
|
||||
function set_validation_summary( $text ) {
|
||||
$this->_validation_summary = $text;
|
||||
}
|
||||
|
||||
function get_validation_summary(){
|
||||
return $this->_validation_summary;
|
||||
}
|
||||
|
||||
function validation_message( $key, $echo = true ){
|
||||
$message = '';
|
||||
$validation_result = $this->get_field_validation_result( $key );
|
||||
if ( ! empty ( $validation_result ) ) {
|
||||
|
||||
$message = sprintf( '<div class="validation_message">%s</div>', $validation_result );
|
||||
}
|
||||
|
||||
if ( $echo ) {
|
||||
echo $message;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
|
||||
function is_complete(){
|
||||
}
|
||||
|
||||
function get_next_button_text(){
|
||||
return __( 'Next', 'gravityforms' );
|
||||
}
|
||||
|
||||
function get_previous_button_text(){
|
||||
return __( 'Back', 'gravityforms' );
|
||||
}
|
||||
|
||||
function update( $posted_values = array() ){
|
||||
$step_values = $this->get_values();
|
||||
if ( empty ( $step_values ) ) {
|
||||
$step_values = array();
|
||||
}
|
||||
$new_values = array_merge( $step_values, $posted_values );
|
||||
update_option( 'gform_installation_wizard_' . $this->get_name(), $new_values );
|
||||
$this->_step_values = $new_values;
|
||||
}
|
||||
|
||||
function summary( $echo = true ){
|
||||
return '';
|
||||
}
|
||||
|
||||
function install(){
|
||||
// do something
|
||||
}
|
||||
|
||||
function flush_values(){
|
||||
delete_option( 'gform_installation_wizard_' . $this->get_name() );
|
||||
}
|
||||
|
||||
function get_posted_values() {
|
||||
|
||||
$posted_values = stripslashes_deep( $_POST );
|
||||
$values = array();
|
||||
foreach ( $posted_values as $key => $value ) {
|
||||
if ( strpos( $key, '_', 0 ) !== 0 ) {
|
||||
$values[ $key ] = $value;
|
||||
}
|
||||
}
|
||||
$values = array_merge( $this->defaults, $values);
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user