Plugin Directory

Changeset 2740791


Ignore:
Timestamp:
06/11/2022 11:02:40 AM (4 years ago)
Author:
solaito
Message:

release v1.2.1

Location:
watts
Files:
8 added
8 deleted
10 edited
5 copied

Legend:

Unmodified
Added
Removed
  • watts/tags/1.2.1/includes/controller.php

    r2628083 r2740791  
    11<?php
    2 require_once 'auto-validation.php';
    3 class Watts_Rest_Controller
    4 {
     2require_once 'realtime-validation.php';
     3
     4class Watts_Rest_Controller {
    55    const route_namespace = 'watts/v1';
    6     public function register_routes()
    7     {
     6
     7    public function register_routes() {
    88        register_rest_route(
    99            self::route_namespace,
    1010            '/(?P<id>\d+)/validation',
    1111            [
    12                 'methods' => WP_REST_Server::CREATABLE,
     12                'methods'             => WP_REST_Server::CREATABLE,
    1313                'permission_callback' => '__return_true',
    14                 'callback' => array($this, 'auto_validation'),
     14                'callback'            => array( $this, 'realtime_validation' ),
    1515            ]
    1616        );
    1717    }
    1818
    19     public function auto_validation(WP_REST_Request $request)
    20     {
    21         $wav = new Watts_Auto_Validation();
    22         $response = $wav->main($request);
    23         return rest_ensure_response($response);
     19    public function realtime_validation( WP_REST_Request $request ) {
     20        $wrv      = new Watts_Realtime_Validation();
     21        $response = $wrv->main( $request );
     22
     23        return rest_ensure_response( $response );
    2424    }
    2525}
  • watts/tags/1.2.1/includes/css/style.css

    r2719563 r2740791  
    11.watts-validation-icon {
    2     width:30px;
    3     height:30px;
    4     vertical-align:middle;
     2    vertical-align: middle;
    53    margin-left: 10px;
     4}
     5
     6.watts-validation-icon-small {
     7    width: 20px;
     8    height: 20px;
     9}
     10
     11.watts-validation-icon-medium {
     12    width: 25px;
     13    height: 25px;
     14}
     15
     16.watts-validation-icon-large {
     17    width: 30px;
     18    height: 30px;
    619}
    720
  • watts/tags/1.2.1/modules/confirm-email.php

    r2630535 r2740791  
    11<?php
    2 if (function_exists('wpcf7_add_form_tag')) {
    3     wpcf7_add_form_tag('confirm_email', 'watts_confirm_email_form_tag_handler', true);
    4     wpcf7_add_form_tag('confirm_email*', 'watts_confirm_email_form_tag_handler', true);
    5 }
    6 
    7 function watts_confirm_email_form_tag_handler($tag)
    8 {
     2if ( function_exists( 'wpcf7_add_form_tag' ) ) {
     3    wpcf7_add_form_tag( 'confirm_email', 'watts_confirm_email_form_tag_handler', true );
     4    wpcf7_add_form_tag( 'confirm_email*', 'watts_confirm_email_form_tag_handler', true );
     5}
     6
     7function watts_confirm_email_form_tag_handler( $tag ) {
    98    if ( empty( $tag->name ) ) {
    109        return '';
     
    2322    $atts = array();
    2423
    25     $atts['class'] = $tag->get_class_option( $class );
    26     $atts['id'] = $tag->get_id_option();
     24    $atts['class']    = $tag->get_class_option( $class );
     25    $atts['id']       = $tag->get_id_option();
    2726    $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
    2827
     
    3938
    4039    if ( $validation_error ) {
    41         $atts['aria-invalid'] = 'true';
     40        $atts['aria-invalid']     = 'true';
    4241        $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
    4342            $tag->name
     
    5049
    5150    if ( $tag->has_option( 'placeholder' )
    52     or $tag->has_option( 'watermark' ) ) {
     51         or $tag->has_option( 'watermark' ) ) {
    5352        $atts['placeholder'] = $value;
    54         $value = '';
     53        $value               = '';
    5554    }
    5655
     
    8180}
    8281
    83 add_filter('wpcf7_validate_confirm_email',  'watts_confirm_email_validation_filter', 10, 2);
    84 add_filter('wpcf7_validate_confirm_email*', 'watts_confirm_email_validation_filter', 10, 2);
    85 
    86 function watts_confirm_email_validation_filter($result, $tag)
    87 {
     82add_filter( 'wpcf7_validate_confirm_email', 'watts_confirm_email_validation_filter', 10, 2 );
     83add_filter( 'wpcf7_validate_confirm_email*', 'watts_confirm_email_validation_filter', 10, 2 );
     84
     85function watts_confirm_email_validation_filter( $result, $tag ) {
    8886    $name = $tag->name;
    8987
    90     $value = isset( $_POST[$name] )
    91         ? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) )
     88    $value = isset( $_POST[ $name ] )
     89        ? trim( wp_unslash( strtr( (string) $_POST[ $name ], "\n", " " ) ) )
    9290        : '';
    9391
     
    9795        $result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
    9896    }
    99     $target = $tag->get_option( 'target' )[0];
    100     $target_value = isset($_POST[$target] )
    101         ? trim( wp_unslash( strtr( (string) $_POST[$target] , "\n", " " ) ) )
     97    $target       = $tag->get_option( 'target' )[0];
     98    $target_value = isset( $_POST[ $target ] )
     99        ? trim( wp_unslash( strtr( (string) $_POST[ $target ], "\n", " " ) ) )
    102100        : '';
    103     if ($value !== $target_value) {
    104         $result->invalidate( $tag, __('Email addresses you entered do not match.', 'watts'));
     101    if ( $value !== $target_value ) {
     102        $result->invalidate( $tag, __( 'Email addresses you entered do not match.', 'watts' ) );
    105103    }
    106104
     
    108106}
    109107
    110 add_action('wpcf7_admin_init', 'watts_add_tag_generator_confirm_email', 16, 0);
    111 
    112 function watts_add_tag_generator_confirm_email()
    113 {
     108add_action( 'wpcf7_admin_init', 'watts_add_tag_generator_confirm_email', 16, 0 );
     109
     110function watts_add_tag_generator_confirm_email() {
    114111    $tag_generator = WPCF7_TagGenerator::get_instance();
    115     $tag_generator->add('confirm-email', __('confirm email', 'watts'),
    116         'watts_tag_generator_confirm_email');
    117 }
    118 
    119 function watts_tag_generator_confirm_email($contact_form, $args = '')
    120 {
    121     $args = wp_parse_args($args, array());
     112    $tag_generator->add( 'confirm-email', __( 'confirm email', 'watts' ),
     113        'watts_tag_generator_confirm_email' );
     114}
     115
     116function watts_tag_generator_confirm_email( $contact_form, $args = '' ) {
     117    $args = wp_parse_args( $args, array() );
    122118    $type = 'confirm_email';
    123119
     
    125121
    126122    ?>
    127 <div class="control-box">
    128 <fieldset>
    129 <legend><?php echo esc_html($description); ?></legend>
    130 
    131 <table class="form-table">
    132 <tbody>
    133     <tr>
    134     <th scope="row"><?php echo esc_html(__('Field type', 'watts')); ?></th>
    135     <td>
     123    <div class="control-box">
    136124        <fieldset>
    137         <legend class="screen-reader-text"><?php echo esc_html(__('Field type', 'watts')); ?></legend>
    138         <label><input type="checkbox" name="required" /> <?php echo esc_html(__('Required field', 'watts')); ?></label>
     125            <legend><?php echo esc_html( $description ); ?></legend>
     126
     127            <table class="form-table">
     128                <tbody>
     129                <tr>
     130                    <th scope="row"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></th>
     131                    <td>
     132                        <fieldset>
     133                            <legend
     134                                class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></legend>
     135                            <label><input type="checkbox"
     136                                          name="required"/> <?php echo esc_html( __( 'Required field', 'watts' ) ); ?>
     137                            </label>
     138                        </fieldset>
     139                    </td>
     140                </tr>
     141
     142                <tr>
     143                    <th scope="row"><label
     144                            for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'watts' ) ); ?></label>
     145                    </th>
     146                    <td><input type="text" name="name" class="tg-name oneline"
     147                               id="<?php echo esc_attr( $args['content'] . '-name' ); ?>"/></td>
     148                </tr>
     149
     150                <tr>
     151                    <th scope="row"><label
     152                            for="<?php echo esc_attr( $args['content'] . '-target' ); ?>"><?php echo esc_html( __( 'Target name*', 'watts' ) ); ?></label>
     153                    </th>
     154                    <td><input type="text" name="target" class="targetvalue oneline option"
     155                               id="<?php echo esc_attr( $args['content'] . '-target' ); ?>"/></td>
     156                </tr>
     157
     158                <tr>
     159                    <th scope="row"><label
     160                            for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'watts' ) ); ?></label>
     161                    </th>
     162                    <td><input type="text" name="values" class="oneline"
     163                               id="<?php echo esc_attr( $args['content'] . '-values' ); ?>"/><br/>
     164                </tr>
     165
     166                <tr>
     167                    <th scope="row"><label
     168                            for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'watts' ) ); ?></label>
     169                    </th>
     170                    <td><input type="text" name="id" class="idvalue oneline option"
     171                               id="<?php echo esc_attr( $args['content'] . '-id' ); ?>"/></td>
     172                </tr>
     173
     174                <tr>
     175                    <th scope="row"><label
     176                            for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'watts' ) ); ?></label>
     177                    </th>
     178                    <td><input type="text" name="class" class="classvalue oneline option"
     179                               id="<?php echo esc_attr( $args['content'] . '-class' ); ?>"/></td>
     180                </tr>
     181                </tbody>
     182            </table>
    139183        </fieldset>
    140     </td>
    141     </tr>
    142 
    143     <tr>
    144     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-name'); ?>"><?php echo esc_html(__('Name', 'watts')); ?></label></th>
    145     <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr($args['content'] . '-name'); ?>" /></td>
    146     </tr>
    147 
    148     <tr>
    149     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-target'); ?>"><?php echo esc_html(__('Target name*', 'watts')); ?></label></th>
    150     <td><input type="text" name="target" class="targetvalue oneline option" id="<?php echo esc_attr($args['content'] . '-target'); ?>" /></td>
    151     </tr>
    152 
    153     <tr>
    154     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-values'); ?>"><?php echo esc_html(__('Default value', 'watts')); ?></label></th>
    155     <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr($args['content'] . '-values'); ?>" /><br />
    156     </tr>
    157 
    158     <tr>
    159     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-id'); ?>"><?php echo esc_html(__('Id attribute', 'watts')); ?></label></th>
    160     <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr($args['content'] . '-id'); ?>" /></td>
    161     </tr>
    162 
    163     <tr>
    164     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-class'); ?>"><?php echo esc_html(__('Class attribute', 'watts')); ?></label></th>
    165     <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr($args['content'] . '-class'); ?>" /></td>
    166     </tr>
    167 </tbody>
    168 </table>
    169 </fieldset>
    170 </div>
    171 
    172 <div class="insert-box">
    173     <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
    174 
    175     <div class="submitbox">
    176     <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr(__('Insert Tag', 'watts')); ?>" />
    177184    </div>
    178185
    179     <br class="clear" />
    180 
    181     <p class="description mail-tag"><label for="<?php echo esc_attr($args['content'] . '-mailtag'); ?>"><?php echo sprintf(esc_html(__("To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts')), '<strong><span class="mail-tag"></span></strong>'); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr($args['content'] . '-mailtag'); ?>" /></label></p>
    182 </div>
    183 <?php
    184 }
     186    <div class="insert-box">
     187        <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()"/>
     188
     189        <div class="submitbox">
     190            <input type="button" class="button button-primary insert-tag"
     191                   value="<?php echo esc_attr( __( 'Insert Tag', 'watts' ) ); ?>"/>
     192        </div>
     193
     194        <br class="clear"/>
     195
     196        <p class="description mail-tag"><label
     197                for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
     198                <input type="text" class="mail-tag code hidden" readonly="readonly"
     199                       id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/></label></p>
     200    </div>
     201    <?php
     202}
  • watts/tags/1.2.1/modules/dob.php

    r2648825 r2740791  
    11<?php
    22
    3 if (function_exists('wpcf7_add_form_tag')) {
    4     wpcf7_add_form_tag('dob', 'watts_dob_form_tag_handler', true);
    5     wpcf7_add_form_tag('dob*', 'watts_dob_form_tag_handler', true);
    6 }
    7 
    8 function watts_dob_form_tag_handler($tag)
    9 {
    10     if (empty($tag->name)) {
     3if ( function_exists( 'wpcf7_add_form_tag' ) ) {
     4    wpcf7_add_form_tag( 'dob', 'watts_dob_form_tag_handler', true );
     5    wpcf7_add_form_tag( 'dob*', 'watts_dob_form_tag_handler', true );
     6}
     7
     8function watts_dob_form_tag_handler( $tag ) {
     9    if ( empty( $tag->name ) ) {
    1110        return '';
    1211    }
    1312
    14     $validation_error = wpcf7_get_validation_error($tag->name);
    15 
    16     $class = wpcf7_form_controls_class($tag->type);
     13    $validation_error = wpcf7_get_validation_error( $tag->name );
     14
     15    $class = wpcf7_form_controls_class( $tag->type );
    1716
    1817    $class .= ' wpcf7-validates-as-dob';
    1918
    20     if ($validation_error) {
     19    if ( $validation_error ) {
    2120        $class .= ' wpcf7-not-valid';
    2221    }
     
    2423    $atts = array();
    2524
    26     $atts['class'] = $tag->get_class_option($class);
    27     $atts['id'] = $tag->get_id_option();
    28     $atts['tabindex'] = $tag->get_option('tabindex', 'signed_int', true);
    29     $format = isset($tag->get_option('format')[0]) ? $tag->get_option('format')[0] : 'YMD';
    30 
    31     if ($tag->is_required()) {
     25    $atts['class']    = $tag->get_class_option( $class );
     26    $atts['id']       = $tag->get_id_option();
     27    $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
     28    $format           = isset( $tag->get_option( 'format' )[0] ) ? $tag->get_option( 'format' )[0] : 'YMD';
     29
     30    if ( $tag->is_required() ) {
    3231        $atts['aria-required'] = 'true';
    3332    }
    3433
    35     if ($validation_error) {
    36         $atts['aria-invalid'] = 'true';
     34    if ( $validation_error ) {
     35        $atts['aria-invalid']     = 'true';
    3736        $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
    3837            $tag->name
     
    4241    }
    4342
    44     $value = (string) reset($tag->values);
    45 
    46     $value = $tag->get_default_option($value);
    47     if ($value) {
    48         $datetime_obj = date_create_immutable($value, wp_timezone());
    49 
    50         if ($datetime_obj) {
     43    $value         = (string) reset( $tag->values );
     44    $default_value = [
     45        'year'  => null,
     46        'month' => null,
     47        'day'   => null,
     48    ];
     49
     50    $value = $tag->get_default_option( $value );
     51    if ( $value ) {
     52        $datetime_obj = date_create_immutable( $value, wp_timezone() );
     53
     54        if ( $datetime_obj ) {
    5155            // NOTE: プルダウンのvalueが0サプレスなので、初期値も合わせる
    5256            $default_value = [
    53                 'year' => $datetime_obj->format('Y'),
    54                 'month' => $datetime_obj->format('n'),
    55                 'day' => $datetime_obj->format('j'),
     57                'year'  => $datetime_obj->format( 'Y' ),
     58                'month' => $datetime_obj->format( 'n' ),
     59                'day'   => $datetime_obj->format( 'j' ),
    5660            ];
    5761        }
     
    6064    // NOTE: 寿命をもとに生年月日の範囲を算出
    6165    $max_lifespan = 120;
    62     $start_year = intval(date_i18n('Y'));
    63     $until_year = $start_year - $max_lifespan;
     66    $start_year   = intval( date_i18n( 'Y' ) );
     67    $until_year   = $start_year - $max_lifespan;
    6468
    6569    $html_parts = [
    66         'year' => watts_dob_form_part($tag, $atts, 'year', $default_value['year'], range($start_year, $until_year), esc_html(__('Year', 'watts'))),
    67         'month' => watts_dob_form_part($tag, $atts, 'month', $default_value['month'], range(1, 12), esc_html(__('Month', 'watts'))),
    68         'day' => watts_dob_form_part($tag, $atts, 'day', $default_value['day'], range(1, 31), esc_html(__('Day', 'watts')))
     70        'year'  => watts_dob_form_part( $tag, $atts, 'year', $default_value['year'], range( $start_year, $until_year ), esc_html( __( 'Year', 'watts' ) ) ),
     71        'month' => watts_dob_form_part( $tag, $atts, 'month', $default_value['month'], range( 1, 12 ), esc_html( __( 'Month', 'watts' ) ) ),
     72        'day'   => watts_dob_form_part( $tag, $atts, 'day', $default_value['day'], range( 1, 31 ), esc_html( __( 'Day', 'watts' ) ) )
    6973    ];
    7074
    7175    $html = '';
    72     if ($format === 'DMY') {
     76    if ( $format === 'DMY' ) {
    7377        $html = $html_parts['day'] . $html_parts['month'] . $html_parts['year'];
    74     } elseif ($format === 'MDY') {
     78    } elseif ( $format === 'MDY' ) {
    7579        $html = $html_parts['month'] . $html_parts['day'] . $html_parts['year'];
    7680    } else { // default
     
    8084    $html = sprintf(
    8185        '<span class="wpcf7-form-control-wrap %1$s">%2$s%3$s</span>',
    82         sanitize_html_class($tag->name), $html, $validation_error
     86        sanitize_html_class( $tag->name ), $html, $validation_error
    8387    );
    8488
     
    8690}
    8791
    88 function watts_dob_form_part($tag, $atts, $name_key, $default_value, $values, $blank_item)
    89 {
    90     $atts['name'] = sprintf('%1$s[%2$s]', $tag->name, $name_key);
    91     $atts['id'] .= '-' . $name_key;
     92function watts_dob_form_part( $tag, $atts, $name_key, $default_value, $values, $blank_item ) {
     93    $atts['name'] = sprintf( '%1$s[%2$s]', $tag->name, $name_key );
     94    $atts['id']   .= '-' . $name_key;
    9295
    9396    $labels = $values;
    9497
    95     $include_blank = $tag->has_option('include_blank');
    96 
    97     if ($include_blank) {
    98         array_unshift($labels, $blank_item);
    99         array_unshift($values, '');
    100     }
    101 
    102     $html = '';
    103     $hangover = wpcf7_get_hangover($tag->name);
    104 
    105     foreach ($values as $key => $value) {
    106         if ($hangover) {
    107             $selected = $value === (int) $hangover[$name_key];
     98    $include_blank = $tag->has_option( 'include_blank' );
     99
     100    if ( $include_blank ) {
     101        array_unshift( $labels, $blank_item );
     102        array_unshift( $values, '' );
     103    }
     104
     105    $html     = '';
     106    $hangover = wpcf7_get_hangover( $tag->name );
     107
     108    foreach ( $values as $key => $value ) {
     109        if ( $hangover ) {
     110            $selected = $value === (int) $hangover[ $name_key ];
    108111        } else {
    109112            $selected = $value === (int) $default_value;
     
    111114
    112115        $item_atts = array(
    113             'value' => $value,
     116            'value'    => $value,
    114117            'selected' => $selected ? 'selected' : '',
    115118        );
    116119
    117         $item_atts = wpcf7_format_atts($item_atts);
    118 
    119         $label = isset($labels[$key]) ? $labels[$key] : $value;
     120        $item_atts = wpcf7_format_atts( $item_atts );
     121
     122        $label = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
    120123
    121124        $html .= sprintf(
    122125            '<option %1$s>%2$s</option>',
    123126            $item_atts,
    124             esc_html($label)
     127            esc_html( $label )
    125128        );
    126129    }
    127     $atts = wpcf7_format_atts($atts);
     130    $atts = wpcf7_format_atts( $atts );
    128131
    129132    $html = sprintf(
     
    135138}
    136139
    137 add_filter('wpcf7_posted_data_dob', 'watts_posted_data_dob', 10, 3);
    138 add_filter('wpcf7_posted_data_dob*', 'watts_posted_data_dob', 10, 3);
    139 
    140 function watts_posted_data_dob($value, $value_orig, $tag)
    141 {
    142     if (!isset($value_orig) ||
    143         !isset($value_orig['year']) ||
    144         !isset($value_orig['month']) ||
    145         !isset($value_orig['day']) ||
    146         in_array('', $value_orig, true)) {
     140add_filter( 'wpcf7_posted_data_dob', 'watts_posted_data_dob', 10, 3 );
     141add_filter( 'wpcf7_posted_data_dob*', 'watts_posted_data_dob', 10, 3 );
     142
     143function watts_posted_data_dob( $value, $value_orig, $tag ) {
     144    if ( ! isset( $value_orig ) ||
     145         ! isset( $value_orig['year'] ) ||
     146         ! isset( $value_orig['month'] ) ||
     147         ! isset( $value_orig['day'] ) ||
     148         in_array( '', $value_orig, true ) ) {
    147149        return '';
    148150    }
    149151
    150     $format = isset($tag->get_option('format')[0]) ? $tag->get_option('format')[0] : 'YMD';
    151     $separator_option = isset($tag->get_option('separator')[0]) ? $tag->get_option('separator')[0] : 'slash';
    152     $separator_map = [
    153         'slash' => '/',
    154         'dash' => '-',
     152    $format           = isset( $tag->get_option( 'format' )[0] ) ? $tag->get_option( 'format' )[0] : 'YMD';
     153    $separator_option = isset( $tag->get_option( 'separator' )[0] ) ? $tag->get_option( 'separator' )[0] : 'slash';
     154    $separator_map    = [
     155        'slash'  => '/',
     156        'dash'   => '-',
    155157        'period' => '.',
    156         'comma' => ',',
    157         'blank' => ' '
    158     ];
    159     $separator = array_key_exists($separator_option, $separator_map) ? $separator_map[$separator_option] : '/';
    160     $leading_zero= $tag->has_option('leading_zero');
    161 
    162     $year = $value_orig['year'];
    163     $month= $value_orig['month'];
    164     $day = $value_orig['day'];
    165     if($leading_zero) {
    166         $month= str_pad($month, 2, '0', STR_PAD_LEFT);
    167         $day = str_pad($day, 2, '0', STR_PAD_LEFT);
     158        'comma'  => ',',
     159        'blank'  => ' '
     160    ];
     161    $separator        = array_key_exists( $separator_option, $separator_map ) ? $separator_map[ $separator_option ] : '/';
     162    $leading_zero     = $tag->has_option( 'leading_zero' );
     163
     164    $year  = $value_orig['year'];
     165    $month = $value_orig['month'];
     166    $day   = $value_orig['day'];
     167    if ( $leading_zero ) {
     168        $month = str_pad( $month, 2, '0', STR_PAD_LEFT );
     169        $day   = str_pad( $day, 2, '0', STR_PAD_LEFT );
    168170    }
    169171
    170172    $result = '';
    171     if ($format === 'DMY') {
    172         $result = implode([$day, $month, $year], $separator);
    173     } elseif ($format === 'MDY') {
    174         $result = implode([$month, $day, $year], $separator);
     173    if ( $format === 'DMY' ) {
     174        $result = implode( [ $day, $month, $year ], $separator );
     175    } elseif ( $format === 'MDY' ) {
     176        $result = implode( [ $month, $day, $year ], $separator );
    175177    } else { // default
    176         $result = implode([$year, $month, $day], $separator);
     178        $result = implode( [ $year, $month, $day ], $separator );
    177179    }
    178180
     
    180182}
    181183
    182 add_filter('wpcf7_validate_dob', 'watts_dob_validation_filter', 10, 2);
    183 add_filter('wpcf7_validate_dob*', 'watts_dob_validation_filter', 10, 2);
    184 
    185 function watts_dob_validation_filter($result, $tag)
    186 {
     184add_filter( 'wpcf7_validate_dob', 'watts_dob_validation_filter', 10, 2 );
     185add_filter( 'wpcf7_validate_dob*', 'watts_dob_validation_filter', 10, 2 );
     186
     187function watts_dob_validation_filter( $result, $tag ) {
    187188    $name = $tag->name;
    188189
    189190    $values = [
    190         'year' => isset($_POST[$name]['year']) ? trim(sanitize_text_field($_POST[$name]['year'])) : '',
    191         'month' => isset($_POST[$name]['month']) ? trim(sanitize_text_field($_POST[$name]['month'])) : '',
    192         'day' => isset($_POST[$name]['day']) ? trim(sanitize_text_field($_POST[$name]['day'])) : '',
     191        'year'  => isset( $_POST[ $name ]['year'] ) ? trim( sanitize_text_field( $_POST[ $name ]['year'] ) ) : '',
     192        'month' => isset( $_POST[ $name ]['month'] ) ? trim( sanitize_text_field( $_POST[ $name ]['month'] ) ) : '',
     193        'day'   => isset( $_POST[ $name ]['day'] ) ? trim( sanitize_text_field( $_POST[ $name ]['day'] ) ) : '',
    193194    ];
    194195
    195196    $blank_flags = [
    196         'year' => $values['year'] === '',
     197        'year'  => $values['year'] === '',
    197198        'month' => $values['month'] === '',
    198         'day' => $values['day'] === '',
    199     ];
    200 
    201     if (!in_array(false, $blank_flags, true) !== false) {
     199        'day'   => $values['day'] === '',
     200    ];
     201
     202    if ( ! in_array( false, $blank_flags, true ) !== false ) {
    202203        // すべて入力されていない
    203         if ($tag->is_required()) {
     204        if ( $tag->is_required() ) {
    204205            // 必須項目
    205206            $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
    206207        }
    207208        // 必須項目ではなく、全て入力されていない場合は許容
    208     } else if (in_array(true, $blank_flags, true) !== false) {
     209    } else if ( in_array( true, $blank_flags, true ) !== false ) {
    209210        // 中途半端な入力
    210211        $result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
    211     } else if (in_array(false, array_map('is_numeric', array_values($values)), true)) {
     212    } else if ( in_array( false, array_map( 'is_numeric', array_values( $values ) ), true ) ) {
    212213        // 数値かどうか
    213214        $result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
    214     } else if (!checkdate($values['month'], $values['day'], $values['year'])) {
     215    } else if ( ! checkdate( $values['month'], $values['day'], $values['year'] ) ) {
    215216        // 数値が入力されていた場合のチェック
    216         $result->invalidate( $tag, __('The date specified is not a valid date value.', 'watts'));
     217        $result->invalidate( $tag, __( 'The date specified is not a valid date value.', 'watts' ) );
    217218    }
    218219
     
    220221}
    221222
    222 add_action('wpcf7_admin_init', 'watts_add_tag_generator_dob', 20, 0);
    223 
    224 function watts_add_tag_generator_dob()
    225 {
     223add_action( 'wpcf7_admin_init', 'watts_add_tag_generator_dob', 20, 0 );
     224
     225function watts_add_tag_generator_dob() {
    226226    $tag_generator = WPCF7_TagGenerator::get_instance();
    227     $tag_generator->add('dob', __('DOB', 'watts'),
    228         'watts_tag_generator_dob');
    229 }
    230 
    231 function watts_tag_generator_dob($contact_form, $args = '')
    232 {
    233     $args = wp_parse_args($args, array());
     227    $tag_generator->add( 'dob', __( 'DOB', 'watts' ),
     228        'watts_tag_generator_dob' );
     229}
     230
     231function watts_tag_generator_dob( $contact_form, $args = '' ) {
     232    $args = wp_parse_args( $args, array() );
    234233    $type = 'dob';
    235234
     
    237236
    238237    ?>
    239 <div class="control-box">
    240 <fieldset>
    241 <legend><?php echo esc_html($description); ?></legend>
    242 
    243 <table class="form-table">
    244 <tbody>
    245     <tr>
    246     <th scope="row"><?php echo esc_html(__('Field type', 'watts')); ?></th>
    247     <td>
     238    <div class="control-box">
    248239        <fieldset>
    249         <legend class="screen-reader-text"><?php echo esc_html(__('Field type', 'watts')); ?></legend>
    250         <label><input type="checkbox" name="required" /> <?php echo esc_html(__('Required field', 'watts')); ?></label>
     240            <legend><?php echo esc_html( $description ); ?></legend>
     241
     242            <table class="form-table">
     243                <tbody>
     244                <tr>
     245                    <th scope="row"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></th>
     246                    <td>
     247                        <fieldset>
     248                            <legend
     249                                class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></legend>
     250                            <label><input type="checkbox"
     251                                          name="required"/> <?php echo esc_html( __( 'Required field', 'watts' ) ); ?>
     252                            </label>
     253                        </fieldset>
     254                    </td>
     255                </tr>
     256
     257                <tr>
     258                    <th scope="row"><label
     259                            for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'watts' ) ); ?></label>
     260                    </th>
     261                    <td><input type="text" name="name" class="tg-name oneline"
     262                               id="<?php echo esc_attr( $args['content'] . '-name' ); ?>"/></td>
     263                </tr>
     264
     265                <tr>
     266                    <th scope="row"><label
     267                            for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'watts' ) ); ?></label>
     268                    </th>
     269                    <td><input type="text" name="values" class="oneline"
     270                               id="<?php echo esc_attr( $args['content'] . '-values' ); ?>"/><br/>
     271                </tr>
     272
     273                <tr>
     274                    <th scope="row"><?php echo esc_html( __( 'Options', 'watts' ) ); ?></th>
     275                    <td>
     276                        <fieldset>
     277                            <legend
     278                                class="screen-reader-text"><?php echo esc_html( __( 'Options', 'watts' ) ); ?></legend>
     279                            <label><input type="checkbox" name="include_blank"
     280                                          class="option"/> <?php echo esc_html( __( 'Insert a blank item as the first option', 'watts' ) ); ?>
     281                            </label>
     282                        </fieldset>
     283                    </td>
     284                </tr>
     285
     286                <tr>
     287                    <th scope="row" rowspan="3"><?php echo esc_html( __( 'Date Format', 'watts' ) ); ?></th>
     288                    <td>
     289                        <fieldset>
     290                            <legend><?php echo esc_html( __( 'Date Style', 'watts' ) ); ?></legend>
     291                            <input type="radio" name="format" class="formatvalue option"
     292                                   id="<?php echo esc_attr( $args['content'] . '-format-ymd' ); ?>" value="YMD" checked>
     293                            <label for="<?php echo esc_attr( $args['content'] . '-format-ymd' ); ?>">YMD</label>
     294                            <input type="radio" name="format" class="formatvalue option"
     295                                   id="<?php echo esc_attr( $args['content'] . '-format-mdy' ); ?>" value="MDY">
     296                            <label for="<?php echo esc_attr( $args['content'] . '-format-mdy' ); ?>">MDY</label>
     297                            <input type="radio" name="format" class="formatvalue option"
     298                                   id="<?php echo esc_attr( $args['content'] . '-format-dmy' ); ?>" value="DMY">
     299                            <label for="<?php echo esc_attr( $args['content'] . '-format-dmy' ); ?>">DMY</label>
     300                        </fieldset>
     301                    </td>
     302                </tr>
     303                <tr>
     304                    <td>
     305                        <fieldset>
     306                            <legend><?php echo esc_html( __( 'Date Separator', 'watts' ) ); ?></legend>
     307                            <input type="radio" name="separator" class="separatorvalue option"
     308                                   id="<?php echo esc_attr( $args['content'] . '-separator-slash' ); ?>" value="slash"
     309                                   checked>
     310                            <label
     311                                for="<?php echo esc_attr( $args['content'] . '-separator-slash' ); ?>"><?php echo esc_html( __( 'slash', 'watts' ) ); ?></label>
     312                            <input type="radio" name="separator" class="separatorvalue option"
     313                                   id="<?php echo esc_attr( $args['content'] . '-separator-dash' ); ?>" value="dash">
     314                            <label
     315                                for="<?php echo esc_attr( $args['content'] . '-separator-dash' ); ?>"><?php echo esc_html( __( 'dash', 'watts' ) ); ?></label>
     316                            <input type="radio" name="separator" class="separatorvalue option"
     317                                   id="<?php echo esc_attr( $args['content'] . '-separator-period' ); ?>"
     318                                   value="period">
     319                            <label
     320                                for="<?php echo esc_attr( $args['content'] . '-separator-period' ); ?>"><?php echo esc_html( __( 'period', 'watts' ) ); ?></label>
     321                            <input type="radio" name="separator" class="separatorvalue option"
     322                                   id="<?php echo esc_attr( $args['content'] . '-separator-comma' ); ?>" value="comma">
     323                            <label
     324                                for="<?php echo esc_attr( $args['content'] . '-separator-comma' ); ?>"><?php echo esc_html( __( 'comma', 'watts' ) ); ?></label>
     325                            <input type="radio" name="separator" class="separatorvalue option"
     326                                   id="<?php echo esc_attr( $args['content'] . '-separator-blank' ); ?>" value="blank">
     327                            <label
     328                                for="<?php echo esc_attr( $args['content'] . '-separator-blank' ); ?>"><?php echo esc_html( __( 'blank', 'watts' ) ); ?></label>
     329                        </fieldset>
     330                    </td>
     331                </tr>
     332
     333                <tr>
     334                    <td>
     335                        <fieldset>
     336                            <legend><?php echo esc_html( __( 'Display Leading Zero', 'watts' ) ); ?></legend>
     337                            <label><input type="checkbox" name="leading_zero"
     338                                          class="option"/> <?php echo esc_html( __( 'Indicates whether to display (or suppress) leading zeros.', 'watts' ) ); ?>
     339                            </label>
     340                        </fieldset>
     341                    </td>
     342                </tr>
     343
     344                <tr>
     345                    <th scope="row"><label
     346                            for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'watts' ) ); ?></label>
     347                    </th>
     348                    <td><input type="text" name="id" class="idvalue oneline option"
     349                               id="<?php echo esc_attr( $args['content'] . '-id' ); ?>"/></td>
     350                </tr>
     351
     352                <tr>
     353                    <th scope="row"><label
     354                            for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'watts' ) ); ?></label>
     355                    </th>
     356                    <td><input type="text" name="class" class="classvalue oneline option"
     357                               id="<?php echo esc_attr( $args['content'] . '-class' ); ?>"/></td>
     358                </tr>
     359                </tbody>
     360            </table>
    251361        </fieldset>
    252     </td>
    253     </tr>
    254 
    255     <tr>
    256     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-name'); ?>"><?php echo esc_html(__('Name', 'watts')); ?></label></th>
    257     <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr($args['content'] . '-name'); ?>" /></td>
    258     </tr>
    259 
    260     <tr>
    261     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-values'); ?>"><?php echo esc_html(__('Default value', 'watts')); ?></label></th>
    262     <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr($args['content'] . '-values'); ?>" /><br />
    263     </tr>
    264 
    265     <tr>
    266     <th scope="row"><?php echo esc_html(__('Options', 'watts')); ?></th>
    267     <td>
    268         <fieldset>
    269         <legend class="screen-reader-text"><?php echo esc_html(__('Options', 'watts')); ?></legend>
    270         <label><input type="checkbox" name="include_blank" class="option" /> <?php echo esc_html(__('Insert a blank item as the first option', 'watts')); ?></label>
    271         </fieldset>
    272     </td>
    273     </tr>
    274 
    275     <tr>
    276     <th scope="row" rowspan="3"><?php echo esc_html(__('Date Format', 'watts')); ?></th>
    277     <td>
    278         <fieldset>
    279             <legend><?php echo esc_html(__('Date Style', 'watts')); ?></legend>
    280             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-ymd'); ?>" value="YMD" checked >
    281             <label for="<?php echo esc_attr($args['content'] . '-format-ymd'); ?>">YMD</label>
    282             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-mdy'); ?>" value="MDY" >
    283             <label for="<?php echo esc_attr($args['content'] . '-format-mdy'); ?>">MDY</label>
    284             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-dmy'); ?>" value="DMY" >
    285             <label for="<?php echo esc_attr($args['content'] . '-format-dmy'); ?>">DMY</label>
    286         </fieldset>
    287     </td>
    288     </tr>
    289     <tr>
    290     <td>
    291         <fieldset>
    292             <legend><?php echo esc_html(__('Date Separator', 'watts')); ?></legend>
    293             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-slash'); ?>" value="slash" checked >
    294             <label for="<?php echo esc_attr($args['content'] . '-separator-slash'); ?>"><?php echo esc_html(__('slash', 'watts')); ?></label>
    295             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-dash'); ?>" value="dash" >
    296             <label for="<?php echo esc_attr($args['content'] . '-separator-dash'); ?>"><?php echo esc_html(__('dash', 'watts')); ?></label>
    297             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-period'); ?>" value="period" >
    298             <label for="<?php echo esc_attr($args['content'] . '-separator-period'); ?>"><?php echo esc_html(__('period', 'watts')); ?></label>
    299             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-comma'); ?>" value="comma" >
    300             <label for="<?php echo esc_attr($args['content'] . '-separator-comma'); ?>"><?php echo esc_html(__('comma', 'watts')); ?></label>
    301             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-blank'); ?>" value="blank" >
    302             <label for="<?php echo esc_attr($args['content'] . '-separator-blank'); ?>"><?php echo esc_html(__('blank', 'watts')); ?></label>
    303         </fieldset>
    304     </td>
    305     </tr>
    306 
    307     <tr>
    308     <td>
    309         <fieldset>
    310         <legend><?php echo esc_html(__('Display Leading Zero', 'watts')); ?></legend>
    311         <label><input type="checkbox" name="leading_zero" class="option" /> <?php echo esc_html(__('Indicates whether to display (or suppress) leading zeros.', 'watts')); ?></label>
    312         </fieldset>
    313     </td>
    314     </tr>
    315 
    316     <tr>
    317     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-id'); ?>"><?php echo esc_html(__('Id attribute', 'watts')); ?></label></th>
    318     <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr($args['content'] . '-id'); ?>" /></td>
    319     </tr>
    320 
    321     <tr>
    322     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-class'); ?>"><?php echo esc_html(__('Class attribute', 'watts')); ?></label></th>
    323     <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr($args['content'] . '-class'); ?>" /></td>
    324     </tr>
    325 </tbody>
    326 </table>
    327 </fieldset>
    328 </div>
    329 
    330 <div class="insert-box">
    331     <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
    332 
    333     <div class="submitbox">
    334     <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr(__('Insert Tag', 'watts')); ?>" />
    335362    </div>
    336363
    337     <br class="clear" />
    338 
    339     <p class="description mail-tag"><label for="<?php echo esc_attr($args['content'] . '-mailtag'); ?>"><?php echo sprintf(esc_html(__("To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts')), '<strong><span class="mail-tag"></span></strong>'); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr($args['content'] . '-mailtag'); ?>" /></label></p>
    340 </div>
    341 <?php
    342 }
     364    <div class="insert-box">
     365        <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()"/>
     366
     367        <div class="submitbox">
     368            <input type="button" class="button button-primary insert-tag"
     369                   value="<?php echo esc_attr( __( 'Insert Tag', 'watts' ) ); ?>"/>
     370        </div>
     371
     372        <br class="clear"/>
     373
     374        <p class="description mail-tag"><label
     375                for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
     376                <input type="text" class="mail-tag code hidden" readonly="readonly"
     377                       id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/></label></p>
     378    </div>
     379    <?php
     380}
  • watts/tags/1.2.1/readme.txt

    r2719562 r2740791  
    66Tested up to: 5.9.3
    77Requires PHP: 5.6
    8 Stable tag: 1.2.0
     8Stable tag: 1.2.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5757== Changelog ==
    5858
     59= 1.2.1 =
     60* Added settings page.
     61
    5962= 1.2.0 =
    6063* Supports icon display showing validation results.
  • watts/tags/1.2.1/watts.php

    r2719562 r2740791  
    77 * Author URI:      https://github.com/solaito/
    88 * Text Domain:     watts
    9  * Domain Path:     /languages
    10  * Version:         1.2.0
     9 * Version:         1.2.1
    1110 *
    1211 * @package         Watts
    1312 */
    1413
     14define( "WATTS_PLUGIN", __FILE__ );
     15define( "WATTS_PLUGIN_BASENAME", plugin_basename( WATTS_PLUGIN ) );
     16define( "WATTS_PLUGIN_DIR_URL", plugin_dir_url( WATTS_PLUGIN ) );
     17
     18require_once 'includes/options-page.php';
    1519require_once 'includes/controller.php';
    1620
     
    1822require_once "modules/confirm-email.php";
    1923
    20 add_action('wp_enqueue_scripts', 'watts_enqueue_scripts');
    21 function watts_enqueue_scripts()
    22 {
    23     $data = get_file_data(__FILE__, array('version' => 'Version'));
     24add_action( 'wp_enqueue_scripts', 'watts_enqueue_scripts' );
     25function watts_enqueue_scripts() {
     26    $data    = get_file_data( WATTS_PLUGIN, array( 'version' => 'Version' ) );
    2427    $version = $data['version'];
    25     if (in_array(get_locale(), ['ja', 'ko_KR', 'zh_CN', 'zh_HK', 'zh_TW'], true)) {
    26         wp_enqueue_script('watts-zenkaku-to-hankaku', plugin_dir_url(__FILE__) . 'includes/js/zenkaku-to-hankaku.js', array('contact-form-7'), $version);
     28    $options = get_option( 'watts_option_name' );
     29    if ( $options[ Watts_Options_Page::IDS['FULL_TO_HALF_ENABLE'] ] === 'on' ) {
     30        wp_enqueue_script( 'watts-full-to-half', WATTS_PLUGIN_DIR_URL . 'includes/js/full-to-half.js', array( 'contact-form-7' ), $version );
    2731    }
    28     if(!(strstr($_SERVER['HTTP_USER_AGENT'], 'Trident') || strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))) {
    29         wp_enqueue_script('watts-auto-validation', plugin_dir_url(__FILE__) . 'includes/js/auto-validation.js', array('contact-form-7'), $version);
    30         $watts= array(
    31             'api' => array(
    32                     'root' => esc_url_raw( get_rest_url() ),
     32    if ( $options[ Watts_Options_Page::IDS['REALTIME_VALIDATION_ENABLE'] ] === 'on' ) {
     33        if ( ! ( strstr( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) || strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) ) ) {
     34            wp_enqueue_script( 'watts-realtime-validation', WATTS_PLUGIN_DIR_URL . 'includes/js/realtime-validation.js', array( 'contact-form-7' ), $version );
     35            $watts = array(
     36                'api'    => array(
     37                    'root'      => esc_url_raw( get_rest_url() ),
    3338                    'namespace' => 'watts/v1',
    34             ),
    35             'plugin' => array(
    36                     'dir' => esc_url_raw(plugin_dir_url(__FILE__)),
    37             )
    38         );
    39         wp_localize_script( 'watts-auto-validation', 'watts', $watts );
     39                ),
     40                'plugin' => array(
     41                    'dir'                  => esc_url_raw( WATTS_PLUGIN_DIR_URL ),
     42                    'validate_icon_enable' => $options[ Watts_Options_Page::IDS['VALIDATE_ICON_ENABLE'] ] === 'on',
     43                    'validate_icon_size'   => isset( $options[ Watts_Options_Page::IDS['VALIDATE_ICON_SIZE'] ] ) ? $options[ Watts_Options_Page::IDS['VALIDATE_ICON_SIZE'] ] : 'medium',
     44                )
     45            );
     46            wp_localize_script( 'watts-realtime-validation', 'watts', $watts );
     47        }
    4048    }
    41     wp_enqueue_style('watts', plugin_dir_url(__FILE__) . 'includes/css/style.css', array('contact-form-7'), $version);
     49    wp_enqueue_style( 'watts', WATTS_PLUGIN_DIR_URL . 'includes/css/style.css', array( 'contact-form-7' ), $version );
    4250}
    4351
    44 add_action('rest_api_init', function () {
     52add_action( 'rest_api_init', function () {
    4553    $controller = new Watts_Rest_Controller;
    4654    $controller->register_routes();
    47 });
     55} );
  • watts/trunk/includes/controller.php

    r2628083 r2740791  
    11<?php
    2 require_once 'auto-validation.php';
    3 class Watts_Rest_Controller
    4 {
     2require_once 'realtime-validation.php';
     3
     4class Watts_Rest_Controller {
    55    const route_namespace = 'watts/v1';
    6     public function register_routes()
    7     {
     6
     7    public function register_routes() {
    88        register_rest_route(
    99            self::route_namespace,
    1010            '/(?P<id>\d+)/validation',
    1111            [
    12                 'methods' => WP_REST_Server::CREATABLE,
     12                'methods'             => WP_REST_Server::CREATABLE,
    1313                'permission_callback' => '__return_true',
    14                 'callback' => array($this, 'auto_validation'),
     14                'callback'            => array( $this, 'realtime_validation' ),
    1515            ]
    1616        );
    1717    }
    1818
    19     public function auto_validation(WP_REST_Request $request)
    20     {
    21         $wav = new Watts_Auto_Validation();
    22         $response = $wav->main($request);
    23         return rest_ensure_response($response);
     19    public function realtime_validation( WP_REST_Request $request ) {
     20        $wrv      = new Watts_Realtime_Validation();
     21        $response = $wrv->main( $request );
     22
     23        return rest_ensure_response( $response );
    2424    }
    2525}
  • watts/trunk/includes/css/style.css

    r2719563 r2740791  
    11.watts-validation-icon {
    2     width:30px;
    3     height:30px;
    4     vertical-align:middle;
     2    vertical-align: middle;
    53    margin-left: 10px;
     4}
     5
     6.watts-validation-icon-small {
     7    width: 20px;
     8    height: 20px;
     9}
     10
     11.watts-validation-icon-medium {
     12    width: 25px;
     13    height: 25px;
     14}
     15
     16.watts-validation-icon-large {
     17    width: 30px;
     18    height: 30px;
    619}
    720
  • watts/trunk/modules/confirm-email.php

    r2630535 r2740791  
    11<?php
    2 if (function_exists('wpcf7_add_form_tag')) {
    3     wpcf7_add_form_tag('confirm_email', 'watts_confirm_email_form_tag_handler', true);
    4     wpcf7_add_form_tag('confirm_email*', 'watts_confirm_email_form_tag_handler', true);
    5 }
    6 
    7 function watts_confirm_email_form_tag_handler($tag)
    8 {
     2if ( function_exists( 'wpcf7_add_form_tag' ) ) {
     3    wpcf7_add_form_tag( 'confirm_email', 'watts_confirm_email_form_tag_handler', true );
     4    wpcf7_add_form_tag( 'confirm_email*', 'watts_confirm_email_form_tag_handler', true );
     5}
     6
     7function watts_confirm_email_form_tag_handler( $tag ) {
    98    if ( empty( $tag->name ) ) {
    109        return '';
     
    2322    $atts = array();
    2423
    25     $atts['class'] = $tag->get_class_option( $class );
    26     $atts['id'] = $tag->get_id_option();
     24    $atts['class']    = $tag->get_class_option( $class );
     25    $atts['id']       = $tag->get_id_option();
    2726    $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
    2827
     
    3938
    4039    if ( $validation_error ) {
    41         $atts['aria-invalid'] = 'true';
     40        $atts['aria-invalid']     = 'true';
    4241        $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
    4342            $tag->name
     
    5049
    5150    if ( $tag->has_option( 'placeholder' )
    52     or $tag->has_option( 'watermark' ) ) {
     51         or $tag->has_option( 'watermark' ) ) {
    5352        $atts['placeholder'] = $value;
    54         $value = '';
     53        $value               = '';
    5554    }
    5655
     
    8180}
    8281
    83 add_filter('wpcf7_validate_confirm_email',  'watts_confirm_email_validation_filter', 10, 2);
    84 add_filter('wpcf7_validate_confirm_email*', 'watts_confirm_email_validation_filter', 10, 2);
    85 
    86 function watts_confirm_email_validation_filter($result, $tag)
    87 {
     82add_filter( 'wpcf7_validate_confirm_email', 'watts_confirm_email_validation_filter', 10, 2 );
     83add_filter( 'wpcf7_validate_confirm_email*', 'watts_confirm_email_validation_filter', 10, 2 );
     84
     85function watts_confirm_email_validation_filter( $result, $tag ) {
    8886    $name = $tag->name;
    8987
    90     $value = isset( $_POST[$name] )
    91         ? trim( wp_unslash( strtr( (string) $_POST[$name], "\n", " " ) ) )
     88    $value = isset( $_POST[ $name ] )
     89        ? trim( wp_unslash( strtr( (string) $_POST[ $name ], "\n", " " ) ) )
    9290        : '';
    9391
     
    9795        $result->invalidate( $tag, wpcf7_get_message( 'invalid_email' ) );
    9896    }
    99     $target = $tag->get_option( 'target' )[0];
    100     $target_value = isset($_POST[$target] )
    101         ? trim( wp_unslash( strtr( (string) $_POST[$target] , "\n", " " ) ) )
     97    $target       = $tag->get_option( 'target' )[0];
     98    $target_value = isset( $_POST[ $target ] )
     99        ? trim( wp_unslash( strtr( (string) $_POST[ $target ], "\n", " " ) ) )
    102100        : '';
    103     if ($value !== $target_value) {
    104         $result->invalidate( $tag, __('Email addresses you entered do not match.', 'watts'));
     101    if ( $value !== $target_value ) {
     102        $result->invalidate( $tag, __( 'Email addresses you entered do not match.', 'watts' ) );
    105103    }
    106104
     
    108106}
    109107
    110 add_action('wpcf7_admin_init', 'watts_add_tag_generator_confirm_email', 16, 0);
    111 
    112 function watts_add_tag_generator_confirm_email()
    113 {
     108add_action( 'wpcf7_admin_init', 'watts_add_tag_generator_confirm_email', 16, 0 );
     109
     110function watts_add_tag_generator_confirm_email() {
    114111    $tag_generator = WPCF7_TagGenerator::get_instance();
    115     $tag_generator->add('confirm-email', __('confirm email', 'watts'),
    116         'watts_tag_generator_confirm_email');
    117 }
    118 
    119 function watts_tag_generator_confirm_email($contact_form, $args = '')
    120 {
    121     $args = wp_parse_args($args, array());
     112    $tag_generator->add( 'confirm-email', __( 'confirm email', 'watts' ),
     113        'watts_tag_generator_confirm_email' );
     114}
     115
     116function watts_tag_generator_confirm_email( $contact_form, $args = '' ) {
     117    $args = wp_parse_args( $args, array() );
    122118    $type = 'confirm_email';
    123119
     
    125121
    126122    ?>
    127 <div class="control-box">
    128 <fieldset>
    129 <legend><?php echo esc_html($description); ?></legend>
    130 
    131 <table class="form-table">
    132 <tbody>
    133     <tr>
    134     <th scope="row"><?php echo esc_html(__('Field type', 'watts')); ?></th>
    135     <td>
     123    <div class="control-box">
    136124        <fieldset>
    137         <legend class="screen-reader-text"><?php echo esc_html(__('Field type', 'watts')); ?></legend>
    138         <label><input type="checkbox" name="required" /> <?php echo esc_html(__('Required field', 'watts')); ?></label>
     125            <legend><?php echo esc_html( $description ); ?></legend>
     126
     127            <table class="form-table">
     128                <tbody>
     129                <tr>
     130                    <th scope="row"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></th>
     131                    <td>
     132                        <fieldset>
     133                            <legend
     134                                class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></legend>
     135                            <label><input type="checkbox"
     136                                          name="required"/> <?php echo esc_html( __( 'Required field', 'watts' ) ); ?>
     137                            </label>
     138                        </fieldset>
     139                    </td>
     140                </tr>
     141
     142                <tr>
     143                    <th scope="row"><label
     144                            for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'watts' ) ); ?></label>
     145                    </th>
     146                    <td><input type="text" name="name" class="tg-name oneline"
     147                               id="<?php echo esc_attr( $args['content'] . '-name' ); ?>"/></td>
     148                </tr>
     149
     150                <tr>
     151                    <th scope="row"><label
     152                            for="<?php echo esc_attr( $args['content'] . '-target' ); ?>"><?php echo esc_html( __( 'Target name*', 'watts' ) ); ?></label>
     153                    </th>
     154                    <td><input type="text" name="target" class="targetvalue oneline option"
     155                               id="<?php echo esc_attr( $args['content'] . '-target' ); ?>"/></td>
     156                </tr>
     157
     158                <tr>
     159                    <th scope="row"><label
     160                            for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'watts' ) ); ?></label>
     161                    </th>
     162                    <td><input type="text" name="values" class="oneline"
     163                               id="<?php echo esc_attr( $args['content'] . '-values' ); ?>"/><br/>
     164                </tr>
     165
     166                <tr>
     167                    <th scope="row"><label
     168                            for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'watts' ) ); ?></label>
     169                    </th>
     170                    <td><input type="text" name="id" class="idvalue oneline option"
     171                               id="<?php echo esc_attr( $args['content'] . '-id' ); ?>"/></td>
     172                </tr>
     173
     174                <tr>
     175                    <th scope="row"><label
     176                            for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'watts' ) ); ?></label>
     177                    </th>
     178                    <td><input type="text" name="class" class="classvalue oneline option"
     179                               id="<?php echo esc_attr( $args['content'] . '-class' ); ?>"/></td>
     180                </tr>
     181                </tbody>
     182            </table>
    139183        </fieldset>
    140     </td>
    141     </tr>
    142 
    143     <tr>
    144     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-name'); ?>"><?php echo esc_html(__('Name', 'watts')); ?></label></th>
    145     <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr($args['content'] . '-name'); ?>" /></td>
    146     </tr>
    147 
    148     <tr>
    149     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-target'); ?>"><?php echo esc_html(__('Target name*', 'watts')); ?></label></th>
    150     <td><input type="text" name="target" class="targetvalue oneline option" id="<?php echo esc_attr($args['content'] . '-target'); ?>" /></td>
    151     </tr>
    152 
    153     <tr>
    154     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-values'); ?>"><?php echo esc_html(__('Default value', 'watts')); ?></label></th>
    155     <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr($args['content'] . '-values'); ?>" /><br />
    156     </tr>
    157 
    158     <tr>
    159     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-id'); ?>"><?php echo esc_html(__('Id attribute', 'watts')); ?></label></th>
    160     <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr($args['content'] . '-id'); ?>" /></td>
    161     </tr>
    162 
    163     <tr>
    164     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-class'); ?>"><?php echo esc_html(__('Class attribute', 'watts')); ?></label></th>
    165     <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr($args['content'] . '-class'); ?>" /></td>
    166     </tr>
    167 </tbody>
    168 </table>
    169 </fieldset>
    170 </div>
    171 
    172 <div class="insert-box">
    173     <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
    174 
    175     <div class="submitbox">
    176     <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr(__('Insert Tag', 'watts')); ?>" />
    177184    </div>
    178185
    179     <br class="clear" />
    180 
    181     <p class="description mail-tag"><label for="<?php echo esc_attr($args['content'] . '-mailtag'); ?>"><?php echo sprintf(esc_html(__("To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts')), '<strong><span class="mail-tag"></span></strong>'); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr($args['content'] . '-mailtag'); ?>" /></label></p>
    182 </div>
    183 <?php
    184 }
     186    <div class="insert-box">
     187        <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()"/>
     188
     189        <div class="submitbox">
     190            <input type="button" class="button button-primary insert-tag"
     191                   value="<?php echo esc_attr( __( 'Insert Tag', 'watts' ) ); ?>"/>
     192        </div>
     193
     194        <br class="clear"/>
     195
     196        <p class="description mail-tag"><label
     197                for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
     198                <input type="text" class="mail-tag code hidden" readonly="readonly"
     199                       id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/></label></p>
     200    </div>
     201    <?php
     202}
  • watts/trunk/modules/dob.php

    r2648825 r2740791  
    11<?php
    22
    3 if (function_exists('wpcf7_add_form_tag')) {
    4     wpcf7_add_form_tag('dob', 'watts_dob_form_tag_handler', true);
    5     wpcf7_add_form_tag('dob*', 'watts_dob_form_tag_handler', true);
    6 }
    7 
    8 function watts_dob_form_tag_handler($tag)
    9 {
    10     if (empty($tag->name)) {
     3if ( function_exists( 'wpcf7_add_form_tag' ) ) {
     4    wpcf7_add_form_tag( 'dob', 'watts_dob_form_tag_handler', true );
     5    wpcf7_add_form_tag( 'dob*', 'watts_dob_form_tag_handler', true );
     6}
     7
     8function watts_dob_form_tag_handler( $tag ) {
     9    if ( empty( $tag->name ) ) {
    1110        return '';
    1211    }
    1312
    14     $validation_error = wpcf7_get_validation_error($tag->name);
    15 
    16     $class = wpcf7_form_controls_class($tag->type);
     13    $validation_error = wpcf7_get_validation_error( $tag->name );
     14
     15    $class = wpcf7_form_controls_class( $tag->type );
    1716
    1817    $class .= ' wpcf7-validates-as-dob';
    1918
    20     if ($validation_error) {
     19    if ( $validation_error ) {
    2120        $class .= ' wpcf7-not-valid';
    2221    }
     
    2423    $atts = array();
    2524
    26     $atts['class'] = $tag->get_class_option($class);
    27     $atts['id'] = $tag->get_id_option();
    28     $atts['tabindex'] = $tag->get_option('tabindex', 'signed_int', true);
    29     $format = isset($tag->get_option('format')[0]) ? $tag->get_option('format')[0] : 'YMD';
    30 
    31     if ($tag->is_required()) {
     25    $atts['class']    = $tag->get_class_option( $class );
     26    $atts['id']       = $tag->get_id_option();
     27    $atts['tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
     28    $format           = isset( $tag->get_option( 'format' )[0] ) ? $tag->get_option( 'format' )[0] : 'YMD';
     29
     30    if ( $tag->is_required() ) {
    3231        $atts['aria-required'] = 'true';
    3332    }
    3433
    35     if ($validation_error) {
    36         $atts['aria-invalid'] = 'true';
     34    if ( $validation_error ) {
     35        $atts['aria-invalid']     = 'true';
    3736        $atts['aria-describedby'] = wpcf7_get_validation_error_reference(
    3837            $tag->name
     
    4241    }
    4342
    44     $value = (string) reset($tag->values);
    45 
    46     $value = $tag->get_default_option($value);
    47     if ($value) {
    48         $datetime_obj = date_create_immutable($value, wp_timezone());
    49 
    50         if ($datetime_obj) {
     43    $value         = (string) reset( $tag->values );
     44    $default_value = [
     45        'year'  => null,
     46        'month' => null,
     47        'day'   => null,
     48    ];
     49
     50    $value = $tag->get_default_option( $value );
     51    if ( $value ) {
     52        $datetime_obj = date_create_immutable( $value, wp_timezone() );
     53
     54        if ( $datetime_obj ) {
    5155            // NOTE: プルダウンのvalueが0サプレスなので、初期値も合わせる
    5256            $default_value = [
    53                 'year' => $datetime_obj->format('Y'),
    54                 'month' => $datetime_obj->format('n'),
    55                 'day' => $datetime_obj->format('j'),
     57                'year'  => $datetime_obj->format( 'Y' ),
     58                'month' => $datetime_obj->format( 'n' ),
     59                'day'   => $datetime_obj->format( 'j' ),
    5660            ];
    5761        }
     
    6064    // NOTE: 寿命をもとに生年月日の範囲を算出
    6165    $max_lifespan = 120;
    62     $start_year = intval(date_i18n('Y'));
    63     $until_year = $start_year - $max_lifespan;
     66    $start_year   = intval( date_i18n( 'Y' ) );
     67    $until_year   = $start_year - $max_lifespan;
    6468
    6569    $html_parts = [
    66         'year' => watts_dob_form_part($tag, $atts, 'year', $default_value['year'], range($start_year, $until_year), esc_html(__('Year', 'watts'))),
    67         'month' => watts_dob_form_part($tag, $atts, 'month', $default_value['month'], range(1, 12), esc_html(__('Month', 'watts'))),
    68         'day' => watts_dob_form_part($tag, $atts, 'day', $default_value['day'], range(1, 31), esc_html(__('Day', 'watts')))
     70        'year'  => watts_dob_form_part( $tag, $atts, 'year', $default_value['year'], range( $start_year, $until_year ), esc_html( __( 'Year', 'watts' ) ) ),
     71        'month' => watts_dob_form_part( $tag, $atts, 'month', $default_value['month'], range( 1, 12 ), esc_html( __( 'Month', 'watts' ) ) ),
     72        'day'   => watts_dob_form_part( $tag, $atts, 'day', $default_value['day'], range( 1, 31 ), esc_html( __( 'Day', 'watts' ) ) )
    6973    ];
    7074
    7175    $html = '';
    72     if ($format === 'DMY') {
     76    if ( $format === 'DMY' ) {
    7377        $html = $html_parts['day'] . $html_parts['month'] . $html_parts['year'];
    74     } elseif ($format === 'MDY') {
     78    } elseif ( $format === 'MDY' ) {
    7579        $html = $html_parts['month'] . $html_parts['day'] . $html_parts['year'];
    7680    } else { // default
     
    8084    $html = sprintf(
    8185        '<span class="wpcf7-form-control-wrap %1$s">%2$s%3$s</span>',
    82         sanitize_html_class($tag->name), $html, $validation_error
     86        sanitize_html_class( $tag->name ), $html, $validation_error
    8387    );
    8488
     
    8690}
    8791
    88 function watts_dob_form_part($tag, $atts, $name_key, $default_value, $values, $blank_item)
    89 {
    90     $atts['name'] = sprintf('%1$s[%2$s]', $tag->name, $name_key);
    91     $atts['id'] .= '-' . $name_key;
     92function watts_dob_form_part( $tag, $atts, $name_key, $default_value, $values, $blank_item ) {
     93    $atts['name'] = sprintf( '%1$s[%2$s]', $tag->name, $name_key );
     94    $atts['id']   .= '-' . $name_key;
    9295
    9396    $labels = $values;
    9497
    95     $include_blank = $tag->has_option('include_blank');
    96 
    97     if ($include_blank) {
    98         array_unshift($labels, $blank_item);
    99         array_unshift($values, '');
    100     }
    101 
    102     $html = '';
    103     $hangover = wpcf7_get_hangover($tag->name);
    104 
    105     foreach ($values as $key => $value) {
    106         if ($hangover) {
    107             $selected = $value === (int) $hangover[$name_key];
     98    $include_blank = $tag->has_option( 'include_blank' );
     99
     100    if ( $include_blank ) {
     101        array_unshift( $labels, $blank_item );
     102        array_unshift( $values, '' );
     103    }
     104
     105    $html     = '';
     106    $hangover = wpcf7_get_hangover( $tag->name );
     107
     108    foreach ( $values as $key => $value ) {
     109        if ( $hangover ) {
     110            $selected = $value === (int) $hangover[ $name_key ];
    108111        } else {
    109112            $selected = $value === (int) $default_value;
     
    111114
    112115        $item_atts = array(
    113             'value' => $value,
     116            'value'    => $value,
    114117            'selected' => $selected ? 'selected' : '',
    115118        );
    116119
    117         $item_atts = wpcf7_format_atts($item_atts);
    118 
    119         $label = isset($labels[$key]) ? $labels[$key] : $value;
     120        $item_atts = wpcf7_format_atts( $item_atts );
     121
     122        $label = isset( $labels[ $key ] ) ? $labels[ $key ] : $value;
    120123
    121124        $html .= sprintf(
    122125            '<option %1$s>%2$s</option>',
    123126            $item_atts,
    124             esc_html($label)
     127            esc_html( $label )
    125128        );
    126129    }
    127     $atts = wpcf7_format_atts($atts);
     130    $atts = wpcf7_format_atts( $atts );
    128131
    129132    $html = sprintf(
     
    135138}
    136139
    137 add_filter('wpcf7_posted_data_dob', 'watts_posted_data_dob', 10, 3);
    138 add_filter('wpcf7_posted_data_dob*', 'watts_posted_data_dob', 10, 3);
    139 
    140 function watts_posted_data_dob($value, $value_orig, $tag)
    141 {
    142     if (!isset($value_orig) ||
    143         !isset($value_orig['year']) ||
    144         !isset($value_orig['month']) ||
    145         !isset($value_orig['day']) ||
    146         in_array('', $value_orig, true)) {
     140add_filter( 'wpcf7_posted_data_dob', 'watts_posted_data_dob', 10, 3 );
     141add_filter( 'wpcf7_posted_data_dob*', 'watts_posted_data_dob', 10, 3 );
     142
     143function watts_posted_data_dob( $value, $value_orig, $tag ) {
     144    if ( ! isset( $value_orig ) ||
     145         ! isset( $value_orig['year'] ) ||
     146         ! isset( $value_orig['month'] ) ||
     147         ! isset( $value_orig['day'] ) ||
     148         in_array( '', $value_orig, true ) ) {
    147149        return '';
    148150    }
    149151
    150     $format = isset($tag->get_option('format')[0]) ? $tag->get_option('format')[0] : 'YMD';
    151     $separator_option = isset($tag->get_option('separator')[0]) ? $tag->get_option('separator')[0] : 'slash';
    152     $separator_map = [
    153         'slash' => '/',
    154         'dash' => '-',
     152    $format           = isset( $tag->get_option( 'format' )[0] ) ? $tag->get_option( 'format' )[0] : 'YMD';
     153    $separator_option = isset( $tag->get_option( 'separator' )[0] ) ? $tag->get_option( 'separator' )[0] : 'slash';
     154    $separator_map    = [
     155        'slash'  => '/',
     156        'dash'   => '-',
    155157        'period' => '.',
    156         'comma' => ',',
    157         'blank' => ' '
    158     ];
    159     $separator = array_key_exists($separator_option, $separator_map) ? $separator_map[$separator_option] : '/';
    160     $leading_zero= $tag->has_option('leading_zero');
    161 
    162     $year = $value_orig['year'];
    163     $month= $value_orig['month'];
    164     $day = $value_orig['day'];
    165     if($leading_zero) {
    166         $month= str_pad($month, 2, '0', STR_PAD_LEFT);
    167         $day = str_pad($day, 2, '0', STR_PAD_LEFT);
     158        'comma'  => ',',
     159        'blank'  => ' '
     160    ];
     161    $separator        = array_key_exists( $separator_option, $separator_map ) ? $separator_map[ $separator_option ] : '/';
     162    $leading_zero     = $tag->has_option( 'leading_zero' );
     163
     164    $year  = $value_orig['year'];
     165    $month = $value_orig['month'];
     166    $day   = $value_orig['day'];
     167    if ( $leading_zero ) {
     168        $month = str_pad( $month, 2, '0', STR_PAD_LEFT );
     169        $day   = str_pad( $day, 2, '0', STR_PAD_LEFT );
    168170    }
    169171
    170172    $result = '';
    171     if ($format === 'DMY') {
    172         $result = implode([$day, $month, $year], $separator);
    173     } elseif ($format === 'MDY') {
    174         $result = implode([$month, $day, $year], $separator);
     173    if ( $format === 'DMY' ) {
     174        $result = implode( [ $day, $month, $year ], $separator );
     175    } elseif ( $format === 'MDY' ) {
     176        $result = implode( [ $month, $day, $year ], $separator );
    175177    } else { // default
    176         $result = implode([$year, $month, $day], $separator);
     178        $result = implode( [ $year, $month, $day ], $separator );
    177179    }
    178180
     
    180182}
    181183
    182 add_filter('wpcf7_validate_dob', 'watts_dob_validation_filter', 10, 2);
    183 add_filter('wpcf7_validate_dob*', 'watts_dob_validation_filter', 10, 2);
    184 
    185 function watts_dob_validation_filter($result, $tag)
    186 {
     184add_filter( 'wpcf7_validate_dob', 'watts_dob_validation_filter', 10, 2 );
     185add_filter( 'wpcf7_validate_dob*', 'watts_dob_validation_filter', 10, 2 );
     186
     187function watts_dob_validation_filter( $result, $tag ) {
    187188    $name = $tag->name;
    188189
    189190    $values = [
    190         'year' => isset($_POST[$name]['year']) ? trim(sanitize_text_field($_POST[$name]['year'])) : '',
    191         'month' => isset($_POST[$name]['month']) ? trim(sanitize_text_field($_POST[$name]['month'])) : '',
    192         'day' => isset($_POST[$name]['day']) ? trim(sanitize_text_field($_POST[$name]['day'])) : '',
     191        'year'  => isset( $_POST[ $name ]['year'] ) ? trim( sanitize_text_field( $_POST[ $name ]['year'] ) ) : '',
     192        'month' => isset( $_POST[ $name ]['month'] ) ? trim( sanitize_text_field( $_POST[ $name ]['month'] ) ) : '',
     193        'day'   => isset( $_POST[ $name ]['day'] ) ? trim( sanitize_text_field( $_POST[ $name ]['day'] ) ) : '',
    193194    ];
    194195
    195196    $blank_flags = [
    196         'year' => $values['year'] === '',
     197        'year'  => $values['year'] === '',
    197198        'month' => $values['month'] === '',
    198         'day' => $values['day'] === '',
    199     ];
    200 
    201     if (!in_array(false, $blank_flags, true) !== false) {
     199        'day'   => $values['day'] === '',
     200    ];
     201
     202    if ( ! in_array( false, $blank_flags, true ) !== false ) {
    202203        // すべて入力されていない
    203         if ($tag->is_required()) {
     204        if ( $tag->is_required() ) {
    204205            // 必須項目
    205206            $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) );
    206207        }
    207208        // 必須項目ではなく、全て入力されていない場合は許容
    208     } else if (in_array(true, $blank_flags, true) !== false) {
     209    } else if ( in_array( true, $blank_flags, true ) !== false ) {
    209210        // 中途半端な入力
    210211        $result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
    211     } else if (in_array(false, array_map('is_numeric', array_values($values)), true)) {
     212    } else if ( in_array( false, array_map( 'is_numeric', array_values( $values ) ), true ) ) {
    212213        // 数値かどうか
    213214        $result->invalidate( $tag, wpcf7_get_message( 'invalid_date' ) );
    214     } else if (!checkdate($values['month'], $values['day'], $values['year'])) {
     215    } else if ( ! checkdate( $values['month'], $values['day'], $values['year'] ) ) {
    215216        // 数値が入力されていた場合のチェック
    216         $result->invalidate( $tag, __('The date specified is not a valid date value.', 'watts'));
     217        $result->invalidate( $tag, __( 'The date specified is not a valid date value.', 'watts' ) );
    217218    }
    218219
     
    220221}
    221222
    222 add_action('wpcf7_admin_init', 'watts_add_tag_generator_dob', 20, 0);
    223 
    224 function watts_add_tag_generator_dob()
    225 {
     223add_action( 'wpcf7_admin_init', 'watts_add_tag_generator_dob', 20, 0 );
     224
     225function watts_add_tag_generator_dob() {
    226226    $tag_generator = WPCF7_TagGenerator::get_instance();
    227     $tag_generator->add('dob', __('DOB', 'watts'),
    228         'watts_tag_generator_dob');
    229 }
    230 
    231 function watts_tag_generator_dob($contact_form, $args = '')
    232 {
    233     $args = wp_parse_args($args, array());
     227    $tag_generator->add( 'dob', __( 'DOB', 'watts' ),
     228        'watts_tag_generator_dob' );
     229}
     230
     231function watts_tag_generator_dob( $contact_form, $args = '' ) {
     232    $args = wp_parse_args( $args, array() );
    234233    $type = 'dob';
    235234
     
    237236
    238237    ?>
    239 <div class="control-box">
    240 <fieldset>
    241 <legend><?php echo esc_html($description); ?></legend>
    242 
    243 <table class="form-table">
    244 <tbody>
    245     <tr>
    246     <th scope="row"><?php echo esc_html(__('Field type', 'watts')); ?></th>
    247     <td>
     238    <div class="control-box">
    248239        <fieldset>
    249         <legend class="screen-reader-text"><?php echo esc_html(__('Field type', 'watts')); ?></legend>
    250         <label><input type="checkbox" name="required" /> <?php echo esc_html(__('Required field', 'watts')); ?></label>
     240            <legend><?php echo esc_html( $description ); ?></legend>
     241
     242            <table class="form-table">
     243                <tbody>
     244                <tr>
     245                    <th scope="row"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></th>
     246                    <td>
     247                        <fieldset>
     248                            <legend
     249                                class="screen-reader-text"><?php echo esc_html( __( 'Field type', 'watts' ) ); ?></legend>
     250                            <label><input type="checkbox"
     251                                          name="required"/> <?php echo esc_html( __( 'Required field', 'watts' ) ); ?>
     252                            </label>
     253                        </fieldset>
     254                    </td>
     255                </tr>
     256
     257                <tr>
     258                    <th scope="row"><label
     259                            for="<?php echo esc_attr( $args['content'] . '-name' ); ?>"><?php echo esc_html( __( 'Name', 'watts' ) ); ?></label>
     260                    </th>
     261                    <td><input type="text" name="name" class="tg-name oneline"
     262                               id="<?php echo esc_attr( $args['content'] . '-name' ); ?>"/></td>
     263                </tr>
     264
     265                <tr>
     266                    <th scope="row"><label
     267                            for="<?php echo esc_attr( $args['content'] . '-values' ); ?>"><?php echo esc_html( __( 'Default value', 'watts' ) ); ?></label>
     268                    </th>
     269                    <td><input type="text" name="values" class="oneline"
     270                               id="<?php echo esc_attr( $args['content'] . '-values' ); ?>"/><br/>
     271                </tr>
     272
     273                <tr>
     274                    <th scope="row"><?php echo esc_html( __( 'Options', 'watts' ) ); ?></th>
     275                    <td>
     276                        <fieldset>
     277                            <legend
     278                                class="screen-reader-text"><?php echo esc_html( __( 'Options', 'watts' ) ); ?></legend>
     279                            <label><input type="checkbox" name="include_blank"
     280                                          class="option"/> <?php echo esc_html( __( 'Insert a blank item as the first option', 'watts' ) ); ?>
     281                            </label>
     282                        </fieldset>
     283                    </td>
     284                </tr>
     285
     286                <tr>
     287                    <th scope="row" rowspan="3"><?php echo esc_html( __( 'Date Format', 'watts' ) ); ?></th>
     288                    <td>
     289                        <fieldset>
     290                            <legend><?php echo esc_html( __( 'Date Style', 'watts' ) ); ?></legend>
     291                            <input type="radio" name="format" class="formatvalue option"
     292                                   id="<?php echo esc_attr( $args['content'] . '-format-ymd' ); ?>" value="YMD" checked>
     293                            <label for="<?php echo esc_attr( $args['content'] . '-format-ymd' ); ?>">YMD</label>
     294                            <input type="radio" name="format" class="formatvalue option"
     295                                   id="<?php echo esc_attr( $args['content'] . '-format-mdy' ); ?>" value="MDY">
     296                            <label for="<?php echo esc_attr( $args['content'] . '-format-mdy' ); ?>">MDY</label>
     297                            <input type="radio" name="format" class="formatvalue option"
     298                                   id="<?php echo esc_attr( $args['content'] . '-format-dmy' ); ?>" value="DMY">
     299                            <label for="<?php echo esc_attr( $args['content'] . '-format-dmy' ); ?>">DMY</label>
     300                        </fieldset>
     301                    </td>
     302                </tr>
     303                <tr>
     304                    <td>
     305                        <fieldset>
     306                            <legend><?php echo esc_html( __( 'Date Separator', 'watts' ) ); ?></legend>
     307                            <input type="radio" name="separator" class="separatorvalue option"
     308                                   id="<?php echo esc_attr( $args['content'] . '-separator-slash' ); ?>" value="slash"
     309                                   checked>
     310                            <label
     311                                for="<?php echo esc_attr( $args['content'] . '-separator-slash' ); ?>"><?php echo esc_html( __( 'slash', 'watts' ) ); ?></label>
     312                            <input type="radio" name="separator" class="separatorvalue option"
     313                                   id="<?php echo esc_attr( $args['content'] . '-separator-dash' ); ?>" value="dash">
     314                            <label
     315                                for="<?php echo esc_attr( $args['content'] . '-separator-dash' ); ?>"><?php echo esc_html( __( 'dash', 'watts' ) ); ?></label>
     316                            <input type="radio" name="separator" class="separatorvalue option"
     317                                   id="<?php echo esc_attr( $args['content'] . '-separator-period' ); ?>"
     318                                   value="period">
     319                            <label
     320                                for="<?php echo esc_attr( $args['content'] . '-separator-period' ); ?>"><?php echo esc_html( __( 'period', 'watts' ) ); ?></label>
     321                            <input type="radio" name="separator" class="separatorvalue option"
     322                                   id="<?php echo esc_attr( $args['content'] . '-separator-comma' ); ?>" value="comma">
     323                            <label
     324                                for="<?php echo esc_attr( $args['content'] . '-separator-comma' ); ?>"><?php echo esc_html( __( 'comma', 'watts' ) ); ?></label>
     325                            <input type="radio" name="separator" class="separatorvalue option"
     326                                   id="<?php echo esc_attr( $args['content'] . '-separator-blank' ); ?>" value="blank">
     327                            <label
     328                                for="<?php echo esc_attr( $args['content'] . '-separator-blank' ); ?>"><?php echo esc_html( __( 'blank', 'watts' ) ); ?></label>
     329                        </fieldset>
     330                    </td>
     331                </tr>
     332
     333                <tr>
     334                    <td>
     335                        <fieldset>
     336                            <legend><?php echo esc_html( __( 'Display Leading Zero', 'watts' ) ); ?></legend>
     337                            <label><input type="checkbox" name="leading_zero"
     338                                          class="option"/> <?php echo esc_html( __( 'Indicates whether to display (or suppress) leading zeros.', 'watts' ) ); ?>
     339                            </label>
     340                        </fieldset>
     341                    </td>
     342                </tr>
     343
     344                <tr>
     345                    <th scope="row"><label
     346                            for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php echo esc_html( __( 'Id attribute', 'watts' ) ); ?></label>
     347                    </th>
     348                    <td><input type="text" name="id" class="idvalue oneline option"
     349                               id="<?php echo esc_attr( $args['content'] . '-id' ); ?>"/></td>
     350                </tr>
     351
     352                <tr>
     353                    <th scope="row"><label
     354                            for="<?php echo esc_attr( $args['content'] . '-class' ); ?>"><?php echo esc_html( __( 'Class attribute', 'watts' ) ); ?></label>
     355                    </th>
     356                    <td><input type="text" name="class" class="classvalue oneline option"
     357                               id="<?php echo esc_attr( $args['content'] . '-class' ); ?>"/></td>
     358                </tr>
     359                </tbody>
     360            </table>
    251361        </fieldset>
    252     </td>
    253     </tr>
    254 
    255     <tr>
    256     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-name'); ?>"><?php echo esc_html(__('Name', 'watts')); ?></label></th>
    257     <td><input type="text" name="name" class="tg-name oneline" id="<?php echo esc_attr($args['content'] . '-name'); ?>" /></td>
    258     </tr>
    259 
    260     <tr>
    261     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-values'); ?>"><?php echo esc_html(__('Default value', 'watts')); ?></label></th>
    262     <td><input type="text" name="values" class="oneline" id="<?php echo esc_attr($args['content'] . '-values'); ?>" /><br />
    263     </tr>
    264 
    265     <tr>
    266     <th scope="row"><?php echo esc_html(__('Options', 'watts')); ?></th>
    267     <td>
    268         <fieldset>
    269         <legend class="screen-reader-text"><?php echo esc_html(__('Options', 'watts')); ?></legend>
    270         <label><input type="checkbox" name="include_blank" class="option" /> <?php echo esc_html(__('Insert a blank item as the first option', 'watts')); ?></label>
    271         </fieldset>
    272     </td>
    273     </tr>
    274 
    275     <tr>
    276     <th scope="row" rowspan="3"><?php echo esc_html(__('Date Format', 'watts')); ?></th>
    277     <td>
    278         <fieldset>
    279             <legend><?php echo esc_html(__('Date Style', 'watts')); ?></legend>
    280             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-ymd'); ?>" value="YMD" checked >
    281             <label for="<?php echo esc_attr($args['content'] . '-format-ymd'); ?>">YMD</label>
    282             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-mdy'); ?>" value="MDY" >
    283             <label for="<?php echo esc_attr($args['content'] . '-format-mdy'); ?>">MDY</label>
    284             <input type="radio" name="format" class="formatvalue option" id="<?php echo esc_attr($args['content'] . '-format-dmy'); ?>" value="DMY" >
    285             <label for="<?php echo esc_attr($args['content'] . '-format-dmy'); ?>">DMY</label>
    286         </fieldset>
    287     </td>
    288     </tr>
    289     <tr>
    290     <td>
    291         <fieldset>
    292             <legend><?php echo esc_html(__('Date Separator', 'watts')); ?></legend>
    293             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-slash'); ?>" value="slash" checked >
    294             <label for="<?php echo esc_attr($args['content'] . '-separator-slash'); ?>"><?php echo esc_html(__('slash', 'watts')); ?></label>
    295             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-dash'); ?>" value="dash" >
    296             <label for="<?php echo esc_attr($args['content'] . '-separator-dash'); ?>"><?php echo esc_html(__('dash', 'watts')); ?></label>
    297             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-period'); ?>" value="period" >
    298             <label for="<?php echo esc_attr($args['content'] . '-separator-period'); ?>"><?php echo esc_html(__('period', 'watts')); ?></label>
    299             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-comma'); ?>" value="comma" >
    300             <label for="<?php echo esc_attr($args['content'] . '-separator-comma'); ?>"><?php echo esc_html(__('comma', 'watts')); ?></label>
    301             <input type="radio" name="separator" class="separatorvalue option" id="<?php echo esc_attr($args['content'] . '-separator-blank'); ?>" value="blank" >
    302             <label for="<?php echo esc_attr($args['content'] . '-separator-blank'); ?>"><?php echo esc_html(__('blank', 'watts')); ?></label>
    303         </fieldset>
    304     </td>
    305     </tr>
    306 
    307     <tr>
    308     <td>
    309         <fieldset>
    310         <legend><?php echo esc_html(__('Display Leading Zero', 'watts')); ?></legend>
    311         <label><input type="checkbox" name="leading_zero" class="option" /> <?php echo esc_html(__('Indicates whether to display (or suppress) leading zeros.', 'watts')); ?></label>
    312         </fieldset>
    313     </td>
    314     </tr>
    315 
    316     <tr>
    317     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-id'); ?>"><?php echo esc_html(__('Id attribute', 'watts')); ?></label></th>
    318     <td><input type="text" name="id" class="idvalue oneline option" id="<?php echo esc_attr($args['content'] . '-id'); ?>" /></td>
    319     </tr>
    320 
    321     <tr>
    322     <th scope="row"><label for="<?php echo esc_attr($args['content'] . '-class'); ?>"><?php echo esc_html(__('Class attribute', 'watts')); ?></label></th>
    323     <td><input type="text" name="class" class="classvalue oneline option" id="<?php echo esc_attr($args['content'] . '-class'); ?>" /></td>
    324     </tr>
    325 </tbody>
    326 </table>
    327 </fieldset>
    328 </div>
    329 
    330 <div class="insert-box">
    331     <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()" />
    332 
    333     <div class="submitbox">
    334     <input type="button" class="button button-primary insert-tag" value="<?php echo esc_attr(__('Insert Tag', 'watts')); ?>" />
    335362    </div>
    336363
    337     <br class="clear" />
    338 
    339     <p class="description mail-tag"><label for="<?php echo esc_attr($args['content'] . '-mailtag'); ?>"><?php echo sprintf(esc_html(__("To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts')), '<strong><span class="mail-tag"></span></strong>'); ?><input type="text" class="mail-tag code hidden" readonly="readonly" id="<?php echo esc_attr($args['content'] . '-mailtag'); ?>" /></label></p>
    340 </div>
    341 <?php
    342 }
     364    <div class="insert-box">
     365        <input type="text" name="<?php echo $type; ?>" class="tag code" readonly="readonly" onfocus="this.select()"/>
     366
     367        <div class="submitbox">
     368            <input type="button" class="button button-primary insert-tag"
     369                   value="<?php echo esc_attr( __( 'Insert Tag', 'watts' ) ); ?>"/>
     370        </div>
     371
     372        <br class="clear"/>
     373
     374        <p class="description mail-tag"><label
     375                for="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"><?php echo sprintf( esc_html( __( "To use the value input through this field in a mail field, you need to insert the corresponding mail-tag (%s) into the field on the Mail tab.", 'watts' ) ), '<strong><span class="mail-tag"></span></strong>' ); ?>
     376                <input type="text" class="mail-tag code hidden" readonly="readonly"
     377                       id="<?php echo esc_attr( $args['content'] . '-mailtag' ); ?>"/></label></p>
     378    </div>
     379    <?php
     380}
  • watts/trunk/readme.txt

    r2719562 r2740791  
    66Tested up to: 5.9.3
    77Requires PHP: 5.6
    8 Stable tag: 1.2.0
     8Stable tag: 1.2.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5757== Changelog ==
    5858
     59= 1.2.1 =
     60* Added settings page.
     61
    5962= 1.2.0 =
    6063* Supports icon display showing validation results.
  • watts/trunk/watts.php

    r2719562 r2740791  
    77 * Author URI:      https://github.com/solaito/
    88 * Text Domain:     watts
    9  * Domain Path:     /languages
    10  * Version:         1.2.0
     9 * Version:         1.2.1
    1110 *
    1211 * @package         Watts
    1312 */
    1413
     14define( "WATTS_PLUGIN", __FILE__ );
     15define( "WATTS_PLUGIN_BASENAME", plugin_basename( WATTS_PLUGIN ) );
     16define( "WATTS_PLUGIN_DIR_URL", plugin_dir_url( WATTS_PLUGIN ) );
     17
     18require_once 'includes/options-page.php';
    1519require_once 'includes/controller.php';
    1620
     
    1822require_once "modules/confirm-email.php";
    1923
    20 add_action('wp_enqueue_scripts', 'watts_enqueue_scripts');
    21 function watts_enqueue_scripts()
    22 {
    23     $data = get_file_data(__FILE__, array('version' => 'Version'));
     24add_action( 'wp_enqueue_scripts', 'watts_enqueue_scripts' );
     25function watts_enqueue_scripts() {
     26    $data    = get_file_data( WATTS_PLUGIN, array( 'version' => 'Version' ) );
    2427    $version = $data['version'];
    25     if (in_array(get_locale(), ['ja', 'ko_KR', 'zh_CN', 'zh_HK', 'zh_TW'], true)) {
    26         wp_enqueue_script('watts-zenkaku-to-hankaku', plugin_dir_url(__FILE__) . 'includes/js/zenkaku-to-hankaku.js', array('contact-form-7'), $version);
     28    $options = get_option( 'watts_option_name' );
     29    if ( $options[ Watts_Options_Page::IDS['FULL_TO_HALF_ENABLE'] ] === 'on' ) {
     30        wp_enqueue_script( 'watts-full-to-half', WATTS_PLUGIN_DIR_URL . 'includes/js/full-to-half.js', array( 'contact-form-7' ), $version );
    2731    }
    28     if(!(strstr($_SERVER['HTTP_USER_AGENT'], 'Trident') || strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))) {
    29         wp_enqueue_script('watts-auto-validation', plugin_dir_url(__FILE__) . 'includes/js/auto-validation.js', array('contact-form-7'), $version);
    30         $watts= array(
    31             'api' => array(
    32                     'root' => esc_url_raw( get_rest_url() ),
     32    if ( $options[ Watts_Options_Page::IDS['REALTIME_VALIDATION_ENABLE'] ] === 'on' ) {
     33        if ( ! ( strstr( $_SERVER['HTTP_USER_AGENT'], 'Trident' ) || strstr( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) ) ) {
     34            wp_enqueue_script( 'watts-realtime-validation', WATTS_PLUGIN_DIR_URL . 'includes/js/realtime-validation.js', array( 'contact-form-7' ), $version );
     35            $watts = array(
     36                'api'    => array(
     37                    'root'      => esc_url_raw( get_rest_url() ),
    3338                    'namespace' => 'watts/v1',
    34             ),
    35             'plugin' => array(
    36                     'dir' => esc_url_raw(plugin_dir_url(__FILE__)),
    37             )
    38         );
    39         wp_localize_script( 'watts-auto-validation', 'watts', $watts );
     39                ),
     40                'plugin' => array(
     41                    'dir'                  => esc_url_raw( WATTS_PLUGIN_DIR_URL ),
     42                    'validate_icon_enable' => $options[ Watts_Options_Page::IDS['VALIDATE_ICON_ENABLE'] ] === 'on',
     43                    'validate_icon_size'   => isset( $options[ Watts_Options_Page::IDS['VALIDATE_ICON_SIZE'] ] ) ? $options[ Watts_Options_Page::IDS['VALIDATE_ICON_SIZE'] ] : 'medium',
     44                )
     45            );
     46            wp_localize_script( 'watts-realtime-validation', 'watts', $watts );
     47        }
    4048    }
    41     wp_enqueue_style('watts', plugin_dir_url(__FILE__) . 'includes/css/style.css', array('contact-form-7'), $version);
     49    wp_enqueue_style( 'watts', WATTS_PLUGIN_DIR_URL . 'includes/css/style.css', array( 'contact-form-7' ), $version );
    4250}
    4351
    44 add_action('rest_api_init', function () {
     52add_action( 'rest_api_init', function () {
    4553    $controller = new Watts_Rest_Controller;
    4654    $controller->register_routes();
    47 });
     55} );
Note: See TracChangeset for help on using the changeset viewer.