Non capisco cosa non funzioni.. :(

Onaxxis

Nuovo Utente
13 Apr 2015
2
0
0
Buona sera a tutti...


ho instalato questo plugin per wordpress che tramite ajax salva ogni 10 secondi il form di Gravity Forms qualora restasse inutilizzato per poter riprendere la compilazione in un momento successivo..

Salvare, salva.. quello che non funziona è che il pulsante dovrebbe avere queste 3 visualizzazini:

Salva
Salvataggio in corso...
Salvato

Il tutto s'intoppa dopo aver cliccato su salva.. appare Salvataggio in corso... che dovrebbe restare per 3 secondi per poi far apparire la scritta Salvato (questo non accade).

Il codice è il seguente:


PHP:
<?php
/*
Plugin Name: Gravity Forms - Data Persistence Reloaded - Save Button
Description: Extends the 'Gravity Forms - Data Persistence Reloaded' plugin to add a save button to the form footer - allowing users to instantly save their form, and providing the reassurance that the form has been saved.
Version: 1.1
Author: Adrian Gordon
License: GPL2
*/

add_action('admin_notices', array('ITSP_GF_DPR_Save_Button', 'admin_warnings'), 20);

if (!class_exists('ITSP_GF_DPR_Save_Button')) {
    class ITSP_GF_DPR_Save_Button
    {
		private static $name = 'Gravity Forms - Data Persistence Reloaded - Save Button';
		private static $slug = 'itsp_gp_drp_save_button';
		
		/**
         * the save button template
         */
		public static $save_button =  "<input type='button' value='Salva' class='button gform_next_button itsg_gf_save_button' onclick='itsg_gf_save_button_ajax_function();'> "; 

        /**
         * Construct the plugin object
         */
		 public function __construct()
        {
            // register actions
            if ((self::is_gravityforms_installed())) {
			// start the plugin
			add_action('gform_enqueue_scripts', array(&$this,'itsg_gf_save_button_button_ajax'), 90, 3);
			
			}
        } // END __construct
		
		/**
         * Place the save button before the 'Next' button
         */
		function itsg_gf_next_button_markup( $next_button, $form ) {
			$save_button = self::$save_button;
			return $save_button.$next_button;
			
			

		} // END my_next_button_markup
		
		/**
         * Place the save button before the 'Submit' button
         */
		function itsg_gf_submit_button_markup( $submit_button, $form ) {
			$save_button = self::$save_button;
			return $save_button.$submit_button;
			
			
		} // END my_submit_button_markup

		/**
         * If Ajax data persistence is enabled, user is logged in and current form is not a user registration form - enqueue javascript and buttons
         */
		public function itsg_gf_save_button_button_ajax($form, $is_ajax) {
	
			if($form['ri_gfdp_persist'] == 'ajax' && is_user_logged_in() && !self::is_user_registration_form($form)) {
			
				add_action('wp_footer', array(&$this,'itsg_gf_save_button_ajax'));
				add_filter( 'gform_next_button', array(&$this,'itsg_gf_next_button_markup'), 10, 2 );
				add_filter( 'gform_submit_button', array(&$this,'itsg_gf_submit_button_markup'), 10, 2 );
				
			}
		} // END itsg_gf_save_button_button_ajax
		
		/**
         * Ajax to handle button press - 
		 *     activates the 'salva' command, 
		 *     sets the button value to 'Salvato' whilst being saved, 
		 *     sets the button value to 'Salvataggio in corso...' for three seconds to confirm to the user that the save completed,
		 *     sets the button value back to 'Salva'
         */
		public static function itsg_gf_save_button_ajax() {
		?>
				<script type="text/javascript" >
				function itsg_gf_save_button_ajax_function() {
				jQuery('.gform_body').find('.itsg_gf_save_button').prop('value', '<?php _e('Salvataggio attivo...', self::$slug); ?>');
				
					changed = true; 
					gfdp_ajax();
					jQuery(document).ajaxComplete(function(event, request, settings ) {
						if ( settings.url === '<?php echo admin_url('admin-ajax.php'); ?>' && request.responseText === 'Salvato' ) {
							itsg_gf_save_button_ajax_reset_button_function();
						}
					});
				}
								
				function itsg_gf_save_button_ajax_reset_button_function() {
					jQuery('.gform_body').find('.itsg_gf_save_button').prop('value', '<?php _e('Salvato', self::$slug); ?>');
					setTimeout(function(){
						jQuery('.gform_body').find('.itsg_gf_save_button').prop('value', '<?php _e('Salva', self::$slug); ?>');
					}, 3000);
				}
				
				</script> <?php
		} // END itsg_gf_save_button_ajax

		/*
         * Warning message if Gravity Forms is not installed and enabled
         */
		public static function admin_warnings() {
			if ( !self::is_gravityforms_installed() ) {
				$gf_message = __('Requires Gravity Forms to be installed.', self::$slug);
			}
			if ( !self::is_dpr_installed() ) {
				$gfdpr_message = __('Requires Gravity - Data Persistence Reloaded to be installed.', self::$slug);
			}
			
			if (!empty($gf_message)) {
			?>
			<div class="error">
				<p>
					<?php _e('The plugin ', self::$slug); ?><strong><?php echo self::$name; ?></strong> <?php echo $gf_message; ?><br />
					<?php _e('Please ',self::$slug); ?><a href="http://www.gravityforms.com/"><?php _e(' download the latest version',self::$slug); ?></a><?php _e(' of Gravity Forms and try again.',self::$slug) ?>
				</p>
			</div>
			<?php
			}
			
			if (!empty($gfdpr_message)) {
			?>
			<div class="error">
				<p>
					<?php _e('The plugin ', self::$slug); ?><strong><?php echo self::$name; ?></strong> <?php echo $gfdpr_message; ?><br />
					<?php _e('Please ',self::$slug); ?><a href="https://wordpress.org/plugins/gravity-forms-data-persistence-add-on-reloaded/"><?php _e(' download the latest version',self::$slug); ?></a><?php _e(' of Gravity Forms Data Persistence Add-On Reloaded and try again.',self::$slug) ?>
				</p>
			</div>
			<?php
			} 
			
		} // END admin_warnings

		/*
         * Check if GF is installed
         */
        private static function is_gravityforms_installed()
        {
            return class_exists('GFAPI');
        } // END is_gravityforms_installed
		
		/*
         * Check if Gravity Forms - Data Persistence Reloaded is installed
         */
        private static function is_dpr_installed() 
        {
            return function_exists('ri_gfdp_ajax');
        } // END is_dpr_installed
		
		private static function is_user_registration_form($form)
		{
		global $wpdb;
		
		$form_id = $form[id];
		$table_user_reg = $wpdb->prefix . "rg_userregistration";
		
		$sql = "SELECT userreg.form_id
		FROM $table_user_reg as userreg 
		WHERE userreg.form_id = $form_id";
		
		$results = $wpdb->get_results($sql);
		
		if (!empty($results)) {
			return true;
			} 
		}
		
	}
    $ITSP_GF_DPR_Save_Button = new ITSP_GF_DPR_Save_Button();
}

?>

Ringrazio anticipatamente chiunque possa dirmi come risolvere il problema.
 
Ultima modifica di un moderatore:
Discussioni simili
Autore Titolo Forum Risposte Data
otto9due Errore ricorsivo jquery, non capisco da cosa dipenda.. jQuery 1
otto9due Problema if elseif o foreach.. o non capisco cosa non funzioni.. PHP 4
M Drag and Drop non capisco le sequenze... Javascript 1
Valerio93 [PHP] non capisco come mai mi da la data NULL PHP 3
trattorino [Javascript] ho comprato questo plugin ma non capisco come installarlo Javascript 1
J [Javascript] una funzione ricorsiva che non capisco come lavori Javascript 6
A anomalia che non capisco... PHP 1
E Non capisco... PHP 1
P Non capisco se invio il socket PHP 2
playmo le animazioni con jQuery RoyalSlider dentro WP a FireFox non piacciono, non capisco WordPress 0
D LEFT JOIN... non ci capisco nulla PHP 2
E non capisco il Backtracking Java 0
L Penalizzata... ma non capisco perchè! SEO e Posizionamento 4
V Script per distanza indirizzi [era: Script Php che non capisco se funzioni !] PHP 2
P non capisco la procedura Javascript 0
I Salve,devo fare un database,ma non ci capisco MySQL 0
B recupero valore campo file ( proprio non capisco ) PHP 0
Y non capisco come sistemare... Flash 0
giorgione_tg dicitura privacy... non ci capisco nulla... Leggi, Normative e Fisco 0
giorgione_tg librerie GD non capisco.. PHP 2
D non capisco perche non funzia questi script PHP 1
M Errore che non capisco... PHP 3
felino Mac OS e Client Mail: Stato non in linea Mac e Software 1
I nome utente non esiste nel database PHP 1
L Suggerimento Pagespeed per non vedenti HTML e CSS 0
F comando di inclusione file audio in I-Pad non funziona HTML e CSS 1
M Immagini non usate WordPress 0
B Non riesco a trovare i cognomi con i caratteri speciali in Access (Microsoft 365) MS Access 0
G Numero zero null non deve visualizzare nulla PHP 0
F Paypal _xclick IPN non risponde PHP 1
R Variabile non risconosciuta dentro una funzione PHP 1
C ACCESS Aprire maschera se valore non presente in una combo MS Access 7
E Alert non viene mostrato PHP 1
felino Hardisk WD SATA 1TB 3.5" non si avvia! Hardware 4
K Scrip non funzionante Javascript 1
R jquery che cambia css di un elemento non mi funziona sulla pagina caricata da ajax Ajax 5
zorro CREATE TABLE non funziona PHP 6
L tipo boolean non funzionante su mariadb (mysql). E codice php 7.4. PHP 0
Sevenjeak Php8 non carica estenzioni PHP 0
R query DELETE non cancella i record PHP 1
otto9due Input text: accetta solo numeri e non può essere vuoto. Javascript 9
G Non vedo frecce su forme Photoshop 2
G Il mio sito dopo aver abilitato l'ssl non visualizza le immagini con indirizzi senza ssl HTML e CSS 0
P jquery refresh div non funziona Javascript 0
N Problema SEO "L'URL non si trova su Google" SEO e Posizionamento 4
S Certificato SSL non funzionante Domini 0
zorro modulo di registrazione: funziona ma non sempre PHP 2
D Form contatti non funzionante HTML e CSS 0
MarcoGrazia Trovare record nel database partendo da id non sequenziali PHP 6
M Non ho rinnovato il mio sito su Aruba... Domini 1

Discussioni simili