Plugin Directory

Changeset 1988214


Ignore:
Timestamp:
12/07/2018 06:42:24 PM (7 years ago)
Author:
heorhiiev
Message:

Tested up to wp 5.0

Location:
cf7-phone-mask-field/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cf7-phone-mask-field/trunk/cf7-phone-mask-field.php

    r1921749 r1988214  
    88Domain Path: /assets/languages/
    99
    10 Copyright © 2017 Ruslan Heorhiiev
     10Copyright © 2018 Ruslan Heorhiiev
    1111*/
    1212
     
    5353 * Функция добавления шорткодов с участием маски
    5454 * Function add shortcodes with mask
    55  * @version 1.0
     55 * @version 1.1
    5656**/
    5757function wpcf7mf_mask_shortcode_handler( $tag ) {
     
    6868
    6969
    70     if ( $validation_error )
    71         $class .= ' wpcf7-not-valid';
     70    if ( $validation_error ) {
     71       $class .= ' wpcf7-not-valid';   
     72    }       
    7273
    7374    $atts = array();
     
    8586    $atts['tabindex'] = $tag->get_option( 'tabindex', 'int', true );
    8687
    87     if ( $tag->has_option( 'readonly' ) )
    88         $atts['readonly'] = 'readonly';
    89 
    90     if ( $tag->is_required() )
    91         $atts['aria-required'] = 'true';
     88    if ( $tag->has_option( 'readonly' ) ) {
     89        $atts['readonly'] = 'readonly';   
     90    }       
     91
     92    if ( $tag->is_required() ) {
     93        $atts['aria-required'] = 'true';
     94    }       
    9295
    9396    $atts['aria-invalid'] = $validation_error ? 'true' : 'false';
    9497   
    95     /** @var array $tag->values $values */
    96     $values = $tag->values;
    97    
    98     $mask = $values[0];   
    99     $value = $mask;
    100    
    101     if (1 < count($values)) {
    102         // если value значений больше одного предпологается, что необходимо разделать маску и placeholder поле       
    103         foreach ($values as $val) {
    104             if (!strrpos($val, '_' )) {
    105                 continue;
    106             }
     98    foreach ( $tag->values as $val ) {         
     99        if ( strrpos( $val, '_', 1 ) ) { // $val is mask ?
     100            $mask = $val;
     101        }
    107102           
    108             $mask = $val;
    109             $value = end($values) !== $mask ? end($values) : $values[0];
    110            
    111             break;           
    112         }
     103        $placeholder = $val;                     
    113104    }
    114105   
    115     $atts['placeholder'] = $value;   
     106    $atts['placeholder'] = $placeholder;   
    116107    $atts['data-mask'] = $mask;   
    117108    $atts['name'] = $tag->name;   
     
    227218                <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr( $args['content'] . '-name' ); ?>" /></td>
    228219            </tr>
     220           
    229221            <!-- msk field -->
    230222            <tr>
    231223                <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Mask', 'contact-form-7-mask-field' ) ); ?></label></th>
    232                 <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
    233                 <?php _e( 'Enter the mask for this field. <br /><code>Example: +1 (___) ___-__-__</code>', 'contact-form-7-mask-field' ); ?></td>
    234             </tr>
     224                <td><input type="text" name="values" class="maskvalue oneline" id="<?php echo esc_attr( $args['content'] . '-values' ); ?>" /><br />
     225                <?php _e( 'Enter the mask for this field. <br /><code>Example: +_ (___) ___-__-__</code>', 'contact-form-7-mask-field' ); ?></td>
     226            </tr>             
    235227       
    236228            <tr>
  • cf7-phone-mask-field/trunk/readme.txt

    r1921757 r1988214  
    33Tags: Contact Form 7, Contact Form 7 phone, mask, mask field, phone field, telephone field, telephone, custom mask, custom mask field, cf7, contact form 7 mask field, contact form 7 phone mask, contact form 7 phone field, маска ввода, маска телефонного номера
    44Requires at least: 4.0
    5 Tested up to: 4.9
     5Tested up to: 5.0
    66Stable tag: 1.1
    77License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.