Advertisement
tribulant

widget.php

Apr 8th, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.52 KB | None | 0 0
  1. <!-- Subscribe Form -->
  2.  
  3. <?php do_action('newsletters_subscribe_before_form', $instance); ?>
  4.  
  5. <form action="<?php echo $action; ?>" onsubmit="jQuery.Watermark.HideAll();" method="post" id="<?php echo $widget_id; ?>-form" class="newsletters-form">
  6.     <?php foreach ($instance as $ikey => $ival) : ?>
  7.         <input type="hidden" name="instance[<?php echo $ikey; ?>]" value="<?php echo esc_attr(stripslashes($ival)); ?>" />
  8.     <?php endforeach; ?>
  9.    
  10.     <?php do_action('newsletters_subscribe_inside_form_top', $instance); ?>
  11.  
  12.     <div id="<?php echo $widget_id; ?>-fields">
  13.         <?php
  14.        
  15.         $list_id = (empty($_POST['list_id'])) ? $instance['list'] : $_POST['list_id'];
  16.        
  17.         ?>
  18.         <?php if ($fields = $FieldsList -> fields_by_list($list_id)) : ?>
  19.             <?php foreach ($fields as $field) : ?>
  20.                 <?php $this -> render_field($field -> id, true, $widget_id, true, true, $instance); ?>
  21.             <?php endforeach; ?>
  22.         <?php endif; ?>
  23.        
  24.         <script type="text/javascript">
  25.         jQuery(document).ready(function() {
  26.             jQuery('#<?php echo $widget_id; ?>-form .newsletters-list-checkbox').on('click', function() { newsletters_refreshfields('<?php echo $widget_id; ?>'); });
  27.             jQuery('#<?php echo $widget_id; ?>-form .newsletters-list-select').on('change', function() { newsletters_refreshfields('<?php echo $widget_id; ?>'); });
  28.         });
  29.         </script>
  30.     </div>
  31.    
  32.     <?php if ($captcha_type = $this -> use_captcha(__($instance['captcha']))) : ?>     
  33.         <?php if ($captcha_type == "rsc") : ?>
  34.             <?php
  35.            
  36.             $captcha = new ReallySimpleCaptcha();
  37.             $captcha -> bg = $Html -> hex2rgb($this -> get_option('captcha_bg'));
  38.             $captcha -> fg = $Html -> hex2rgb($this -> get_option('captcha_fg'));
  39.             $captcha_size = $this -> get_option('captcha_size');
  40.             $captcha -> img_size = array($captcha_size['w'], $captcha_size['h']);
  41.             $captcha -> char_length = $this -> get_option('captcha_chars');
  42.             $captcha -> font_size = $this -> get_option('captcha_font');
  43.             $captcha_word = $captcha -> generate_random_word();
  44.             $captcha_prefix = mt_rand();
  45.             $captcha_filename = $captcha -> generate_image($captcha_prefix, $captcha_word);
  46.             $captcha_file = plugins_url() . '/really-simple-captcha/tmp/' . $captcha_filename;
  47.            
  48.             ?>
  49.             <div class="newsletters-fieldholder <?php echo $this -> pre; ?>captcha">
  50.                 <input type="hidden" name="captcha_prefix" value="<?php echo $captcha_prefix; ?>" />
  51.                 <label for="<?php echo $this -> pre; ?>captcha_code"><?php _e('Please fill in the code below:', $this -> plugin_name); ?></label>
  52.                 <img src="<?php echo $captcha_file; ?>" alt="captcha" />
  53.                 <input <?php echo $Html -> tabindex($widget_id); ?> class="<?php echo $this -> pre; ?>captchacode <?php echo $this -> pre; ?>text <?php echo (!empty($errors['captcha_code'])) ? $this -> pre . 'fielderror' : ''; ?>" type="text" name="captcha_code" id="<?php echo $this -> pre; ?>captcha_code" value="" />
  54.             </div>
  55.         <?php elseif ($captcha_type == "recaptcha") : ?>
  56.             <?php
  57.            
  58.             $recaptcha_publickey = $this -> get_option('recaptcha_publickey');
  59.             $recaptcha_theme = $this -> get_option('recaptcha_theme');
  60.             $recaptcha_customcss = $this -> get_option('recaptcha_customcss');
  61.            
  62.             ?>
  63.             <div id="<?php echo $widget_id; ?>-recaptcha" style="display:none;" class="recaptcha_widget">
  64.                 <?php if (!empty($recaptcha_theme) && $recaptcha_theme == "custom") : ?>
  65.                     <div id="recaptcha_image" class="recaptcha_image"></div>
  66.                     <div id="recaptcha_links" class="recaptcha_links">
  67.                         <a href="javascript:Recaptcha.reload()">reload</a> |
  68.                         <a class="recaptcha_only_if_image" href="javascript:Recaptcha.switch_type('audio')">switch to audio</a>
  69.                         <a class="recaptcha_only_if_audio" href="javascript:Recaptcha.switch_type('image')">switch to image</a> |
  70.                         <a href="javascript:Recaptcha.showhelp()">help</a>
  71.                     </div>
  72.                     <div class="newsletters-fieldholder recaptcha_response">
  73.                         <label for="recaptcha_response_field" class="wpmlcustomfield"><?php _e('Type the words', $this -> plugin_name); ?></label>
  74.                         <input type="text" id="recaptcha_response_field" class="wpml widefat wpmltext recaptcha_response_field" name="recaptcha_response_field">
  75.                     </div>                 
  76.                     <style type="text/css">
  77.                     <?php echo $recaptcha_customcss; ?>
  78.                     </style>
  79.                 <?php endif; ?>
  80.             </div>
  81.             <script type="text/javascript">
  82.             jQuery(document).ready(function() {
  83.                 Recaptcha.create("<?php echo $recaptcha_publickey; ?>", "<?php echo $widget_id; ?>-recaptcha", {
  84.                     theme:"<?php echo $recaptcha_theme; ?>",
  85.                     tabindex:<?php echo $Html -> tabindex($widget_id); ?>
  86.                 });
  87.             });
  88.             </script>
  89.         <?php endif; ?>
  90.     <?php endif; ?>
  91.    
  92.     <div class="newslettername-wrapper">
  93.         <input type="text" name="newslettername" value="" id="<?php echo $widget_id; ?>newslettername" class="newslettername" />
  94.     </div>
  95.    
  96.     <div id="<?php echo $widget_id; ?>-submit" class="newsletters_submit">
  97.         <span id="newsletters_buttonwrap">
  98.             <input type="submit" class="button" name="submit" value="<?php echo esc_attr(stripslashes(__($instance['button']))); ?>" id="<?php echo $widget_id; ?>-button" />
  99.         </span>
  100.         <span id="<?php echo $widget_id; ?>-loading" class="newsletters_loading" style="display:none;">
  101.             <img src="<?php echo $this -> render_url('img' . DS . 'loading.gif', 'default', false); ?>" />
  102.         </span>
  103.     </div>
  104. </form>
  105.  
  106. <?php do_action('newsletters_subscribe_after_form', $instance); ?>
  107.  
  108. <?php $this -> render('error', array('errors' => $Subscriber -> errors)); ?>
  109.  
  110. <script type="text/javascript">
  111. jQuery(document).ready(function() {
  112.     <?php $ajax = __($instance['ajax']); ?>
  113.     <?php if (!empty($ajax) && $ajax == "Y") : ?>
  114.         jQuery('#<?php echo $widget_id; ?>-form').submit(function() {
  115.             jQuery('#<?php echo $widget_id; ?>-loading').show();
  116.             jQuery('#<?php echo $widget_id; ?>-button').button('option', 'disabled', true);
  117.             jQuery('#<?php echo $widget_id; ?> .wpmlfieldholder :input').attr('readonly', true);
  118.        
  119.             jQuery.ajax({
  120.                 url: wpmlajaxurl + 'action=wpmlsubscribe&widget=<?php echo $widget; ?>&widget_id=<?php echo $widget_id; ?>&number=<?php echo $number; ?>&nonce=<?php echo wp_create_nonce($widget); ?>',
  121.                 data: jQuery('#<?php echo $widget_id; ?>-form').serialize(),
  122.                 type: "POST",
  123.                 cache: false,
  124.                 success: function(response) {
  125.                     jQuery('#<?php echo $widget_id; ?>-wrapper').html(response);
  126.                     wpml_scroll(jQuery('#<?php echo $widget_id; ?>'));
  127.                 }
  128.             });
  129.            
  130.             return false;
  131.         });
  132.     <?php endif; ?>
  133.            
  134.     jQuery('.widget_newsletters .button').button();
  135. });
  136. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement