Plugin Directory

Changeset 2415319


Ignore:
Timestamp:
11/09/2020 04:51:00 PM (5 years ago)
Author:
webmarcello
Message:

cleaning phone number and international prefix

Location:
wp-phone-message/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • wp-phone-message/trunk/includes/WpPhoneMessageAdmin.php

    r2302452 r2415319  
    3232            // save data
    3333            if( ( $_POST['wp-phone-message-phone-number'] ) && ( $_POST['wp-phone-message-phone-prefix'] ) ) {
     34                $_POST['wp-phone-message-phone-number'] = $this->cleanPhoneNumber($_POST);
    3435                $this->model->setData($_POST);
    3536                $this->model->setMessage('Settings saved.');
     
    7071            echo '<p>This section is part of WP Phone Message Plugin</p>';
    7172        }
     73       
     74        private function cleanPhoneNumber($args){
     75            $prefix = str_replace(' ', '', sanitize_text_field( $args['wp-phone-message-phone-prefix'] ));
     76            $phone = sanitize_text_field( $args['wp-phone-message-phone-number'] );
     77
     78            if(is_numeric(substr($prefix, 0, 1))){
     79                $prefix = '+'. $prefix;
     80            }
     81           
     82            $phone = preg_replace('/^' . preg_quote($prefix, '/') . '/', '0', $phone);
     83           
     84            return $phone;
     85        }
    7286    }
    7387}
  • wp-phone-message/trunk/readme.txt

    r2333369 r2415319  
    33Tags: message, form, whatsapp, shortcode, widget
    44Requires at least: 4.5.13
    5 Tested up to: 5.3.2
     5Tested up to: 5.5.3
    66Stable tag: trunk
    77Requires PHP: 5.6
     
    9090== Changelog ==
    9191
     92= 1.0.6 =
     93* Cleaning phone number and international prefix
     94* Managing error messages on admin area
     95
    9296= 1.0.5 =
    9397* Possibility to add name field in shortcode form
  • wp-phone-message/trunk/views/admin-form.php

    r2333369 r2415319  
    33    if( current_user_can( 'edit_users' ) ){
    44    ?>
    5     <div class="wrap">
    6         <h1 class="admin-page-title"><?= esc_html( get_admin_page_title() ); ?></h1>
    7    
    8         <form method="post" action="<?= esc_html( admin_url( 'admin-post.php' ) ); ?>">
     5<div class="wrap">
     6      <h1 class="admin-page-title"><?= esc_html( get_admin_page_title() ); ?></h1>
     7
     8      <form method="post" action="<?= esc_html( admin_url( 'admin-post.php' ) ); ?>">
    99
    1010            <div class="form-description">
    11                 Using WP Phone Message is very simple and it doens't require any API Key or registration.<br/>
    12                 Please complete the form below. International Prefix and Whatsapp phone number are required.<br/>
    13                 In order to display the Whatsapp message form on your page please add the shortcode <strong>[wp-phone-message]</strong> to your page/post content.<br/>
     11                  Using WP Phone Message is very simple and it doens't require any API Key or registration.<br />
     12                  Please complete the form below. International Prefix and Whatsapp phone number are required.<br />
     13                  In order to display the Whatsapp message form on your page please add the shortcode
     14                  <strong>[wp-phone-message]</strong> to your page/post content.<br />
    1415            </div>
    1516
    1617            <table class="form-table">
    17                 <tbody>
    18                     <tr>
    19                         <th scope="row">
    20                             <label for="wp-phone-message-phone-prefix">
    21                                 International Prefix* :
    22                             </label>
    23                         </th>
    24                         <td>
    25                             <input name="wp-phone-message-phone-prefix" type="text" id="wp-phone-message-phone-prefix" value="<?= get_option('wp-phone-message-phone-prefix'); ?>" class="regular-text" />
    26                             <p class="description" id="wp-phone-message-phone-prefix-description">Insert the international prefix of your Whatsapp phone number.</p>
    27                         </td>
    28                     </tr>
    29                     <tr>
    30                         <th scope="row">
    31                             <label for="wp-phone-message-phone-number">
    32                                 Whatsapp phone number* :
    33                             </label>
    34                         </th>
    35                         <td>
    36                             <input name="wp-phone-message-phone-number" type="text" id="wp-phone-message-phone-number" value="<?= get_option('wp-phone-message-phone-number'); ?>" class="regular-text" />
    37                             <p class="description" id="wp-phone-message-phone-number-description">Insert a valid Whatsapp number that will receive the messages.</p>
    38                         </td>
    39                     </tr>
    40                     <tr>
    41                         <th scope="row">
    42                             <label for="wp-phone-message-title">
    43                                 Title :
    44                             </label>
    45                         </th>
    46                         <td>
    47                             <input name="wp-phone-message-title" type="text" id="wp-phone-message-title" value="<?= get_option('wp-phone-message-title'); ?>" class="regular-text" />
    48                             <p class="description" id="wp-phone-message-title-description">The title will appear on the top of the message form.</p>
    49                         </td>
    50                     </tr>
    51                     <tr>
    52                         <th scope="row">
    53                             <label for="wp-phone-message-text">
    54                                 Text :
    55                             </label>
    56                         </th>
    57                         <td>
    58                             <textarea name="wp-phone-message-text"  id="wp-phone-message-text" class="large-text code" rows="3"><?= get_option('wp-phone-message-text'); ?></textarea>
    59                             <p class="description" id="wp-phone-message-text-description">The text will appear on the top of the message form.</p>
    60                         </td>
    61                     </tr>
    62                 </tbody>
     18                  <tbody>
     19                        <tr>
     20                              <th scope="row">
     21                                    <label for="wp-phone-message-phone-prefix">
     22                                          International Prefix* :
     23                                    </label>
     24                              </th>
     25                              <td>
     26                                    <input name="wp-phone-message-phone-prefix" type="text"
     27                                          id="wp-phone-message-phone-prefix"
     28                                          value="<?= get_option('wp-phone-message-phone-prefix'); ?>"
     29                                          class="regular-text" />
     30                                    <p class="description" id="wp-phone-message-phone-prefix-description">Insert the
     31                                          international prefix of your Whatsapp phone number.
     32                                    </p>
     33                              </td>
     34                        </tr>
     35                        <tr>
     36                              <th scope="row">
     37                                    <label for="wp-phone-message-phone-number">
     38                                          Whatsapp phone number* :
     39                                    </label>
     40                              </th>
     41                              <td>
     42                                    <input name="wp-phone-message-phone-number" type="text"
     43                                          id="wp-phone-message-phone-number"
     44                                          value="<?= get_option('wp-phone-message-phone-number'); ?>"
     45                                          class="regular-text" />
     46                                    <p class="description" id="wp-phone-message-phone-number-description">Insert a valid
     47                                          Whatsapp number that will receive the messages.<br />
     48                                          <strong>Please be sure to insert a phone number without
     49                                                international
     50                                                prefix.</strong>
     51                                    </p>
     52                              </td>
     53                        </tr>
     54                        <tr>
     55                              <th scope="row">
     56                                    <label for="wp-phone-message-title">
     57                                          Title :
     58                                    </label>
     59                              </th>
     60                              <td>
     61                                    <input name="wp-phone-message-title" type="text" id="wp-phone-message-title"
     62                                          value="<?= get_option('wp-phone-message-title'); ?>" class="regular-text" />
     63                                    <p class="description" id="wp-phone-message-title-description">The title will appear
     64                                          on the top of the message form.</p>
     65                              </td>
     66                        </tr>
     67                        <tr>
     68                              <th scope="row">
     69                                    <label for="wp-phone-message-text">
     70                                          Text :
     71                                    </label>
     72                              </th>
     73                              <td>
     74                                    <textarea name="wp-phone-message-text" id="wp-phone-message-text"
     75                                          class="large-text code"
     76                                          rows="3"><?= get_option('wp-phone-message-text'); ?></textarea>
     77                                    <p class="description" id="wp-phone-message-text-description">The text will appear
     78                                          on the top of the message form.</p>
     79                              </td>
     80                        </tr>
     81                  </tbody>
    6382            </table>
    6483
     
    6685
    6786            <table class="form-table">
    68                 <tbody>
    69                     <tr>
    70                         <th scope="row">
    71                             <label for="wp-phone-message-name">
    72                                 Name Area :
    73                             </label>
    74                         </th>
    75                         <td>
    76                             <input type="checkbox" id="wp-phone-message-name-active" name="wp-phone-message-name-active" <?= ( get_option('wp-phone-message-name-active') ? 'checked' : '') ?> value="1">
    77                             <label for="wp-phone-message-name-active">Active Name Input Area in shortcode</label>
    78                         </td>
    79                         <td>
    80                             <input type="checkbox" id="wp-phone-message-name-active-widget" name="wp-phone-message-name-active-widget" <?= ( get_option('wp-phone-message-name-active-widget') ? 'checked' : '') ?> value="1">
    81                             <label for="wp-phone-message-name-active-widget">Active Name Input Area in widget</label>
    82                         </td>
    83                         <td>
    84                             <input type="checkbox" id="wp-phone-message-name-mandatory" name="wp-phone-message-name-mandatory" <?= ( get_option('wp-phone-message-name-mandatory') ? 'checked' : '') ?> value="required">
    85                             <label for="wp-phone-message-name-mandatory">Name Input Area Mandatory</label>
    86                         </td>
    87                         <td>
    88                             <input name="wp-phone-message-name" type="text" id="wp-phone-message-name" value="<?= get_option('wp-phone-message-name'); ?>" class="regular-text" />
    89                             <p class="description" id="wp-phone-message-name-description">The Name area input placeholder.</p>
    90                         </td>
    91                     </tr>
    92                     <tr>
    93                         <th scope="row">
    94                             <label for="wp-phone-message-address">
    95                                 Address Area :
    96                             </label>
    97                         </th>
    98                         <td>
    99                             <input type="checkbox" id="wp-phone-message-address-active" name="wp-phone-message-address-active" <?= ( get_option('wp-phone-message-address-active') ? 'checked' : '') ?> value="1">
    100                             <label for="wp-phone-message-address-active">Active Address Input Area in shortcode</label>
    101                         </td>
    102                         <td>
    103                             <input type="checkbox" id="wp-phone-message-address-active-widget" name="wp-phone-message-address-active-widget" <?= ( get_option('wp-phone-message-address-active-widget') ? 'checked' : '') ?> value="1">
    104                             <label for="wp-phone-message-address-active-widget">Active Address Input Area in widget</label>
    105                         </td>
    106                         <td>
    107                             <input type="checkbox" id="wp-phone-message-address-mandatory" name="wp-phone-message-address-mandatory" <?= ( get_option('wp-phone-message-address-mandatory') ? 'checked' : '') ?> value="required">
    108                             <label for="wp-phone-message-address-mandatory">Address Input Area Mandatory</label>
    109                         </td>
    110                         <td>
    111                             <input name="wp-phone-message-address" type="text" id="wp-phone-message-address" value="<?= get_option('wp-phone-message-address'); ?>" class="regular-text" />
    112                             <p class="description" id="wp-phone-message-address-description">The Address area input placeholder.</p>
    113                         </td>
    114                     </tr>
    115                     <tr>
    116                         <th scope="row">
    117                             <label for="wp-phone-message-phone">
    118                                 Phone Area :
    119                             </label>
    120                         </th>
    121                         <td>
    122                             <input type="checkbox" id="wp-phone-message-phone-active" name="wp-phone-message-phone-active" <?= ( get_option('wp-phone-message-phone-active') ? 'checked' : '') ?> value="1">
    123                             <label for="wp-phone-message-phone-active">Active Phone Input Area in shortcode</label>
    124                         </td>
    125                         <td>
    126                             <input type="checkbox" id="wp-phone-message-phone-active-widget" name="wp-phone-message-phone-active-widget" <?= ( get_option('wp-phone-message-phone-active-widget') ? 'checked' : '') ?> value="1">
    127                             <label for="wp-phone-message-phone-active-widget">Active Phone Input Area in widget</label>
    128                         </td>
    129                         <td>
    130                             <input type="checkbox" id="wp-phone-message-phone-mandatory" name="wp-phone-message-phone-mandatory" <?= ( get_option('wp-phone-message-phone-mandatory') ? 'checked' : '') ?> value="required">
    131                             <label for="wp-phone-message-phone-mandatory">Phone Input Area Mandatory</label>
    132                         </td>
    133                         <td>
    134                             <input name="wp-phone-message-phone" type="text" id="wp-phone-message-phone" value="<?= get_option('wp-phone-message-phone'); ?>" class="regular-text" />
    135                             <p class="description" id="wp-phone-message-phone-description">The Phone area input placeholder.</p>
    136                         </td>
    137                     </tr>
    138                     <tr>
    139                         <th scope="row">
    140                             <label for="wp-phone-message-email">
    141                                 Email Address Area :
    142                             </label>
    143                         </th>
    144                         <td>
    145                             <input type="checkbox" id="wp-phone-message-email-active" name="wp-phone-message-email-active" <?= ( get_option('wp-phone-message-email-active') ? 'checked' : '') ?> value="1">
    146                             <label for="wp-phone-message-email-active">Active Email Address Input Area in shortcode</label>
    147                         </td>
    148                         <td>
    149                             <input type="checkbox" id="wp-phone-message-email-active-widget" name="wp-phone-message-email-active-widget" <?= ( get_option('wp-phone-message-email-active-widget') ? 'checked' : '') ?> value="1">
    150                             <label for="wp-phone-message-email-active-widget">Active Email Address Input Area in widget</label>
    151                         </td>
    152                         <td>
    153                             <input type="checkbox" id="wp-phone-message-email-mandatory" name="wp-phone-message-email-mandatory" <?= ( get_option('wp-phone-message-email-mandatory') ? 'checked' : '') ?> value="required">
    154                             <label for="wp-phone-message-email-mandatory">Email Address Input Area Mandatory</label>
    155                         </td>
    156                         <td>
    157                             <input name="wp-phone-message-email" type="text" id="wp-phone-message-email" value="<?= get_option('wp-phone-message-email'); ?>" class="regular-text" />
    158                             <p class="description" id="wp-phone-message-email-description">The Email Address area input placeholder.</p>
    159                         </td>
    160                     </tr>
    161                     <tr>
    162                         <th scope="row">
    163                             <label for="wp-phone-message-textarea">
    164                                 Text Area Placeholder :
    165                             </label>
    166                         </th>
    167                         <td>
    168                             <input name="wp-phone-message-textarea" type="text" id="wp-phone-message-textarea" value="<?= get_option('wp-phone-message-textarea'); ?>" class="regular-text" />
    169                             <p class="description" id="wp-phone-message-textarea-description">The textarea placeholder.</p>
    170                         </td>
    171                     </tr>
    172                     <tr>
    173                         <th scope="row">
    174                             <label for="wp-phone-message-title">
    175                                 Button Title :
    176                             </label>
    177                         </th>
    178                         <td>
    179                             <input name="wp-phone-message-button" type="text" id="wp-phone-message-button" value="<?= get_option('wp-phone-message-button'); ?>" class="regular-text" />
    180                             <p class="description" id="wp-phone-message-button-description">The Button Title will appear on the button of the message form.</p>
    181                         </td>
    182                     </tr>
    183                 </tbody>
     87                  <tbody>
     88                        <tr>
     89                              <th scope="row">
     90                                    <label for="wp-phone-message-name">
     91                                          Name Area :
     92                                    </label>
     93                              </th>
     94                              <td>
     95                                    <input type="checkbox" id="wp-phone-message-name-active"
     96                                          name="wp-phone-message-name-active"
     97                                          <?= ( get_option('wp-phone-message-name-active') ? 'checked' : '') ?>
     98                                          value="1">
     99                                    <label for="wp-phone-message-name-active">Active Name Input Area in
     100                                          shortcode</label>
     101                              </td>
     102                              <td>
     103                                    <input type="checkbox" id="wp-phone-message-name-active-widget"
     104                                          name="wp-phone-message-name-active-widget"
     105                                          <?= ( get_option('wp-phone-message-name-active-widget') ? 'checked' : '') ?>
     106                                          value="1">
     107                                    <label for="wp-phone-message-name-active-widget">Active Name Input Area in
     108                                          widget</label>
     109                              </td>
     110                              <td>
     111                                    <input type="checkbox" id="wp-phone-message-name-mandatory"
     112                                          name="wp-phone-message-name-mandatory"
     113                                          <?= ( get_option('wp-phone-message-name-mandatory') ? 'checked' : '') ?>
     114                                          value="required">
     115                                    <label for="wp-phone-message-name-mandatory">Name Input Area Mandatory</label>
     116                              </td>
     117                              <td>
     118                                    <input name="wp-phone-message-name" type="text" id="wp-phone-message-name"
     119                                          value="<?= get_option('wp-phone-message-name'); ?>" class="regular-text" />
     120                                    <p class="description" id="wp-phone-message-name-description">The Name area input
     121                                          placeholder.</p>
     122                              </td>
     123                        </tr>
     124                        <tr>
     125                              <th scope="row">
     126                                    <label for="wp-phone-message-address">
     127                                          Address Area :
     128                                    </label>
     129                              </th>
     130                              <td>
     131                                    <input type="checkbox" id="wp-phone-message-address-active"
     132                                          name="wp-phone-message-address-active"
     133                                          <?= ( get_option('wp-phone-message-address-active') ? 'checked' : '') ?>
     134                                          value="1">
     135                                    <label for="wp-phone-message-address-active">Active Address Input Area in
     136                                          shortcode</label>
     137                              </td>
     138                              <td>
     139                                    <input type="checkbox" id="wp-phone-message-address-active-widget"
     140                                          name="wp-phone-message-address-active-widget"
     141                                          <?= ( get_option('wp-phone-message-address-active-widget') ? 'checked' : '') ?>
     142                                          value="1">
     143                                    <label for="wp-phone-message-address-active-widget">Active Address Input Area in
     144                                          widget</label>
     145                              </td>
     146                              <td>
     147                                    <input type="checkbox" id="wp-phone-message-address-mandatory"
     148                                          name="wp-phone-message-address-mandatory"
     149                                          <?= ( get_option('wp-phone-message-address-mandatory') ? 'checked' : '') ?>
     150                                          value="required">
     151                                    <label for="wp-phone-message-address-mandatory">Address Input Area Mandatory</label>
     152                              </td>
     153                              <td>
     154                                    <input name="wp-phone-message-address" type="text" id="wp-phone-message-address"
     155                                          value="<?= get_option('wp-phone-message-address'); ?>" class="regular-text" />
     156                                    <p class="description" id="wp-phone-message-address-description">The Address area
     157                                          input placeholder.</p>
     158                              </td>
     159                        </tr>
     160                        <tr>
     161                              <th scope="row">
     162                                    <label for="wp-phone-message-phone">
     163                                          Phone Area :
     164                                    </label>
     165                              </th>
     166                              <td>
     167                                    <input type="checkbox" id="wp-phone-message-phone-active"
     168                                          name="wp-phone-message-phone-active"
     169                                          <?= ( get_option('wp-phone-message-phone-active') ? 'checked' : '') ?>
     170                                          value="1">
     171                                    <label for="wp-phone-message-phone-active">Active Phone Input Area in
     172                                          shortcode</label>
     173                              </td>
     174                              <td>
     175                                    <input type="checkbox" id="wp-phone-message-phone-active-widget"
     176                                          name="wp-phone-message-phone-active-widget"
     177                                          <?= ( get_option('wp-phone-message-phone-active-widget') ? 'checked' : '') ?>
     178                                          value="1">
     179                                    <label for="wp-phone-message-phone-active-widget">Active Phone Input Area in
     180                                          widget</label>
     181                              </td>
     182                              <td>
     183                                    <input type="checkbox" id="wp-phone-message-phone-mandatory"
     184                                          name="wp-phone-message-phone-mandatory"
     185                                          <?= ( get_option('wp-phone-message-phone-mandatory') ? 'checked' : '') ?>
     186                                          value="required">
     187                                    <label for="wp-phone-message-phone-mandatory">Phone Input Area Mandatory</label>
     188                              </td>
     189                              <td>
     190                                    <input name="wp-phone-message-phone" type="text" id="wp-phone-message-phone"
     191                                          value="<?= get_option('wp-phone-message-phone'); ?>" class="regular-text" />
     192                                    <p class="description" id="wp-phone-message-phone-description">The Phone area input
     193                                          placeholder.</p>
     194                              </td>
     195                        </tr>
     196                        <tr>
     197                              <th scope="row">
     198                                    <label for="wp-phone-message-email">
     199                                          Email Address Area :
     200                                    </label>
     201                              </th>
     202                              <td>
     203                                    <input type="checkbox" id="wp-phone-message-email-active"
     204                                          name="wp-phone-message-email-active"
     205                                          <?= ( get_option('wp-phone-message-email-active') ? 'checked' : '') ?>
     206                                          value="1">
     207                                    <label for="wp-phone-message-email-active">Active Email Address Input Area in
     208                                          shortcode</label>
     209                              </td>
     210                              <td>
     211                                    <input type="checkbox" id="wp-phone-message-email-active-widget"
     212                                          name="wp-phone-message-email-active-widget"
     213                                          <?= ( get_option('wp-phone-message-email-active-widget') ? 'checked' : '') ?>
     214                                          value="1">
     215                                    <label for="wp-phone-message-email-active-widget">Active Email Address Input Area in
     216                                          widget</label>
     217                              </td>
     218                              <td>
     219                                    <input type="checkbox" id="wp-phone-message-email-mandatory"
     220                                          name="wp-phone-message-email-mandatory"
     221                                          <?= ( get_option('wp-phone-message-email-mandatory') ? 'checked' : '') ?>
     222                                          value="required">
     223                                    <label for="wp-phone-message-email-mandatory">Email Address Input Area
     224                                          Mandatory</label>
     225                              </td>
     226                              <td>
     227                                    <input name="wp-phone-message-email" type="text" id="wp-phone-message-email"
     228                                          value="<?= get_option('wp-phone-message-email'); ?>" class="regular-text" />
     229                                    <p class="description" id="wp-phone-message-email-description">The Email Address
     230                                          area input placeholder.</p>
     231                              </td>
     232                        </tr>
     233                        <tr>
     234                              <th scope="row">
     235                                    <label for="wp-phone-message-textarea">
     236                                          Text Area Placeholder :
     237                                    </label>
     238                              </th>
     239                              <td>
     240                                    <input name="wp-phone-message-textarea" type="text" id="wp-phone-message-textarea"
     241                                          value="<?= get_option('wp-phone-message-textarea'); ?>"
     242                                          class="regular-text" />
     243                                    <p class="description" id="wp-phone-message-textarea-description">The textarea
     244                                          placeholder.</p>
     245                              </td>
     246                        </tr>
     247                        <tr>
     248                              <th scope="row">
     249                                    <label for="wp-phone-message-title">
     250                                          Button Title :
     251                                    </label>
     252                              </th>
     253                              <td>
     254                                    <input name="wp-phone-message-button" type="text" id="wp-phone-message-button"
     255                                          value="<?= get_option('wp-phone-message-button'); ?>" class="regular-text" />
     256                                    <p class="description" id="wp-phone-message-button-description">The Button Title
     257                                          will appear on the button of the message form.</p>
     258                              </td>
     259                        </tr>
     260                  </tbody>
    184261            </table>
    185262
    186263            <div class="form-messages">
    187                 <?php echo get_option('wp-phone-message-form-message'); ?>
    188                 <input type="hidden" id="wp-phone-message-full-phone-number" value="<?= get_option('wp-phone-message-full-phone-number'); ?>" />
     264                  <?php echo get_option('wp-phone-message-form-message'); ?>
     265                  <input type="hidden" id="wp-phone-message-full-phone-number"
     266                        value="<?= get_option('wp-phone-message-full-phone-number'); ?>" />
    189267            </div>
    190268
     
    193271                submit_button();
    194272            ?>
    195         </form>
    196     </div><!-- .wrap -->
    197     <?php
     273      </form>
     274</div><!-- .wrap -->
     275<?php
    198276    }
    199     else { 
     277    else {
    200278    ?>
    201         <p> <?php __("You are not authorized to perform this operation.") ?> </p>
    202     <?php   
     279<p> <?php __("You are not authorized to perform this operation.") ?> </p>
     280<?php   
    203281    }
  • wp-phone-message/trunk/wp-phone-message.php

    r2333369 r2415319  
    44 * Plugin URI:        https://github.com/webmarcello8080/wp-phone-message
    55 * Description:       Send a whatsapp message from your Wordpress website. You can render a message form through shotcode or widget.
    6  * Version:           1.0.5
     6 * Version:           1.0.6
    77 * Requires at least: 4.5.13
    88 * Requires PHP:      5.6
Note: See TracChangeset for help on using the changeset viewer.