Plugin Directory

Changeset 1477386


Ignore:
Timestamp:
08/17/2016 11:40:25 PM (10 years ago)
Author:
Vincent Stark
Message:

[VID-39] Name and phone configurable options

Location:
video-capture/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • video-capture/trunk/js/record_video.js

    r1477375 r1477386  
    77  var record_btn_element = '';
    88  var record_type = '';
    9   var configure_options = {'email' :VideoCapture.collect_email,
    10                            'birthday' : VideoCapture.collect_birthday,
    11                            'location' : VideoCapture.collect_location,
    12                            'additional_data' : VideoCapture.collect_additional_data,
    13                            'language' : VideoCapture.collect_language
     9  var configure_options = { 'name' : VideoCapture.collect_name,
     10                            'email' :VideoCapture.collect_email,
     11                            'phone' : VideoCapture.collect_phone,
     12                            'birthday' : VideoCapture.collect_birthday,
     13                            'location' : VideoCapture.collect_location,
     14                            'additional_data' : VideoCapture.collect_additional_data,
     15                            'language' : VideoCapture.collect_language
    1416                          };
    1517  var required_options = required_options();
     18  var name = '';
    1619  var email = '';
     20  var phone = '';
    1721  var birthday = '';
    1822  var location = '';
     
    108112          var input_name = jQuery(this).attr('name');
    109113          switch(input_name){
     114              case 'vidrack-capture-name':
     115                name = jQuery(this).val()
     116                break;
    110117              case 'vidrack-capture-email':
    111118                email = jQuery(this).val()
    112119                break;
     120              case 'vidrack-capture-phone':
     121                phone = jQuery(this).val()
     122                break;
    113123              case 'vidrack-capture-birthday':
    114124                birthday = jQuery(this).val()
    115125                break;
    116126              case 'vidrack-capture-location':
    117                   location = jQuery(this).val()
    118                   break;
     127                location = jQuery(this).val()
     128                break;
    119129              case 'vidrack-capture-additional-data':
    120                   additional_data = jQuery(this).val();
    121                   break;
     130                additional_data = jQuery(this).val();
     131                break;
    122132              case 'vidrack-capture-language':
    123                   language = jQuery(this).val();
    124                   break;
     133                language = jQuery(this).val();
     134                break;
    125135              default :
    126136                return;
    127137                break;
    128138          }
     139          jQuery(this).next('.wp-video-capture-collect-error').hide();
    129140      }
    130141    })
     
    153164            return isEmail(input_val);
    154165            break;
     166         case 'vidrack-capture-phone':
     167             return isPhone(input_val);
     168             break;
    155169         default :
    156170            return true;
     
    197211  }
    198212
     213  // Check correct phone number.
     214  function isPhone(phone){
     215    var pattern =  new RegExp(/^[\s()+-]*([0-9][\s()+-]*){6,20}(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/i);
     216    return pattern.test(phone);
     217  }
     218
    199219  function renderSWF(element) {
    200220    // Pass SWF Video Player params
     
    204224      ip: VideoCapture.ip,
    205225      email: email,
     226      name: name,
     227      phone: phone,
    206228      birthday: birthday,
    207229      location: location,
     
    331353              ip: ip,
    332354              email: email,
     355              name: name,
     356              phone: phone,
    333357              birthday: birthday,
    334358              additional_data: additional_data,
  • video-capture/trunk/settings.php

    r1477380 r1477386  
    131131            // Register collect options.
    132132            register_setting( 'wp_video_capture-group', 'vidrack_collect_email' );
     133            register_setting( 'wp_video_capture-group', 'vidrack_collect_name' );
     134            register_setting( 'wp_video_capture-group', 'vidrack_collect_phone' );
    133135            register_setting( 'wp_video_capture-group', 'vidrack_collect_birthday' );
    134136            register_setting( 'wp_video_capture-group', 'vidrack_collect_additional_data' );
     
    173175                array(
    174176                    'field' => 'vidrack_youtube_api_secret',
     177                )
     178            );
     179           
     180            // Add name collect settings field.
     181            add_settings_field(
     182                'wp_video_capture-collect_name_options',
     183                'Collect Name',
     184                array( &$this, 'settings_field_select_collect_data' ),
     185                'wp_video_capture-collect',
     186                'wp_video_capture-section-collect',
     187                array(
     188                    'field' => 'vidrack_collect_name',
    175189                )
    176190            );
     
    187201               )
    188202           );
     203
     204            // Add phone collect settings field.
     205            add_settings_field(
     206                'wp_video_capture-collect_phone_options',
     207                'Collect Phone',
     208                array( &$this, 'settings_field_select_collect_data' ),
     209                'wp_video_capture-collect',
     210                'wp_video_capture-section-collect',
     211                array(
     212                    'field' => 'vidrack_collect_phone',
     213                )
     214            );
    189215
    190216           // Add date of birth collect settings field.
  • video-capture/trunk/templates/record-video.php

    r1477375 r1477386  
    8989    <div class="wp-video-collect-data">
    9090        <form class="wp-video-collect-data-form" method="post" action="#">
     91            <div class="wp-video-collect-data-block" data-collect="name">
     92                <label>Your name <span class="required">*</span>:</label>
     93                <input type="text" class="wp-video-collect-data-input" name='vidrack-capture-name' autocomplete="off">
     94                <div class="wp-video-capture-collect-error">Please paste correct name</div>
     95            </div>
    9196            <div class="wp-video-collect-data-block" data-collect="email">
    9297                <label>Your email <span class="required">*</span>:</label>
    9398                <input type="text" class="wp-video-collect-data-input" name='vidrack-capture-email' autocomplete="off">
    9499                <div class="wp-video-capture-collect-error">Please paste correct email</div>
     100            </div>
     101            <div class="wp-video-collect-data-block" data-collect="phone">
     102                <label>Your phone<span class="required">*</span>:</label>
     103                <input type="tel" class="wp-video-collect-data-input" name='vidrack-capture-phone' autocomplete="off">
     104                <div class="wp-video-capture-collect-error">Please paste correct phone number</div>
    95105            </div>
    96106            <div class="wp-video-collect-data-block" data-collect="birthday">
  • video-capture/trunk/wp-video-capture.php

    r1477384 r1477386  
    234234            add_option( 'vidrack_desktop_upload' );
    235235            add_option( 'vidrack_collect_email', 'no' );
     236            add_option( 'vidrack_collect_name', 'no' );
     237            add_option( 'vidrack_collect_phone', 'no' );
    236238            add_option( 'vidrack_collect_birthday', 'no' );
    237239            add_option( 'vidrack_collect_location', 'no' );
     
    339341                $configure_options_array = array( );
    340342                $configure_options_array[ 'email' ] = esc_html( get_post_meta( get_the_ID(), '_vidrack_email', true ) );
     343                $configure_options_array[ 'name' ] = esc_html( get_post_meta( get_the_ID(), '_vidrack_name', true ) );
     344                $configure_options_array[ 'phone' ] = esc_html( get_post_meta( get_the_ID(), '_vidrack_phone', true ) );
    341345                $configure_options_array[ 'birthday' ] = esc_html( get_post_meta( get_the_ID(), '_vidrack_birthday', true ) );
    342346                $configure_options_array[ 'location' ] = esc_html( get_post_meta( get_the_ID(), '_vidrack_location', true ) );
     
    484488                        'desktop_upload' => get_option( 'vidrack_desktop_upload' ),
    485489                        'collect_email' => get_option( 'vidrack_collect_email' ),
     490                        'collect_name' => get_option( 'vidrack_collect_name' ),
     491                        'collect_phone' => get_option( 'vidrack_collect_phone' ),
    486492                        'collect_birthday' => get_option( 'vidrack_collect_birthday' ),
    487493                        'collect_location' => get_option( 'vidrack_collect_location' ),
     
    618624            }
    619625
    620             if ( ! $r1 || ! $r2 || ! $r3 || ! $r4 || ! $r5 || ! $r6 || ! $r7 || ! $r8 || ! $r9 ) {
     626            if ( isset( $_POST['name'] ) ) { // Input var "name" is set?
     627                $r10 = add_post_meta( $post_id, '_vidrack_name', sanitize_text_field( wp_unslash( $_POST['name'] ), true ) ); // Input var "name" is set.
     628            } else {
     629                $r10 = true;
     630            }
     631
     632            if ( isset( $_POST['phone'] ) ) { // Input var "phone" is set?
     633                $r11 = add_post_meta( $post_id, '_vidrack_phone', sanitize_text_field( wp_unslash( $_POST['phone'] ), true ) ); // Input var "phone" is set.
     634            } else {
     635                $r11 = true;
     636            }
     637
     638            if ( ! $r1 || ! $r2 || ! $r3 || ! $r4 || ! $r5 || ! $r6 || ! $r7 || ! $r8 || ! $r9 || ! $r10|| ! $r11 ) {
    621639                echo wp_json_encode( array( 'status' => 'error', 'message' => 'Cannot add post attributes.' ) );
    622640            } else {
Note: See TracChangeset for help on using the changeset viewer.