Guest User

Untitled

a guest
May 26th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. <?= do_shortcode('[contact-form-7 id="111" title="blabla"]') ?>
  2.  
  3. <?php
  4. function hidden() {
  5.  
  6. //Поля формы
  7. $source = isset($_REQUEST['utm_source']) ? $_REQUEST['utm_source'] : '' ;
  8. $term = isset($_REQUEST['utm_term']) ? $_REQUEST['utm_term'] : '' ;
  9. $campaign = isset($_REQUEST['utm_campaign']) ? $_REQUEST['utm_campaign'] : '' ;
  10. $medium = isset($_REQUEST['utm_medium']) ? $_REQUEST['utm_medium'] : '' ;
  11. $content = isset($_REQUEST['utm_content']) ? $_REQUEST['utm_content'] : '';
  12.  
  13. $html = '<input type="hidden" name="source" class="source" id="utm_source" value="'.$source.'" />';
  14. $html .= '<input type="hidden" name="term" class="term" id="utm_term" value="'.$term.'" />';
  15. $html .= '<input type="hidden" name="campaign" class="campaign" id="utm_campaign" value="'.$campaign.'" />';
  16. $html .= '<input type="hidden" name="medium" class="medium" id="utm_medium" value="'.$medium.'" />';
  17. $html .= '<input type="hidden" name="content" class="term" id="utm_content" value="'.$content.'" />';
  18. return $html;
  19. }
  20.  
  21. wpcf7_add_form_tag('hidden', 'hidden', false);
  22.  
  23. ?>
  24.  
  25. $html .= '<input type="hidden" name="city" class="wpcf7-form-control wpcf7-hidden js-city-input" value="" />';
  26.  
  27. function updateDeliveryInfo(){
  28. var geolocation = ymaps.geolocation;
  29. if(geolocation.city){
  30. $('.js-city-input').val(geolocation.city);
  31. $('.js-city').text(geolocation.city);
  32. $('.city').show();
  33. }
  34. }
  35.  
  36. add_action( 'wpcf7_init', 'my_wpcf7_add_form_tag_hidden', 0 );
  37.  
  38. function my_wpcf7_add_form_tag_hidden() {
  39. remove_action( 'wpcf7_init', 'wpcf7_add_form_tag_hidden' );
  40.  
  41. wpcf7_add_form_tag( 'hidden',
  42. 'my_wpcf7_hidden_form_tag_handler',
  43. array(
  44. 'name-attr' => true,
  45. 'display-hidden' => true,
  46. )
  47. );
  48. }
  49.  
  50. function my_wpcf7_hidden_form_tag_handler( $tag ) {
  51. $source = isset( $_REQUEST['utm_source'] ) ? $_REQUEST['utm_source'] : '';
  52. $term = isset( $_REQUEST['utm_term'] ) ? $_REQUEST['utm_term'] : '';
  53. $campaign = isset( $_REQUEST['utm_campaign'] ) ? $_REQUEST['utm_campaign'] : '';
  54. $medium = isset( $_REQUEST['utm_medium'] ) ? $_REQUEST['utm_medium'] : '';
  55. $content = isset( $_REQUEST['utm_content'] ) ? $_REQUEST['utm_content'] : '';
  56.  
  57. $html = '<input type="hidden" name="source" class="source" id="utm_source" value="' . $source . '" />';
  58.  
  59. $html .= '<input type="hidden" name="term" class="term" id="utm_term" value="' . $term . '" />';
  60. $html .= '<input type="hidden" name="campaign" class="campaign" id="utm_campaign" value="' . $campaign . '" />';
  61. $html .= '<input type="hidden" name="medium" class="medium" id="utm_medium" value="' . $medium . '" />';
  62. $html .= '<input type="hidden" name="content" class="term" id="utm_content" value="' . $content . '" />';
  63.  
  64. if ( empty( $tag->name ) ) {
  65. return $html;
  66. }
  67.  
  68. $atts = array();
  69.  
  70. $class = wpcf7_form_controls_class( $tag->type );
  71. $atts['class'] = $tag->get_class_option( $class );
  72. $atts['id'] = $tag->get_id_option();
  73.  
  74. $value = (string) reset( $tag->values );
  75. $value = $tag->get_default_option( $value );
  76. $atts['value'] = $value;
  77.  
  78. $atts['type'] = 'hidden';
  79. $atts['name'] = $tag->name;
  80. $atts = wpcf7_format_atts( $atts );
  81.  
  82. $html .= sprintf( '<input %s />', $atts );
  83.  
  84. return $html;
  85. }
Add Comment
Please, Sign In to add comment