Plugin Directory

Changeset 2842501


Ignore:
Timestamp:
01/02/2023 08:19:41 PM (3 years ago)
Author:
nant82
Message:

Update to version master from GitHub

Location:
airport-transfers
Files:
18 added
8 deleted
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • airport-transfers/assets/icon.svg

    • Property svn:mime-type set to image/svg+xml
  • airport-transfers/assets/screenshot-1.jpg

    • Property svn:mime-type changed from image/png to image/jpeg
  • airport-transfers/assets/screenshot-2.jpg

    • Property svn:mime-type changed from image/png to image/jpeg
  • airport-transfers/tags/master/README.md

    r1959832 r2842501  
    1 === Airport Transfers ===
    2 Contributors: atanasantonov
    3 Receive orders for transfer with this simple plugin. Easy to install and configure for your needs. Unlimited airports. Polylang compatible and fully translatable!
    4 Tags: transfer, airport, arrival, departure
    5 Requires at least: 3.0.1
    6 Tested up to: 5.0
    7 Requires PHP: 5.6
    8 Stable tag: trunk
    9 License: GPLv2
    10 License URI: http://www.gnu.org/licenses/gpl-2.0.html
    11  
     1#  Airport Transfers
     2
    123Special airport transfers form that delivers mail to an administrator with customer's data.
    13  
    14 == Description ==
    15  
    16 Receive orders for transfer with this simple plugin. Easy to install and configure for your needs. Form is designed to serve as transfer order tool.
    174
    18 The plugin has full localisation and internationalisation support. Polylang compatible!
    19  
     5Form is designed to serve as transfer order tool. Design is airport transfers ready.
     6
     7The plugin has full l10n and i18n support.
     8
    209There are several options like mails for the delivery and default settings.
    21  
    22 == Installation ==
     10
     11= Features =
     12* Simple & Intuitive
     13* Flexible transfer reservation form
     14* Multiple emails can be used for notifications
     15
     16## Installation
    2317
    2418Download and activate the plugin. The plugin works with shortcode:
     
    3327
    3428After the settings are done and the shortcode is placed on the desired pages you are ready to operate.
    35  
    36 == Frequently Asked Questions ==
    3729
    38 = Can I customize where the emails will be delivered? =
    39  
     30## Screenshots
     31
     32![This screen shows the settings page](.wordpress-org/screenshot-1.jpg?raw=true "Settings page")
     33
     34![This screen shows the form in the page on the frontend](.wordpress-org/screenshot-2.jpg?raw=true "Form on the frontend")
     35
     36## Frequently Asked Questions
     37
     38### Can I customize where the emails will be delivered?
     39
    4040Yes, you can add as many emails for delivery as you want. The only rule is that they must be comma separated.
    4141
    42 = Can I place a custom contact information? =
    43  
     42### Can I place a custom contact information?
     43
    4444Yes, you can place your phone/phones and email.
    4545
    46 = Can I customize the destination country? =
    47  
     46### Can I customize the destination country?
     47
    4848Yes, you can set any country you want. It can be a default one and as option in every page where the shorcode is placed.
    4949
    50 = Can I switch between 12 and 24 hour format? =
    51  
     50### Can I switch between 12 and 24 hour format?
     51
    5252Yes, you can choose default the format in the settings page and also as option in every page where the shorcode is placed..
    53  
    54 = Is there a limitation of airports number? =
    55  
     53
     54### Is there a limitation of airports number?
     55
    5656No, you can add as many airports in the dropdown as you wish.
    57  
    58 = What about the number of request? =
    59  
     57
     58### What about the number of request?
     59
    6060There is no limitation. You can recieve as many orders as they are submitted.
    6161
    62 = Is there a mandatory fields verification? =
    63  
     62### Is there a mandatory fields verification?
     63
    6464Yes, the most important fields are validated twice - both on client's machine and on the server. Especially the email address.
    6565
    66 = How can the customer understand that is missing something? =
    67  
     66### How can the customer understand that is missing something?
     67
    6868There is a nice gentle modal window that is opened when mandatory field is empty.
    6969
    70 == Screenshots ==
    71  
    72 1. This screen shows the settings page.
     70## Changelog
    7371
    74 2. This is the second screens shows the form in the page on frontend.
     72### 1.1
     73* Security fixes.
    7574
    76 == Donations ==
    77 
    78 If you like the plugin and it helps you to offer better services at your clients you can buy me a fruit!
    79 
    80 (BTC) 1ATAnAsK2wwDGK6UKrUewJDWtZ6kgJXEYu
    81 (LTC) LdoQwdNn2FQAap8QBYDP8H4TetGmhhx3vj
    82 (ZEC) t1VXcnmXZPaEfXtkshmhBtWEHy1CHqETh1V
    83  
    84 == Changelog ==
    85  
    86 = 1.0 =
     75### 1.0
    8776* First release.
    8877* No changes.
    89  
    90 == Upgrade Notice ==
    91  
    92 = 1.0 =
    93 
    94 No upgrades needed at this time.
  • airport-transfers/tags/master/admin/class-airport-transfers-admin.php

    r1725009 r2842501  
    44
    55class NS_Airport_Transfers_Admin {
    6    
    7   private static  $initiated   = FALSE;
    8   private static  $class       = 'NS_Airport_Transfers_Admin';
    9   public static   $prefix      = 'ns_admin_';
    10   public static   $textdomain  = 'ns-airport-transfers';
    11   public static   $settings    = 'ns-airport-transfers-group';
    126
    13   public static function init() {       
    14     if(!self::$initiated) {
    15       self::ns_admin_init_hooks();
    16     }
    17   }
     7    private static  $initiated   = FALSE;
     8    public static   $settings    = 'ns-airport-transfers-group';
    189
    19   /**
    20   * Initializes WordPress hooks
    21   */
    22   private static function ns_admin_init_hooks() {
    23     add_action( 'admin_init', array( self::$class, self::$prefix.'init' ) );
    24     add_action( 'admin_init', array( self::$class, self::$prefix.'texts' ) );
    25     add_action( 'admin_menu', array( self::$class, self::$prefix.'menu' ) );   
    26     add_action( 'admin_init', array( self::$class, self::$prefix.'register_settings' ) );
    27    
    28     self::$initiated = TRUE;
    29   }
     10    /**
     11     * Init.
     12     */
     13    public static function init() {
     14        if( ! self::$initiated ) {
     15            self::init_hooks();
     16        }
     17    }
    3018
    31   public static function ns_admin_init() {
    3219
    33   }
    34  
    35   public static function ns_admin_menu() {
    36     add_menu_page('Airport Transfers', 'Airport Transfers', 'edit_posts', self::$textdomain.'-settings', array( self::$class, self::$prefix.'settings_page' ),'dashicons-admin-generic');
    37   }
    38  
    39   public static function ns_admin_register_settings() {
    40     register_setting( self::$settings, 'ns-airport-transfers-admin-email' );
    41     register_setting( self::$settings, 'ns-airport-transfers-contact-email' );
    42     register_setting( self::$settings, 'ns-airport-transfers-contact-phone' );
    43     register_setting( self::$settings, 'ns-airport-transfers-country' );
    44     register_setting( self::$settings, 'ns-airport-transfers-resort' );
    45     register_setting( self::$settings, 'ns-airport-transfers-time-format' );
    46   }
    47  
    48   public static function ns_admin_settings_page() {
    49     require_once( plugin_dir_path(__FILE__) . 'views/settings-page.php' );
    50   }
     20    /**
     21     * Register hooks.
     22     */
     23    private static function init_hooks() {
     24        add_action( 'admin_init', array( '\NS_Airport_Transfers_Admin', 'init' ) );
     25        add_action( 'admin_menu', array( '\NS_Airport_Transfers_Admin', 'admin_menu' ) );
     26        add_action( 'admin_init', array( '\NS_Airport_Transfers_Admin', 'register_settings' ) );
    5127
    52   public static function ns_admin_texts() {
     28        self::$initiated = TRUE;
     29    }
    5330
    54     // prepare the texts
    55     global $texts;
    5631
    57     foreach ($texts as $text)
    58     {
    59       __($text,self::$textdomain);
    60       if(function_exists('pll_register_string'))
    61       {
    62         pll_register_string(__('Form elements',self::$textdomain), $text, 'Airport Transfers');   
    63       } 
    64     }
    65   }
    66  
    67   // ajax form handler
    68   public static function ns_admin_send() {   
    69     try {
    70       // check post at all
    71       if(empty($_POST)) {
    72         throw new Exception(airport_transfers_lang('Incorrect data!'));
    73       }
    74      
    75       $post = $_POST;
     32    /**
     33     * Admin menu.
     34     */
     35    public static function admin_menu() {
     36        add_submenu_page(
     37            'options-general.php',
     38            'Airport Transfers',
     39            'Airport Transfers',
     40            'edit_posts',
     41            'ns-airport-transfers-settings',
     42            array( '\NS_Airport_Transfers_Admin', 'settings_page' ),
     43            100
     44        );
     45    }
    7646
    77      
    78       $lang = sanitize_text_field($post['lang']);
    79      
    80       // check email
    81       $email = filter_var(sanitize_email($post['email']), FILTER_VALIDATE_EMAIL);
    82       if (!$email) {
    83         throw new Exception(airport_transfers_lang('Invalid email address!'));
    84       }
    85      
    86       // Subject
    87       $subject  = airport_transfers_lang('Request');
    8847
    89       // Message     
    90       $message = '';
    91      
    92       // information
    93       $message .= airport_transfers_lang('Your Name', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['name'])).PHP_EOL;
    94       $message .= airport_transfers_lang('Email Address', $lang).": ".$email.PHP_EOL;
    95       $message .= airport_transfers_lang('Mobile', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['phone'])).PHP_EOL;
    96       $message .= airport_transfers_lang('I would like to', $lang).": ".sanitize_text_field($post['like_to']).PHP_EOL;
    97       $message .= airport_transfers_lang('Transfer type', $lang).": ".airport_transfers_lang(sanitize_text_field($post['transfer_type']), $lang).PHP_EOL;
    98       $message .= airport_transfers_lang('No. of adults', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['adults'])).PHP_EOL;
    99       $message .= airport_transfers_lang('No. of children', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['children'])).PHP_EOL;
    100       $message .= airport_transfers_lang('No. of koffers', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['koffers'])).PHP_EOL;
    101       if(sanitize_text_field($post['resort'])==='winter') {
    102         $message .= airport_transfers_lang('No. of ski/snowboards', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['ski'])).PHP_EOL;
    103       }
    104  
    105       $message .= PHP_EOL;
    106      
    107       // transfer_type
    108       $transfer_type = sanitize_text_field($post['transfer_type']);
    109      
    110       // time format
    111       $time_format = sanitize_text_field($post['time_format']);
    112      
    113       // arrival 
    114       $post_arrival_us_time = sanitize_text_field($post['arrival_us_time']);
    115       $arrival_us_time = ($time_format==='12'&&$post_arrival_us_time!=='') ? $post_arrival_us_time : '';
    116       if($transfer_type==='two_way' || $transfer_type==='from_airport') {
    117         $message .= airport_transfers_lang('Date of arrival', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['arrival_date'])).PHP_EOL;       
    118         $message .= airport_transfers_lang('Time of arrival', $lang).": ".sanitize_text_field($post['arrival_hour']).':'.sanitize_text_field($post['arrival_minutes']).$arrival_us_time.PHP_EOL;       
    119         $message .= airport_transfers_lang('Airport', $lang).": ".sanitize_text_field($post['arrival_airport']).PHP_EOL;
    120         $message .= airport_transfers_lang('Flight number', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['arrival_flight'])).PHP_EOL;
    121         $message .= PHP_EOL;
    122       }
    123      
    124       // departure
    125       $post_out_us_time = sanitize_text_field($post['out_us_time']);
    126       $out_us_time = ($time_format==='12'&&$post_out_us_time!=='') ? $post_out_us_time : '';
    127       if($transfer_type==='two_way' || $transfer_type==='to_airport') {
    128         $message .= airport_transfers_lang('Date of departure', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['out_date'])).PHP_EOL;       
    129         $message .= airport_transfers_lang('Time of departure', $lang).": ".sanitize_text_field($post['out_hour']).':'.sanitize_text_field($post['out_minutes']).$out_us_time.PHP_EOL;       
    130         $message .= airport_transfers_lang('Airport', $lang).": ".sanitize_text_field($post['out_airport']).PHP_EOL;
    131         $message .= airport_transfers_lang('Flight number', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['out_flight'])).PHP_EOL;
    132         $message .= PHP_EOL;
    133       }
    134      
    135       // address in destination country
    136       $message .= airport_transfers_lang('Address in', $lang).' '.airport_transfers_lang(get_option('ns-airport-transfers-country'), $lang).PHP_EOL;
    137       $message .= airport_transfers_lang('Address of hotel/accommodation', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['adress'])).PHP_EOL;
    138      
    139       // instructions
    140       $message .= airport_transfers_lang('Remarks/instructions', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['instructions'])).PHP_EOL;
    141      
    142       // Headers
    143       $headers  = 'MIME-Version: 1.0' . PHP_EOL;
    144       $headers .= 'Content-type: text/plain; charset=utf-8' . PHP_EOL;
    145       $headers .= 'Content-Transfer-Encoding: 7bit' . PHP_EOL;
    146       $headers .= 'Message-ID: <' . time() . '-'. md5($email).'>' . PHP_EOL;
    147       $headers .= 'From: '.get_option('blogname').' <'.get_option('admin_email').'>' . PHP_EOL;           
    148       $headers .= 'Return-Path: <'.get_option('admin_email').'>' . PHP_EOL;
    149      
    150       // get administrative emails for the form
    151       if(!mail(get_option('ns-airport-transfers-admin-email'), $subject, $message, $headers)) {
    152         $error_message  = 'Sending mail failed!'.PHP_EOL.PHP_EOL;
    153         $error_message  = 'Form message:'.PHP_EOL.PHP_EOL;
    154         $error_message .= print_r($message,TRUE).PHP_EOL;         
    155         mail(get_option('admin_email'), 'Airport Transfers Plugin', $error_message, $headers);
    156         throw new Exception(airport_transfers_lang('System Error!', $lang));
    157       }
    158      
    159       $result['status'] = 'success';
    160       $result['data'] = airport_transfers_lang('Thank you for your submission! We will answer as soon as possible!', $lang);
    161      
    162     } catch (Exception $e) {
    163       $result['status'] = 'error';
    164       $result['data'] = $e->getMessage();
    165     } finally {
    166       echo json_encode($result);     
    167     }
    168     wp_die();
    169   }
     48    /**
     49     * Register settings.
     50     */
     51    public static function register_settings() {
     52        register_setting( self::$settings, 'ns-airport-transfers-admin-email' );
     53        register_setting( self::$settings, 'ns-airport-transfers-contact-email' );
     54        register_setting( self::$settings, 'ns-airport-transfers-contact-phone' );
     55        register_setting( self::$settings, 'ns-airport-transfers-country' );
     56        register_setting( self::$settings, 'ns-airport-transfers-resort' );
     57        register_setting( self::$settings, 'ns-airport-transfers-time-format' );
     58    }
     59
     60
     61    /**
     62     * Settings page.
     63     */
     64    public static function settings_page() {
     65        require_once( NS_AIRPORT_TRANSFERS_PATH . 'admin/views/settings-page.php' );
     66    }
    17067}
    17168
  • airport-transfers/tags/master/admin/views/settings-page.php

    r1725009 r2842501  
    33<div class="wrap">
    44<h1>Airport Transfers</h1>
    5 <p class="description"><span class="dashicons dashicons-admin-settings"></span> <?php echo __('Styling and functionality settings',self::$textdomain); ?>.</p>
     5<p class="description"><span class="dashicons dashicons-admin-settings"></span> <?php esc_html_e('Styling and functionality settings','ns-airport-transfers'); ?>.</p>
    66
    77<form method="post" action="options.php">
    88  <?php settings_fields( self::$settings ); ?>
    99  <?php do_settings_sections( self::$settings ); ?>
    10  
    11   <table class="form-table"> 
    12    
     10
     11  <table class="form-table">
     12
    1313    <tr>
    14       <th scope="row"><?php echo __('Admin email/emails',self::$textdomain); ?></th>
     14      <th scope="row"><?php esc_html_e('Admin email/emails','ns-airport-transfers'); ?></th>
    1515      <td>
    1616        <input type="text" name="ns-airport-transfers-admin-email" value="<?php echo esc_attr( get_option('ns-airport-transfers-admin-email') ); ?>" class="large-text" />
    17         <p class="description"><?php echo __('Email/emails for delivery. Comma separated if more than one (admin1@example.com, admin2@example.com, ...)',self::$textdomain); ?></p>
     17        <p class="description"><?php esc_html_e('Email/emails for delivery. Comma separated if more than one (admin1@example.com, admin2@example.com, ...)','ns-airport-transfers'); ?></p>
    1818      <br><hr></td>
    1919    </tr>
    20    
     20
    2121    <tr>
    22       <th scope="row"><?php echo __('Contact email',self::$textdomain); ?></th>
     22      <th scope="row"><?php esc_html_e('Contact email','ns-airport-transfers'); ?></th>
    2323      <td>
    2424        <input type="text" name="ns-airport-transfers-contact-email" value="<?php echo esc_attr( get_option('ns-airport-transfers-contact-email') ); ?>" class="large-text" />
    25         <p class="description"><?php echo __('Contact email.',self::$textdomain); ?></p>
     25        <p class="description"><?php esc_html_e('Contact email.','ns-airport-transfers'); ?></p>
    2626      <br><hr></td>
    2727    </tr>
    28    
     28
    2929    <tr>
    30       <th scope="row"><?php echo __('Contact phone/phones',self::$textdomain); ?></th>
     30      <th scope="row"><?php esc_html_e('Contact phone/phones','ns-airport-transfers'); ?></th>
    3131      <td>
    3232        <input type="text" name="ns-airport-transfers-contact-phone" value="<?php echo esc_attr( get_option('ns-airport-transfers-contact-phone') ); ?>" class="large-text" />
    33         <p class="description"><?php echo __('Contact phone/phones.',self::$textdomain); ?></p>
     33        <p class="description"><?php esc_html_e('Contact phone/phones.','ns-airport-transfers'); ?></p>
    3434      <br><hr></td>
    3535    </tr>
    36        
     36
    3737    <tr>
    38       <th scope="row"><?php echo __('Default destination country',self::$textdomain); ?></th>
     38      <th scope="row"><?php esc_html_e('Default destination country','ns-airport-transfers'); ?></th>
    3939      <td>
    4040        <input type="text" name="ns-airport-transfers-country" value="<?php echo esc_attr( get_option('ns-airport-transfers-country') ); ?>" />
    41         <p class="description"><?php echo __('Set the country (also can be set in the shortcode [airport-transfers-form country="Earthsea"])',self::$textdomain); ?></p> 
     41        <p class="description"><?php esc_html_e('Set the country (also can be set in the shortcode [airport-transfers-form country="Earthsea"])','ns-airport-transfers'); ?></p>
    4242      </td>
    4343    </tr>
    44    
     44
    4545    <tr>
    46       <th scope="row"><?php echo __('Resort type',self::$textdomain); ?></th>
     46      <th scope="row"><?php esc_html_e('Resort type','ns-airport-transfers'); ?></th>
    4747      <td>
    4848        <select name="ns-airport-transfers-resort">
     
    5454        <?php foreach ($options as $value => $name) : ?>
    5555          <?php $selected = ($format===$value) ? ' selected="selected"' : ''; ?>
    56           <option value="<?php echo $value; ?>"<?php echo $selected; ?>><?php echo __($name,self::$textdomain); ?></option>
     56          <option value="<?php echo $value; ?>"<?php echo $selected; ?>><?php esc_html_e($name,'ns-airport-transfers'); ?></option>
    5757        <?php endforeach; ?>
    5858        </select>
    59         <p class="description"><?php echo __('Select default resort type (also can be set in the shortcode [airport-transfers-form resort="summer/winter"])',self::$textdomain); ?></p> 
     59        <p class="description"><?php esc_html_e('Select default resort type (also can be set in the shortcode [airport-transfers-form resort="summer/winter"])','ns-airport-transfers'); ?></p>
    6060      </td>
    6161    </tr>
    62    
     62
    6363    <tr>
    64       <th scope="row"><?php echo __('Time format',self::$textdomain); ?></th>
     64      <th scope="row"><?php esc_html_e('Time format','ns-airport-transfers'); ?></th>
    6565      <td>
    6666        <select name="ns-airport-transfers-time-format">
     
    6969        <?php foreach ($options as $option) : ?>
    7070          <?php $selected = ($format===$option) ? ' selected="selected"' : ''; ?>
    71           <option value="<?php echo $option; ?>"<?php echo $selected; ?>><?php echo $option; ?> <?php echo __('Hours',self::$textdomain); ?></option>
     71          <option value="<?php echo $option; ?>"<?php echo $selected; ?>><?php echo $option; ?> <?php esc_html_e('Hours','ns-airport-transfers'); ?></option>
    7272        <?php endforeach; ?>
    7373        </select>
    74         <p class="description"><?php echo __('Select default time-format (also can be set in the shortcode [airport-transfers-form time-format="24"])',self::$textdomain); ?></p> 
     74        <p class="description"><?php esc_html_e('Select default time-format (also can be set in the shortcode [airport-transfers-form time-format="24"])','ns-airport-transfers'); ?></p>
    7575      </td>
    7676    </tr>
  • airport-transfers/tags/master/airport-transfers.php

    r1725009 r2842501  
    1 <?php 
     1<?php
    22/*
    33Plugin Name: Airport Transfers
    4 Plugin URI:  https://github.com/atanasantonov/wordpress-plugins/tree/master/airport-transfers
     4Plugin URI:  https://github.com/atanasantonov/airport-transfers
    55Description: Plugin delivers multilingual form for airport transfers
    6 Version:     1.0
     6Version: master
    77Author:      Atanas Antonov
    8 Author URI:  http://nantstudio.eu/
     8Author URI:  https://unax.org
    99License:     GPL2
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111Text Domain: ns-airport-transfers
    12 Domain Path: /languages
     12Domain Path: /languages/
    1313*/
    1414
    1515defined( 'ABSPATH' ) or die( 'I can\'t do anything alone! Sorry!' );
    16  
     16
     17define( 'NS_AIRPORT_TRANSFERS_VERSION', 'master' );
     18define( 'NS_AIRPORT_TRANSFERS_PATH', plugin_dir_path( __FILE__ ) );
     19define( 'NS_AIRPORT_TRANSFERS_URL', plugins_url( '/', __FILE__ ) );
     20
     21load_plugin_textdomain('ns-airport-transfers', false, basename( dirname( __FILE__ ) ) . '/languages' );
     22
     23require_once( NS_AIRPORT_TRANSFERS_PATH . 'functions.php' );
     24require_once( NS_AIRPORT_TRANSFERS_PATH . 'admin/class-airport-transfers-admin.php' );
     25require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/class-airport-transfers.php' );
     26
    1727register_activation_hook( __FILE__, 'ns_airport_transfers_activate' );
    1828register_deactivation_hook( __FILE__, 'ns_airport_transfers_uninstall' );
    1929
    20 // add the options defaults
    21 function ns_airport_transfers_activate() {
    22   add_option( 'ns-airport-transfers-admin-email', get_option('admin_email')); // Admin email delivery and contact address
    23   add_option( 'ns-airport-transfers-contact-email', '' ); // Contant email
    24   add_option( 'ns-airport-transfers-contact-phone', '' ); // Contant phone
    25   add_option( 'ns-airport-transfers-country', 'Earthsea' ); // Can be set in plugin's settings page or trough the shortcode
    26   add_option( 'ns-airport-transfers-resort', 'summer' );  // Include ski field or not. Can be set in plugin's settings page or trough the shortcode
    27   add_option( 'ns-airport-transfers-time-format', '24' );  // 12 or 24 Hours time format. Can be set in plugin's settings page or trough the shortcode
     30if ( is_admin() ) {
     31    \NS_Airport_Transfers_Admin::init();
     32    add_action( 'init', array( '\NS_Airport_Transfers_Admin', 'init' ) );
    2833}
    2934
    30 // delete the unnecessary options from the database
    31 function ns_airport_transfers_uninstall() {
    32   delete_option('ns-airport-transfers-admin-email');
    33   delete_option('ns-airport-transfers-contact-email');
    34   delete_option('ns-airport-transfers-contact-phone');
    35   delete_option('ns-airport-transfers-country');
    36   delete_option('ns-airport-transfers-resort');
    37   delete_option('ns-airport-transfers-time-format');
    38 }
    39 
    40 load_plugin_textdomain('ns-airport-transfers', false, basename( dirname( __FILE__ ) ) . '/languages' );
    41 require_once( plugin_dir_path(__FILE__) . 'texts.php' );
    42 
    43 /**
    44  * airport_transfers_lang
    45  *
    46  * returns translation of the string
    47  * @param string $string - string to be translated
    48  * @param string $lang - desired language
    49  * Function check if Polylang plugin's 'pll_translate_string' function
    50  * is available. If so the plugin's function will be used. Otherwise Wordpress translation system will be used.
    51 */
    52 function airport_transfers_lang($string='',$lang=null) {
    53   if(function_exists('pll_translate_string')) {
    54     $string = isset($lang) ? pll_translate_string($string, $lang) : pll__($string);
    55   } else {
    56     $string = __($string, 'ns-airport-transfers');
    57   }
    58   return $string;
    59 }
    60 
    61 /**
    62  * airport_transfers_lang_e
    63  *
    64  * returns translation of the string with echo
    65  * @param string $string - string to be translated
    66  * @param string $lang - desired language
    67  * same as airport_transfers_lang but with echo
    68 */
    69 function airport_transfers_lang_e($string='',$lang=null) {
    70   if(function_exists('pll_translate_string')) {
    71     $string = isset($lang) ? pll_translate_string($string, $lang) : pll__($string);
    72   } else {
    73     $string = __($string, 'ns-airport-transfers');
    74   }
    75   echo $string;
    76   return;
    77 }
    78 
    79 /**
    80  * airport_transfers_check_val
    81  *
    82  * returns '-' if param is empty string
    83  * @param string $string
    84 */
    85 function airport_transfers_check_val($string='') {
    86   $string = ($string!='') ? $string : '-';
    87   return $string;
    88 }
    89 
    90 if (is_admin()) { 
    91   require_once( plugin_dir_path(__FILE__) . 'admin/class-airport-transfers-admin.php' );
    92   add_action( 'init', array( 'NS_Airport_Transfers_Admin', 'init' ) );
    93  
    94   // register ajax functions for the fronend
    95   add_action( 'wp_ajax_send', array( 'NS_Airport_Transfers_Admin', 'ns_admin_send' ));
    96   add_action( 'wp_ajax_nopriv_send', array( 'NS_Airport_Transfers_Admin', 'ns_admin_send' ));
    97 }
    98 else
    99 {
    100   function ns_enqueue_scripts() {
    101     // load css
    102     wp_enqueue_style( 'bootstrap', plugins_url('assets/bootstrap/css/bootstrap.min.css', __FILE__));
    103     wp_enqueue_style( 'jquery-ui', plugins_url('assets/jquery-ui/jquery-ui.min.css', __FILE__));
    104     wp_enqueue_style( 'ns-airport-transfers', plugins_url('assets/css/styles.css', __FILE__));
    105 
    106     // load scripts
    107     wp_enqueue_script('jquery');
    108     wp_enqueue_script('jquery-ui-datepicker');       
    109     wp_enqueue_script('bootstrap', plugins_url('assets/bootstrap/js/bootstrap.min.js',  __FILE__ ),array('jquery'));
    110   }
    111   add_action( 'wp_enqueue_scripts','ns_enqueue_scripts');
    112  
    113   require_once( plugin_dir_path(__FILE__) . 'public/class-airport-transfers.php' );   
    114   add_action( 'init', array( 'NS_Airport_Transfers', 'init' ) );
    115 }
     35\NS_Airport_Transfers::init();
  • airport-transfers/tags/master/languages/ns-airport-transfers.pot

    r1725009 r2842501  
    22msgid ""
    33msgstr ""
    4 "Project-Id-Version: PACKAGE VERSION\n"
     4"Project-Id-Version: Airport Transfers\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2017-08-30 11:45+0000\n"
     6"POT-Creation-Date: 2023-01-02 17:48+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    99"Language-Team: \n"
    1010"Language: \n"
    11 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n"
     11"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    1212"MIME-Version: 1.0\n"
    1313"Content-Type: text/plain; charset=UTF-8\n"
    1414"Content-Transfer-Encoding: 8bit\n"
    15 "X-Generator: Loco - https://localise.biz/"
     15"X-Generator: Loco https://localise.biz/\n"
     16"X-Loco-Version: 2.6.2; wp-6.0.3\n"
     17"X-Domain: ns-airport-transfers"
     18
     19#: public/class-airport-transfers.php:190 public/views/form.php:197
     20msgid "Address in"
     21msgstr ""
     22
     23#: public/class-airport-transfers.php:191 public/views/form.php:202
     24msgid "Address of hotel/accommodation"
     25msgstr ""
     26
     27#: admin/views/settings-page.php:14
     28msgid "Admin email/emails"
     29msgstr ""
     30
     31#: public/views/form.php:80
     32msgid "After arrival"
     33msgstr ""
     34
     35#: public/class-airport-transfers.php:173
     36#: public/class-airport-transfers.php:184 public/views/form.php:117
     37#: public/views/form.php:175
     38msgid "Airport"
     39msgstr ""
     40
     41#. Name of the plugin
     42msgid "Airport Transfers"
     43msgstr ""
     44
     45#. Author of the plugin
     46msgid "Atanas Antonov"
     47msgstr ""
     48
     49#: public/views/modal-error.php:7 public/views/modal-error.php:22
     50msgid "Close"
     51msgstr ""
     52
     53#: admin/views/settings-page.php:22
     54msgid "Contact email"
     55msgstr ""
     56
     57#: admin/views/settings-page.php:25
     58msgid "Contact email."
     59msgstr ""
     60
     61#: admin/views/settings-page.php:30
     62msgid "Contact phone/phones"
     63msgstr ""
     64
     65#: admin/views/settings-page.php:33
     66msgid "Contact phone/phones."
     67msgstr ""
     68
     69#: public/class-airport-transfers.php:171 public/views/form.php:83
     70msgid "Date of arrival"
     71msgstr ""
     72
     73#: public/class-airport-transfers.php:182 public/views/form.php:141
     74msgid "Date of departure"
     75msgstr ""
     76
     77#: admin/views/settings-page.php:38
     78msgid "Default destination country"
     79msgstr ""
     80
     81#: public/class-airport-transfers.php:56 public/class-airport-transfers.php:148
     82msgid "Email Address"
     83msgstr ""
     84
     85#: public/views/form.php:18
     86msgid "Email address"
     87msgstr ""
     88
     89#: admin/views/settings-page.php:17
     90msgid ""
     91"Email/emails for delivery. Comma separated if more than one (admin1@example."
     92"com, admin2@example.com, ...)"
     93msgstr ""
     94
     95#: public/views/modal-error.php:8
     96msgid "Error"
     97msgstr ""
     98
     99#: public/class-airport-transfers.php:174
     100#: public/class-airport-transfers.php:185 public/views/form.php:129
     101#: public/views/form.php:187
     102msgid "Flight number"
     103msgstr ""
     104
     105#: public/views/form.php:46 public/views/form.php:80
     106msgid "From airport"
     107msgstr ""
     108
     109#: public/views/form.php:93 public/views/form.php:151
     110msgid "Hour"
     111msgstr ""
     112
     113#: admin/views/settings-page.php:71
     114msgid "Hours"
     115msgstr ""
     116
     117#. URI of the plugin
     118msgid "https://github.com/atanasantonov/airport-transfers"
     119msgstr ""
     120
     121#. Author URI of the plugin
     122msgid "https://unax.org"
     123msgstr ""
     124
     125#: public/class-airport-transfers.php:150 public/views/form.php:34
     126msgid "I would like to"
     127msgstr ""
     128
     129#: public/class-airport-transfers.php:131
     130msgid "Incorrect data!"
     131msgstr ""
     132
     133#: public/views/form.php:8
     134msgid "Information about you"
     135msgstr ""
     136
     137#: public/class-airport-transfers.php:137
     138msgid "Invalid email address!"
     139msgstr ""
     140
     141#: public/views/form.php:29
     142msgid "It's mandatory to input your phone number"
     143msgstr ""
     144
     145#: public/views/form.php:4
     146msgid "Javascript must be enabled!"
     147msgstr ""
     148
     149#: public/views/form.php:138
     150msgid "Leaving"
     151msgstr ""
     152
     153#: public/views/form.php:36
     154msgid "Make reservation"
     155msgstr ""
     156
     157#: public/class-airport-transfers.php:58
     158msgid "Mandatory Field"
     159msgstr ""
     160
     161#: public/views/form.php:101 public/views/form.php:159
     162msgid "Min"
     163msgstr ""
     164
     165#: public/class-airport-transfers.php:57 public/class-airport-transfers.php:149
     166#: public/views/form.php:26
     167msgid "Mobile"
     168msgstr ""
     169
     170#: public/class-airport-transfers.php:152 public/views/form.php:53
     171msgid "No. of adults"
     172msgstr ""
     173
     174#: public/class-airport-transfers.php:153 public/views/form.php:58
     175msgid "No. of children"
     176msgstr ""
     177
     178#: public/class-airport-transfers.php:154 public/views/form.php:65
     179msgid "No. of koffers"
     180msgstr ""
     181
     182#: public/class-airport-transfers.php:156 public/views/form.php:71
     183msgid "No. of ski/snowboards"
     184msgstr ""
     185
     186#: public/views/form.php:21
     187msgid "On this Email you will recieve confirmation"
     188msgstr ""
     189
     190#: public/views/form.php:46 public/views/form.php:47
     191msgid "One way"
     192msgstr ""
     193
     194#. Description of the plugin
     195msgid "Plugin delivers multilingual form for airport transfers"
     196msgstr ""
     197
     198#: public/class-airport-transfers.php:194 public/views/form.php:211
     199msgid "Remarks/instructions"
     200msgstr ""
     201
     202#: public/class-airport-transfers.php:141
     203msgid "Request"
     204msgstr ""
     205
     206#: public/views/form.php:37
     207msgid "Request more information"
     208msgstr ""
     209
     210#: admin/views/settings-page.php:46
     211msgid "Resort type"
     212msgstr ""
     213
     214#: public/views/form.php:120 public/views/form.php:178
     215msgid "select"
     216msgstr ""
     217
     218#: admin/views/settings-page.php:59
     219msgid ""
     220"Select default resort type (also can be set in the shortcode [airport-"
     221"transfers-form resort=\"summer/winter\"])"
     222msgstr ""
     223
     224#: admin/views/settings-page.php:74
     225msgid ""
     226"Select default time-format (also can be set in the shortcode [airport-"
     227"transfers-form time-format=\"24\"])"
     228msgstr ""
     229
     230#: public/views/form.php:217
     231msgid "Send"
     232msgstr ""
     233
     234#: admin/views/settings-page.php:41
     235msgid ""
     236"Set the country (also can be set in the shortcode [airport-transfers-form "
     237"country=\"Earthsea\"])"
     238msgstr ""
     239
     240#: admin/views/settings-page.php:5
     241msgid "Styling and functionality settings"
     242msgstr ""
     243
     244#: public/class-airport-transfers.php:59
     245msgid "System Error"
     246msgstr ""
     247
     248#: public/class-airport-transfers.php:206
     249msgid "System Error!"
     250msgstr ""
     251
     252#: public/class-airport-transfers.php:210
     253msgid "Thank you for your submission! We will answer as soon as possible!"
     254msgstr ""
     255
     256#: admin/views/settings-page.php:64
     257msgid "Time format"
     258msgstr ""
     259
     260#: public/class-airport-transfers.php:172 public/views/form.php:90
     261msgid "Time of arrival"
     262msgstr ""
     263
     264#: public/class-airport-transfers.php:183 public/views/form.php:148
     265msgid "Time of departure"
     266msgstr ""
     267
     268#: public/views/form.php:47 public/views/form.php:138
     269msgid "To airport"
     270msgstr ""
     271
     272#: public/class-airport-transfers.php:151 public/views/form.php:42
     273msgid "Transfer type"
     274msgstr ""
     275
     276#: public/views/form.php:45
     277msgid "Two way"
     278msgstr ""
     279
     280#: public/class-airport-transfers.php:55 public/class-airport-transfers.php:147
     281msgid "Your Name"
     282msgstr ""
     283
     284#: public/views/form.php:11
     285msgid "Your name"
     286msgstr ""
  • airport-transfers/tags/master/public/class-airport-transfers.php

    r1725009 r2842501  
    11<?php defined( 'ABSPATH' ) or die( 'I can\'t do anything alone! Sorry!' );
    22
    3 if( !class_exists('NS_Airport_Transfers') ) {
    4  
    5   class NS_Airport_Transfers {
    6  
    7     private static $initiated = false;
    8    
    9     private static $class       = 'NS_Airport_Transfers';
    10     public static  $textdomain  = 'ns-airport-transfers';
    11     public static  $prefix      = 'ns_';
    12    
    13     public static function init() {
    14       if ( !self::$initiated ) {
    15               self::init_hooks();
    16       }
     3if( ! class_exists( 'NS_Airport_Transfers' ) ) {
     4
     5    class NS_Airport_Transfers {
     6
     7        private static $initiated = false;
     8
     9        /**
     10         * Init.
     11         */
     12        public static function init() {
     13            if( ! self::$initiated ) {
     14                self::init_hooks();
     15            }
     16        }
     17
     18
     19        /**
     20         * Register hooks.
     21         */
     22        private static function init_hooks() {
     23            // Enqueue scripts.
     24            add_action( 'wp_enqueue_scripts', array( '\NS_Airport_Transfers', 'enqueue_scripts' ) );
     25
     26            // Register ajax functions for the fronend.
     27            add_action( 'wp_ajax_send', array( '\NS_Airport_Transfers', 'send' ) );
     28            add_action( 'wp_ajax_nopriv_send', array( '\NS_Airport_Transfers', 'send' ) );
     29
     30            // Shortcodes.
     31            add_shortcode('airport-transfers-form', array( '\NS_Airport_Transfers', 'form' ) );
     32
     33            self::$initiated = true;
     34        }
     35
     36
     37        /**
     38         * Enqueue scripts.
     39         */
     40        public static function enqueue_scripts() {
     41            // Load css.
     42            wp_enqueue_style( 'bootstrap', NS_AIRPORT_TRANSFERS_URL . 'assets/bootstrap/css/bootstrap.min.css', array(), '3.3.7' );
     43            wp_enqueue_style( 'jquery-ui', NS_AIRPORT_TRANSFERS_URL . 'assets/jquery-ui/jquery-ui.min.css', array(), '1.12.1' );
     44            wp_enqueue_style( 'ns-airport-transfers',  NS_AIRPORT_TRANSFERS_URL . 'assets/css/styles.css', array( 'bootstrap', 'jquery-ui' ), NS_AIRPORT_TRANSFERS_VERSION );
     45
     46            // Load scripts.
     47            wp_enqueue_script( 'bootstrap', NS_AIRPORT_TRANSFERS_URL . 'assets/bootstrap/js/bootstrap.min.js', array( 'jquery', 'jquery-ui-datepicker' ), '3.3.7', true );
     48            wp_enqueue_script( 'ns-airport-transfers', NS_AIRPORT_TRANSFERS_URL . 'assets/js/index.js', array( 'bootstrap' ), NS_AIRPORT_TRANSFERS_VERSION, true );
     49            wp_localize_script(
     50                'ns-airport-transfers',
     51                'nsAirportTransfers',
     52                array(
     53                    'adminUrl' => admin_url( 'admin-ajax.php' ),
     54                    'texts' => array(
     55                        'yourName' => esc_html__( 'Your Name', 'ns-airport-transfers' ),
     56                        'emailAddress' => esc_html__( 'Email Address', 'ns-airport-transfers' ),
     57                        'mobile' => esc_html__( 'Mobile', 'ns-airport-transfers' ),
     58                        'MandatoryField' => esc_html__( 'Mandatory Field', 'ns-airport-transfers' ),
     59                        'SystemError' => esc_html__( 'System Error', 'ns-airport-transfers' ),
     60                    )
     61                )
     62            );
     63        }
     64
     65
     66        /**
     67         * Main function to display and process the form.
     68         *
     69         * Option provided are:
     70         *      resort - if summer [no. of ski] field is skipped,
     71         *      country - concatenated with [Addres in] label, default is [add country option please]
     72         *      time-format - if 12 we use the 12 Hour format, default is 24
     73         *
     74         * @param array $atts    Array of options.
     75         * @param sring $content Content provides comma separeted airports for the dropdown, default is one option [add Airports in content please].
     76         *
     77         * @return string
     78         */
     79        public static function form( $atts, $content = '' ) {
     80
     81          $params = shortcode_atts( array(
     82            'resort' => get_option( 'ns-airport-transfers-resort' ),
     83            'time-format' => get_option( 'ns-airport-transfers-time-format' ),
     84            'show-contacts' => '1'
     85          ), $atts );
     86
     87          // Adjust dropdowns depending on Time format (12 or 24 Hours).
     88          if( strtolower( $params['time-format']) === '12' ) :
     89            for($i=1; $i<=12; $i++) :
     90              $hours[] = strval($i);
     91            endfor;
     92            $am_pm = '<option>AM/PM</option>
     93                    <option value="AM">AM</option>
     94                    <option value="PM">PM</option>';
     95          else :
     96            for($i=0; $i<=23; $i++) :
     97              $hours[] = ($i<10) ? '0' . strval($i) : strval($i);
     98            endfor;
     99            $am_pm = FALSE;
     100          endif;
     101
     102          // Adjust minutes dropdown.
     103          for($i=0; $i<=55; $i++) :
     104            if($i%5===0) :
     105              $minutes[] = ($i<10) ? '0' . strval($i) : strval($i);
     106            endif;
     107          endfor;
     108
     109          // Process the content from the shortcode.
     110          $options = explode(",", $content);
     111          $options = (sizeof($options)>0) ? $options : array();
     112
     113          array_map( 'trim', $options );
     114
     115          ob_start();
     116
     117          require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/views/form.php' );
     118          require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/views/modal-error.php' );
     119
     120          return ob_get_clean();
     121        }
     122
     123
     124        /**
     125         * Ajax form handler.
     126         */
     127        public static function send() {
     128          try {
     129            // Check post at all.
     130            if( empty( $_POST ) ) {
     131                throw new \Exception( esc_html__( 'Incorrect data!', 'ns-airport-transfers' ) );
     132            }
     133
     134            // Check email.
     135            $email = filter_var( sanitize_email( $_POST['email'] ), FILTER_VALIDATE_EMAIL );
     136            if ( ! $email ) {
     137              throw new \Exception(esc_html__( 'Invalid email address!', 'ns-airport-transfers' ) );
     138            }
     139
     140            // Subject.
     141            $subject  = esc_html__( 'Request', 'ns-airport-transfers' );
     142
     143            // Message.
     144            $message = '';
     145
     146            // Information.
     147            $message .= esc_html__( 'Your Name', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['name'] ) ) . PHP_EOL;
     148            $message .= esc_html__( 'Email Address', 'ns-airport-transfers' ).": " . $email . PHP_EOL;
     149            $message .= esc_html__( 'Mobile', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field($_POST['phone'] ) ) . PHP_EOL;
     150            $message .= esc_html__( 'I would like to', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['like_to'] ) . PHP_EOL;
     151            $message .= esc_html__( 'Transfer type', 'ns-airport-transfers' ).": " . sanitize_text_field( $_POST['transfer_type'] ) . PHP_EOL;
     152            $message .= esc_html__( 'No. of adults', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['adults'] ) ) . PHP_EOL;
     153            $message .= esc_html__( 'No. of children', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['children'] ) ) . PHP_EOL;
     154            $message .= esc_html__( 'No. of koffers', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['koffers'] ) ) . PHP_EOL;
     155            if(sanitize_text_field( $_POST['resort'])==='winter' ) {
     156              $message .= esc_html__( 'No. of ski/snowboards', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field($_POST['ski'] ) ) . PHP_EOL;
     157            }
     158
     159            $message .= PHP_EOL;
     160
     161            // transfer_type
     162            $transfer_type = sanitize_text_field( $_POST['transfer_type'] );
     163
     164            // time format
     165            $time_format = sanitize_text_field( $_POST['time_format']);
     166
     167            // arrival
     168            $post_arrival_us_time = sanitize_text_field( $_POST['arrival_us_time']);
     169            $arrival_us_time = ($time_format==='12'&&$post_arrival_us_time!=='') ? $post_arrival_us_time : '';
     170            if($transfer_type==='two_way' || $transfer_type==='from_airport') {
     171              $message .= esc_html__( 'Date of arrival', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['arrival_date'] ) ) . PHP_EOL;
     172              $message .= esc_html__( 'Time of arrival', 'ns-airport-transfers' ).": " . sanitize_text_field(  $_POST['arrival_hour'] ) . ':' . sanitize_text_field(  $_POST['arrival_minutes']).$arrival_us_time . PHP_EOL;
     173              $message .= esc_html__( 'Airport', 'ns-airport-transfers' ).": ".sanitize_text_field(  $_POST['arrival_airport'] ) . PHP_EOL;
     174              $message .= esc_html__( 'Flight number', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field(  $_POST['arrival_flight'] ) ) . PHP_EOL;
     175              $message .= PHP_EOL;
     176            }
     177
     178            // departure
     179            $post_out_us_time = sanitize_text_field(  $_POST['out_us_time'] );
     180            $out_us_time = ($time_format==='12'&&$post_out_us_time!=='') ? $post_out_us_time : '';
     181            if($transfer_type==='two_way' || $transfer_type==='to_airport') {
     182              $message .= esc_html__( 'Date of departure', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['out_date'])) . PHP_EOL;
     183              $message .= esc_html__( 'Time of departure', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['out_hour']).':'.sanitize_text_field( $_POST['out_minutes']).$out_us_time . PHP_EOL;
     184              $message .= esc_html__( 'Airport', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['out_airport']) . PHP_EOL;
     185              $message .= esc_html__( 'Flight number', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['out_flight'])) . PHP_EOL;
     186              $message .= PHP_EOL;
     187            }
     188
     189            // address in destination country
     190            $message .= esc_html__( 'Address in', 'ns-airport-transfers' ).' '.esc_html__( get_option( 'ns-airport-transfers-country' ), 'ns-airport-transfers' ) . PHP_EOL;
     191            $message .= esc_html__( 'Address of hotel/accommodation', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['adress'])) . PHP_EOL;
     192
     193            // instructions
     194            $message .= esc_html__( 'Remarks/instructions', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['instructions'])) . PHP_EOL;
     195
     196            // Headers
     197            $headers  = 'MIME-Version: 1.0' . PHP_EOL;
     198            $headers .= 'Content-type: text/plain; charset=utf-8' . PHP_EOL;
     199            $headers .= 'Content-Transfer-Encoding: 7bit' . PHP_EOL;
     200            $headers .= 'Message-ID: <' . time() . '-'. md5($email).'>' . PHP_EOL;
     201            $headers .= 'From: '.get_option('blogname').' <'.get_option('admin_email').'>' . PHP_EOL;
     202            $headers .= 'Return-Path: <'.get_option('admin_email').'>' . PHP_EOL;
     203
     204            // get administrative emails for the form
     205            if( ! wp_mail( get_option('ns-airport-transfers-admin-email'), $subject, $message, $headers ) ) {
     206              throw new \Exception(esc_html__( 'System Error!', 'ns-airport-transfers' ));
     207            }
     208
     209            $result['status'] = 'success';
     210            $result['data'] = esc_html__( 'Thank you for your submission! We will answer as soon as possible!', 'ns-airport-transfers' );
     211
     212          } catch (Exception $e) {
     213            $result['status'] = 'error';
     214            $result['data'] = $e->getMessage();
     215
     216            $error_message  = 'Sending mail failed!'.PHP_EOL . PHP_EOL;
     217            $error_message .= 'Form message:'.PHP_EOL . PHP_EOL;
     218            $error_message .= print_r($e->getMessage(),TRUE) . PHP_EOL;
     219
     220            wp_mail( get_option('admin_email'), 'Airport Transfers Error', $error_message, $headers );
     221          } finally {
     222            echo json_encode($result);
     223          }
     224          wp_die();
     225        }
     226
    17227    }
    18    
    19     /**
    20     * Initializes WordPress hooks
    21     */
    22     private static function init_hooks() {
    23       // add javascript for the form
    24       add_action('wp_footer', array(self::$class, self::$prefix.'form_js'));
    25       // form shortcode     
    26       add_shortcode('airport-transfers-form', array(self::$class, self::$prefix.'form'));
    27       self::$initiated = true;
    28     }
    29    
    30    
    31     public static function ns_form_js() { ?>
    32 <script type="text/javascript">
    33  
    34 jQuery(document).ready(function($) {
    35  
    36     var prefix = '#ns-airport-transfer-form ';
    37    
    38     // load datepicker
    39     if((prefix+".date").length > 0 ){
    40       $(prefix+".date" ).datepicker();
    41     }
    42    
    43     $(prefix+'#transfer_type').on('change', function(){
    44       let val= $(prefix+'#transfer_type option:selected').val();
    45       if(val==='from_airport') {
    46         $(prefix+"#arrival").css('display','block');
    47         $(prefix+"#departure").css('display','none');
    48       } else if(val==='to_airport') {
    49         $(prefix+"#arrival").css('display','none');
    50         $(prefix+"#departure").css('display','block');
    51       } else {
    52         $(prefix+"#arrival").css('display','block');
    53         $(prefix+"#departure").css('display','block');
    54       }
    55     });
    56    
    57 
    58     $(prefix+'#submit').on('click', function(){
    59      
    60       if(!ns_form_validate(prefix+'#name','<?=airport_transfers_lang_e('Your Name')?>')) {
    61         return;
    62       }
    63      
    64       if(!ns_form_validate(prefix+'#email','<?=airport_transfers_lang_e('Email Address')?>')) {
    65         return;
    66       }
    67      
    68       if(!ns_form_validate(prefix+'#phone','<?=airport_transfers_lang_e('Mobile')?>')) {
    69         return;
    70       }
    71      
    72       $('body').last('div').after('<div id="loading" class="loading"></div>');
    73      
    74       $.post( '<?=admin_url('admin-ajax.php?action=send')?>', {
    75        
    76         // form data
    77         lang: '<?php echo function_exists('pll_current_language')?pll_current_language('locale'):get_locale(); ?>',       
    78         resort: $(prefix+"#resort").val(),       
    79         time_format: $(prefix+"#time_format").val(),       
    80        
    81         // personal data
    82         name: $(prefix+"#name").val(),
    83         email: $(prefix+"#email").val(),
    84         phone: $(prefix+"#phone").val(),
    85         like_to: $(prefix+'input[name=like_to]:checked').val(),
    86         transfer_type: $(prefix+"#transfer_type option:selected").val(),
    87         adults: $(prefix+"#adults").val(),
    88         children: $(prefix+"#children").val(),
    89         koffers: $(prefix+"#koffers").val(),
    90         ski: ($(prefix+"#ski").length>0) ? $("#ski").val() : '',
    91        
    92         // arrival data
    93         arrival_date: $(prefix+"#arrival_date").val(),
    94         arrival_hour: $(prefix+"#arrival_hour option:selected").val(),
    95         arrival_minutes: $(prefix+"#arrival_minutes option:selected").val(),
    96         arrival_us_time: ($(prefix+"#arrival_us_time").length>0) ? $("#arrival_us_time option:selected").val() : '',
    97         arrival_airport: $(prefix+"#arrival_airport option:selected").val(),
    98         arrival_flight: $(prefix+"#arrival_flight").val(),
    99        
    100         // departure data
    101         out_date: $(prefix+"#out_date").val(),
    102         out_hour: $(prefix+"#out_hour option:selected").val(),
    103         out_minutes: $(prefix+"#out_minutes option:selected").val(),
    104         out_us_time: ($(prefix+"#out_us_time").length>0) ? $("#out_us_time option:selected").val() : '',
    105         out_airport: $(prefix+"#out_airport option:selected").val(),
    106         out_flight: $(prefix+"#out_flight").val(),
    107        
    108         // address and instructions
    109         adress: $(prefix+"#adress").val(),
    110         instructions: $(prefix+"#instructions").val()
    111       }).done(function(data) {
    112         let response = $.parseJSON(data);
    113         if(response.status==='error') {
    114           $('#modal-error-message').text(response.data);
    115           $('#modal-error').modal();
    116           return;
    117         }
    118        
    119         $('html, body').animate({
    120           scrollTop: $(".main-container").offset().top
    121         }, 500);
    122                
    123         setTimeout(function(){
    124             $("#ns-airport-transfer-form").empty();
    125             $("#ns-airport-transfer-form").html('<h3 class="text-success">'+response.data+'</h3>');
    126         },500);
    127       }).fail(function() {
    128         $('#modal-error-message').text('<?=airport_transfers_lang_e('System Error!')?>');
    129         $('#modal-error').modal();
    130       })
    131       .always(function() {
    132         $("#loading").remove();
    133       });
    134     });
    135    
    136     function ns_form_validate(el,message) {
    137       if($(el).val()==='') {
    138         $('html, body').animate({
    139           scrollTop: $(".main-container").offset().top
    140         }, 500);
    141         $('#modal-error-message').text('<?=airport_transfers_lang_e('Please input')?> '+message);
    142         $('#modal-error').modal();
    143         return false;
    144       }
    145       return true;
    146     }
    147 
    148   });
    149 
    150 </script>
    151     <?php }
    152        
    153     /**
    154     * Main function to display and process the form
    155     *
    156     * option provided are:
    157     * resort - if summer [no. of ski] field is skipped,
    158     * country - concatenated with [Addres in] label, default is [add country option please]
    159     * time-format - if 12 we use the 12 Hour format, default is 24
    160     *
    161     * content provides comma separeted airports for the dropdown, default is one option [add Airports in content please]
    162     */
    163     public static function ns_form($atts, $content = '') {
    164      
    165       $params = shortcode_atts( array(
    166         'resort' => get_option('ns-airport-transfers-resort'),
    167         'time-format' => get_option('ns-airport-transfers-time-format'),
    168         'show-contacts' => 'true'
    169       ), $atts);
    170      
    171       // adjust dropdowns depending on Time format (12 or 24 Hours)
    172       if(strtolower($params['time-format'])==='12') :
    173         for($i=1; $i<=12; $i++) :
    174           $hours[] = strval($i);
    175         endfor;
    176         $am_pm = '<option>AM/PM</option>
    177                 <option value="AM">AM</option>
    178                 <option value="PM">PM</option>';
    179       else :
    180         for($i=0; $i<=23; $i++) :
    181           $hours[] = ($i<10) ? '0' . strval($i) : strval($i);
    182         endfor;
    183         $am_pm = FALSE;
    184       endif;
    185      
    186       // adjust minutes dropdown
    187       for($i=0; $i<=55; $i++) :
    188         if($i%5===0) :
    189           $minutes[] = ($i<10) ? '0' . strval($i) : strval($i);
    190         endif;
    191       endfor;
    192      
    193       // process the content from the shortcode
    194       $options = explode(",", $content);     
    195       $options = (sizeof($options)>0) ? $options : array();
    196      
    197       ob_start();
    198       require_once( plugin_dir_path(__FILE__) . 'views/form.php' );
    199       require_once( plugin_dir_path(__FILE__) . 'views/modal-error.php' );
    200       return ob_get_clean();
    201     }
    202    
    203   } // class ends here
    204228}
    205 
  • airport-transfers/tags/master/public/views/form.php

    r1725009 r2842501  
    22
    33<form id="ns-airport-transfer-form" action="<?=get_permalink()?>" class="form-horizontal" method="post" accept-charset="utf-8">
    4 <noscript><?=airport_transfers_lang_e('Javascript must be enabled!');?></noscript><br><br>
     4<noscript><?php esc_html_e( 'Javascript must be enabled!', 'ns-airport-transfers' ); ?></noscript><br><br>
    55<input type="hidden" id="resort" value="<?=$params['resort']?>">
    66<input type="hidden" id="time_format" value="<?=$params['time-format']?>">
    77
    8   <h4 class="text-success"><?=airport_transfers_lang_e('Information about you');?></h4>
    9 
    10   <div class="form-group">
    11     <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Your name');?><span class="text-danger">*</span></label>
     8  <h4 class="text-success"><?php esc_html_e( 'Information about you', 'ns-airport-transfers' ); ?></h4>
     9
     10  <div class="form-group">
     11    <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Your name', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    1212      <div class="col-sm-8 col-xs-12">
    1313        <input type="text" id="name" class="form-control" value="" placeholder="">
     
    1616  <div class="clear"><br></div>
    1717  <div class="form-group">
    18       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Email address');?><span class="text-danger">*</span></label>
     18      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Email address', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    1919      <div class="col-sm-8 col-xs-12">
    2020        <input type="text" id="email" class="form-control" value="" placeholder="">
    21         <span class="explanation">(<?=airport_transfers_lang_e('On this Email you will recieve confirmation');?>)</span>
    22       </div>         
    23   </div>
    24   <div class="clear"></div>
    25   <div class="form-group">
    26       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Mobile');?><span class="text-danger">*</span></label>
     21        <span class="explanation">(<?php esc_html_e( 'On this Email you will recieve confirmation', 'ns-airport-transfers' ); ?>)</span>
     22      </div>
     23  </div>
     24  <div class="clear"></div>
     25  <div class="form-group">
     26      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Mobile', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    2727      <div class="col-sm-8 col-xs-12">
    2828        <input type="text" id="phone" class="form-control" value="" placeholder="">
    29         <span class="explanation">(<?=airport_transfers_lang_e('It\'s mandatory to input your phone number');?>)</span>
    30       </div>         
    31   </div>
    32   <div class="clear"></div>
    33   <div class="form-group">
    34       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('I would like to');?>:<span class="text-danger">*</span></label>
    35       <div class="col-sm-8 col-xs-12">
    36         <input type="radio" name="like_to" value="<?=airport_transfers_lang_e('Make reservation');?>" checked> <?=airport_transfers_lang_e('Make reservation');?><br>
    37         <input type="radio" name="like_to" value="<?=airport_transfers_lang_e('Request more information');?>"> <?=airport_transfers_lang_e('Request more information');?>
    38       </div> 
     29        <span class="explanation">(<?php esc_html_e( 'It\'s mandatory to input your phone number', 'ns-airport-transfers' ); ?>)</span>
     30      </div>
     31  </div>
     32  <div class="clear"></div>
     33  <div class="form-group">
     34      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'I would like to', 'ns-airport-transfers' ); ?>:<span class="text-danger">*</span></label>
     35      <div class="col-sm-8 col-xs-12">
     36        <input type="radio" name="like_to" value="<?php esc_html_e( 'Make reservation', 'ns-airport-transfers' ); ?>" checked> <?php esc_html_e( 'Make reservation', 'ns-airport-transfers' ); ?><br>
     37        <input type="radio" name="like_to" value="<?php esc_html_e( 'Request more information', 'ns-airport-transfers' ); ?>"> <?php esc_html_e( 'Request more information', 'ns-airport-transfers' ); ?>
     38      </div>
    3939  </div><hr>
    4040  <div class="clear"></div>
    4141  <div class="form-group">
    42       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Transfer type');?><span class="text-danger">*</span></label>
     42      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Transfer type', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    4343      <div class="col-sm-8 col-xs-12">
    4444        <select id="transfer_type" class="form-control">
    45           <option value="two_way"><?=airport_transfers_lang_e('Two way');?></option>
    46           <option value="from_airport"><?=airport_transfers_lang_e('One way');?> (<?=airport_transfers_lang_e('From airport');?>)</option>
    47           <option value="to_airport"><?=airport_transfers_lang_e('One way');?> (<?=airport_transfers_lang_e('To airport');?>)</option>
     45          <option value="two_way"><?php esc_html_e( 'Two way', 'ns-airport-transfers' ); ?></option>
     46          <option value="from_airport"><?php esc_html_e( 'One way', 'ns-airport-transfers' ); ?> (<?php esc_html_e( 'From airport', 'ns-airport-transfers' ); ?>)</option>
     47          <option value="to_airport"><?php esc_html_e( 'One way', 'ns-airport-transfers' ); ?> (<?php esc_html_e( 'To airport', 'ns-airport-transfers' ); ?>)</option>
    4848        </select>
    4949      </div>
     
    5151  <div class="clear"></div><br>
    5252  <div class="form-group">
    53       <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of adults');?><span class="text-danger">*</span></label>
     53      <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of adults', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    5454      <div class="col-md-2 col-sm-2 col-xs-4">
    5555        <input type="text" id="adults" class="form-control" value="" placeholder="">
    56       </div> 
    57      
    58       <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of children');?><span class="text-danger">*</span></label>
     56      </div>
     57
     58      <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of children', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    5959      <div class="col-md-2 col-sm-2 col-xs-4">
    6060        <input type="text" id="children" class="form-control" value="" placeholder="">
     
    6262  </div>
    6363  <div class="clear"></div><br>
    64   <div class="form-group"> 
    65       <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of koffers');?><span class="text-danger">*</span></label>
     64  <div class="form-group">
     65      <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of koffers', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    6666      <div class="col-md-2 col-sm-2 col-xs-4">
    6767        <input type="text" id="koffers" class="form-control" value="" placeholder="">
    68       </div> 
    69      
     68      </div>
     69
    7070      <?php if(strtolower($params['resort'])==='winter') : ?>
    71       <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of ski/snowboards');?><span class="text-danger">*</span></label>
     71      <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of ski/snowboards', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    7272      <div class="col-md-2 col-sm-2 col-xs-4">
    7373        <input type="text" id="ski" class="form-control" value="" placeholder="">
    74       </div>         
     74      </div>
    7575      <?php endif; ?>
    7676  </div>
    7777  <div class="clear"></div><hr>
    78  
     78
    7979  <div id="arrival">
    80     <h4><span class="text-success"><?=airport_transfers_lang_e('After arrival');?></span> <span class="small">(<?=airport_transfers_lang_e('From airport');?>)</span></h4>
    81 
    82     <div class="form-group">
    83         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Date of arrival');?><span class="text-danger">*</span></label>
     80    <h4><span class="text-success"><?php esc_html_e( 'After arrival', 'ns-airport-transfers' ); ?></span> <span class="small">(<?php esc_html_e( 'From airport', 'ns-airport-transfers' ); ?>)</span></h4>
     81
     82    <div class="form-group">
     83        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Date of arrival', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    8484        <div class="col-sm-3 col-xs-4">
    8585          <input type="text" id="arrival_date" value="" class="date form-control" placeholder="">
     
    8888    <div class="clear"></div><br>
    8989    <div class="form-group">
    90         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Time of arrival');?><span class="text-danger">*</span></label>
     90        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Time of arrival', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    9191        <div class="col-sm-3 col-xs-4">
    9292          <select id="arrival_hour" class="form-control">
    93             <option value="-"><?=airport_transfers_lang_e('Hour')?></option>
     93            <option value="-"><?php esc_html_e( 'Hour', 'ns-airport-transfers' ); ?></option>
    9494            <?php foreach ($hours as $hour) : ?>
    9595            <option value="<?=$hour?>"><?=$hour?></option>
     
    9999        <div class="col-sm-3 col-xs-4">
    100100          <select id="arrival_minutes" class="form-control">
    101             <option value="-"><?=airport_transfers_lang_e('Min')?></option>
     101            <option value="-"><?php esc_html_e( 'Min', 'ns-airport-transfers' ); ?></option>
    102102            <?php foreach ($minutes as $minute) : ?>
    103103            <option value="<?=$minute?>"><?=$minute?></option>
     
    115115    <div class="clear"></div><br>
    116116    <div class="form-group">
    117         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Airport')?><span class="text-danger">*</span></label>
    118         <div class="col-sm-6 col-xs-12">
    119           <select id="arrival_airport" class="form-control">         
    120             <option value="-"><?=airport_transfers_lang_e('select')?></option>
     117        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Airport', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
     118        <div class="col-sm-6 col-xs-12">
     119          <select id="arrival_airport" class="form-control">
     120            <option value="-"><?php esc_html_e( 'select', 'ns-airport-transfers' ); ?></option>
    121121            <?php foreach ($options as $option) : ?>
    122122            <option value="<?=$option?>"><?=$option?></option>
     
    127127    <div class="clear"></div><br>
    128128    <div class="form-group">
    129         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Flight number')?><span class="text-danger">*</span></label>
     129        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Flight number', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    130130        <div class="col-sm-6 col-xs-12">
    131131          <input type="text" class="form-control" id="arrival_flight" value="" placeholder="">
     
    134134    <div class="clear"></div><br>
    135135  </div>
    136  
     136
    137137  <div id="departure">
    138     <h4><span class="text-success"><?=airport_transfers_lang_e('Leaving')?></span> <span class="small">(<?=airport_transfers_lang_e('To airport');?>)</span></h4>
    139 
    140     <div class="form-group">
    141         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Date of departure')?><span class="text-danger">*</span></label>
     138    <h4><span class="text-success"><?php esc_html_e( 'Leaving', 'ns-airport-transfers' ); ?></span> <span class="small">(<?php esc_html_e( 'To airport', 'ns-airport-transfers' ); ?>)</span></h4>
     139
     140    <div class="form-group">
     141        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Date of departure', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    142142        <div class="col-sm-3 col-xs-4">
    143143          <input type="text" id="out_date" value="" class="date form-control" placeholder="">
     
    146146    <div class="clear"></div><br>
    147147    <div class="form-group">
    148         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Time of departure');?><span class="text-danger">*</span></label>
     148        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Time of departure', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    149149        <div class="col-sm-3 col-xs-4">
    150150          <select id="out_hour" class="form-control">
    151             <option value="-"><?=airport_transfers_lang_e('Hour')?></option>
     151            <option value="-"><?php esc_html_e( 'Hour', 'ns-airport-transfers' ); ?></option>
    152152            <?php foreach ($hours as $hour) : ?>
    153153            <option value="<?=$hour?>"><?=$hour?></option>
     
    157157        <div class="col-sm-3 col-xs-4">
    158158          <select id="out_minutes" class="form-control">
    159             <option value="-"><?=airport_transfers_lang_e('Min')?></option>
     159            <option value="-"><?php esc_html_e( 'Min', 'ns-airport-transfers' ); ?></option>
    160160            <?php foreach ($minutes as $minute) : ?>
    161161            <option value="<?=$minute?>"><?=$minute?></option>
     
    173173    <div class="clear"></div><br>
    174174    <div class="form-group">
    175         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Airport')?><span class="text-danger">*</span></label>
    176         <div class="col-sm-6 col-xs-12">
    177           <select id="out_airport" class="form-control">         
    178             <option value="-"><?=airport_transfers_lang_e('select')?></option>
     175        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Airport', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
     176        <div class="col-sm-6 col-xs-12">
     177          <select id="out_airport" class="form-control">
     178            <option value="-"><?php esc_html_e( 'select', 'ns-airport-transfers' ); ?></option>
    179179            <?php foreach ($options as $option) : ?>
    180180            <option value="<?=$option?>"><?=$option?></option>
     
    185185    <div class="clear"></div><br>
    186186    <div class="form-group">
    187         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Flight number')?><span class="text-danger">*</span></label>
     187        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Flight number', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    188188        <div class="col-sm-6 col-xs-12">
    189189          <input type="text" id="out_flight" class="form-control" value="" placeholder="">
     
    192192    <div class="clear"></div><br>
    193193  </div>
    194  
     194
    195195  <div class="clear"></div><hr>
    196196
    197   <h4 class="text-success"><?=airport_transfers_lang_e('Address in')?> <?=airport_transfers_lang_e(get_option('ns-airport-transfers-country'))?></h4>
    198  
    199   <div class="clear"></div>
    200  
    201   <div class="form-group">
    202     <label class="col-md-4 col-sm-12 col-xs-12"><?=airport_transfers_lang_e('Address of hotel/accommodation')?>: <span class="text-danger">*</span></label>
     197  <h4 class="text-success"><?php esc_html_e( 'Address in', 'ns-airport-transfers' ); ?> <?php esc_html_e( get_option('ns-airport-transfers-country'))?></h4>
     198
     199  <div class="clear"></div>
     200
     201  <div class="form-group">
     202    <label class="col-md-4 col-sm-12 col-xs-12"><?php esc_html_e( 'Address of hotel/accommodation', 'ns-airport-transfers' ); ?>: <span class="text-danger">*</span></label>
    203203    <div class="col-md-8 col-sm-12 col-xs-12">
    204204      <textarea id="adress" class="form-control" rows="2" placeholder=""></textarea>
    205     </div>     
    206   </div>
    207  
     205    </div>
     206  </div>
     207
    208208  <div class="clear"></div><br>
    209  
    210   <div class="form-group">
    211     <label class="col-md-4 col-sm-12 col-xs-12"><?=airport_transfers_lang_e('Remarks/instructions')?>:</label>
     209
     210  <div class="form-group">
     211    <label class="col-md-4 col-sm-12 col-xs-12"><?php esc_html_e( 'Remarks/instructions', 'ns-airport-transfers' ); ?>:</label>
    212212    <div class="col-md-8 col-sm-12 col-xs-12">
    213213      <textarea id="instructions" class="form-control" rows="2" placeholder=""></textarea>
     
    215215  </div>
    216216  <br><br>
    217   <div id="submit" class="btn btn-default"><?=airport_transfers_lang_e('Send')?></div>
    218  
     217  <div id="submit" class="btn btn-default"><?php esc_html_e( 'Send', 'ns-airport-transfers' ); ?></div>
     218
    219219</form>
    220220
    221 <?php if($params['show-contacts']==='true') : ?>
     221<?php if($params['show-contacts']==='1') : ?>
    222222<div class="clear"></div><br>
    223 <i><?php printf(airport_transfers_lang('If you need transfer from airport to another destination, wich is not specified please call us at %s or send an e-mail to %s'), get_option('ns-airport-transfers-contact-phone'), get_option('ns-airport-transfers-contact-email'))?></i>
     223<i><?php
     224    printf(
     225        esc_html__( 'If you need transfer from airport to another destination, wich is not specified please call us at %s or send an e-mail to %s' ),
     226        get_option( 'ns-airport-transfers-contact-phone' ),
     227        get_option( 'ns-airport-transfers-contact-email' )
     228    ); ?></i>
    224229<?php endif; ?>
  • airport-transfers/tags/master/public/views/modal-error.php

    r1725009 r2842501  
    55    <div class="modal-content">
    66      <div class="modal-header">
    7         <button type="button" class="close" data-dismiss="modal" aria-label="<?=airport_transfers_lang_e('close'); ?>"><span aria-hidden="true">&times;</span></button>
    8         <h4 class="modal-title" id="modal-error-title"><?=airport_transfers_lang_e('Error'); ?></h4>
     7        <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'ns-airport-transfers' ); ?>"><span aria-hidden="true">&times;</span></button>
     8        <h4 class="modal-title" id="modal-error-title"><?php esc_html_e( 'Error', 'ns-airport-transfers' ); ?></h4>
    99      </div>
    1010      <div class="modal-body">
    1111        <div class="box box-danger">
    12           <div class="box-body"> 
     12          <div class="box-body">
    1313            <div class="row">
    1414              <div class="col-xs-12">
     
    2020      </div>
    2121      <div class="modal-footer">
    22         <button type="button" id="cancel" class="btn btn-default" data-dismiss="modal"><?=airport_transfers_lang_e('close'); ?></button>
     22        <button type="button" id="cancel" class="btn btn-default" data-dismiss="modal"><?php esc_html_e( 'Close', 'ns-airport-transfers' ); ?></button>
    2323      </div>
    2424    </div>
  • airport-transfers/trunk/README.md

    r1959832 r2842501  
    1 === Airport Transfers ===
    2 Contributors: atanasantonov
    3 Receive orders for transfer with this simple plugin. Easy to install and configure for your needs. Unlimited airports. Polylang compatible and fully translatable!
    4 Tags: transfer, airport, arrival, departure
    5 Requires at least: 3.0.1
    6 Tested up to: 5.0
    7 Requires PHP: 5.6
    8 Stable tag: trunk
    9 License: GPLv2
    10 License URI: http://www.gnu.org/licenses/gpl-2.0.html
    11  
     1#  Airport Transfers
     2
    123Special airport transfers form that delivers mail to an administrator with customer's data.
    13  
    14 == Description ==
    15  
    16 Receive orders for transfer with this simple plugin. Easy to install and configure for your needs. Form is designed to serve as transfer order tool.
    174
    18 The plugin has full localisation and internationalisation support. Polylang compatible!
    19  
     5Form is designed to serve as transfer order tool. Design is airport transfers ready.
     6
     7The plugin has full l10n and i18n support.
     8
    209There are several options like mails for the delivery and default settings.
    21  
    22 == Installation ==
     10
     11= Features =
     12* Simple & Intuitive
     13* Flexible transfer reservation form
     14* Multiple emails can be used for notifications
     15
     16## Installation
    2317
    2418Download and activate the plugin. The plugin works with shortcode:
     
    3327
    3428After the settings are done and the shortcode is placed on the desired pages you are ready to operate.
    35  
    36 == Frequently Asked Questions ==
    3729
    38 = Can I customize where the emails will be delivered? =
    39  
     30## Screenshots
     31
     32![This screen shows the settings page](.wordpress-org/screenshot-1.jpg?raw=true "Settings page")
     33
     34![This screen shows the form in the page on the frontend](.wordpress-org/screenshot-2.jpg?raw=true "Form on the frontend")
     35
     36## Frequently Asked Questions
     37
     38### Can I customize where the emails will be delivered?
     39
    4040Yes, you can add as many emails for delivery as you want. The only rule is that they must be comma separated.
    4141
    42 = Can I place a custom contact information? =
    43  
     42### Can I place a custom contact information?
     43
    4444Yes, you can place your phone/phones and email.
    4545
    46 = Can I customize the destination country? =
    47  
     46### Can I customize the destination country?
     47
    4848Yes, you can set any country you want. It can be a default one and as option in every page where the shorcode is placed.
    4949
    50 = Can I switch between 12 and 24 hour format? =
    51  
     50### Can I switch between 12 and 24 hour format?
     51
    5252Yes, you can choose default the format in the settings page and also as option in every page where the shorcode is placed..
    53  
    54 = Is there a limitation of airports number? =
    55  
     53
     54### Is there a limitation of airports number?
     55
    5656No, you can add as many airports in the dropdown as you wish.
    57  
    58 = What about the number of request? =
    59  
     57
     58### What about the number of request?
     59
    6060There is no limitation. You can recieve as many orders as they are submitted.
    6161
    62 = Is there a mandatory fields verification? =
    63  
     62### Is there a mandatory fields verification?
     63
    6464Yes, the most important fields are validated twice - both on client's machine and on the server. Especially the email address.
    6565
    66 = How can the customer understand that is missing something? =
    67  
     66### How can the customer understand that is missing something?
     67
    6868There is a nice gentle modal window that is opened when mandatory field is empty.
    6969
    70 == Screenshots ==
    71  
    72 1. This screen shows the settings page.
     70## Changelog
    7371
    74 2. This is the second screens shows the form in the page on frontend.
     72### 1.1
     73* Security fixes.
    7574
    76 == Donations ==
    77 
    78 If you like the plugin and it helps you to offer better services at your clients you can buy me a fruit!
    79 
    80 (BTC) 1ATAnAsK2wwDGK6UKrUewJDWtZ6kgJXEYu
    81 (LTC) LdoQwdNn2FQAap8QBYDP8H4TetGmhhx3vj
    82 (ZEC) t1VXcnmXZPaEfXtkshmhBtWEHy1CHqETh1V
    83  
    84 == Changelog ==
    85  
    86 = 1.0 =
     75### 1.0
    8776* First release.
    8877* No changes.
    89  
    90 == Upgrade Notice ==
    91  
    92 = 1.0 =
    93 
    94 No upgrades needed at this time.
  • airport-transfers/trunk/admin/class-airport-transfers-admin.php

    r1725009 r2842501  
    44
    55class NS_Airport_Transfers_Admin {
    6    
    7   private static  $initiated   = FALSE;
    8   private static  $class       = 'NS_Airport_Transfers_Admin';
    9   public static   $prefix      = 'ns_admin_';
    10   public static   $textdomain  = 'ns-airport-transfers';
    11   public static   $settings    = 'ns-airport-transfers-group';
    126
    13   public static function init() {       
    14     if(!self::$initiated) {
    15       self::ns_admin_init_hooks();
    16     }
    17   }
     7    private static  $initiated   = FALSE;
     8    public static   $settings    = 'ns-airport-transfers-group';
    189
    19   /**
    20   * Initializes WordPress hooks
    21   */
    22   private static function ns_admin_init_hooks() {
    23     add_action( 'admin_init', array( self::$class, self::$prefix.'init' ) );
    24     add_action( 'admin_init', array( self::$class, self::$prefix.'texts' ) );
    25     add_action( 'admin_menu', array( self::$class, self::$prefix.'menu' ) );   
    26     add_action( 'admin_init', array( self::$class, self::$prefix.'register_settings' ) );
    27    
    28     self::$initiated = TRUE;
    29   }
     10    /**
     11     * Init.
     12     */
     13    public static function init() {
     14        if( ! self::$initiated ) {
     15            self::init_hooks();
     16        }
     17    }
    3018
    31   public static function ns_admin_init() {
    3219
    33   }
    34  
    35   public static function ns_admin_menu() {
    36     add_menu_page('Airport Transfers', 'Airport Transfers', 'edit_posts', self::$textdomain.'-settings', array( self::$class, self::$prefix.'settings_page' ),'dashicons-admin-generic');
    37   }
    38  
    39   public static function ns_admin_register_settings() {
    40     register_setting( self::$settings, 'ns-airport-transfers-admin-email' );
    41     register_setting( self::$settings, 'ns-airport-transfers-contact-email' );
    42     register_setting( self::$settings, 'ns-airport-transfers-contact-phone' );
    43     register_setting( self::$settings, 'ns-airport-transfers-country' );
    44     register_setting( self::$settings, 'ns-airport-transfers-resort' );
    45     register_setting( self::$settings, 'ns-airport-transfers-time-format' );
    46   }
    47  
    48   public static function ns_admin_settings_page() {
    49     require_once( plugin_dir_path(__FILE__) . 'views/settings-page.php' );
    50   }
     20    /**
     21     * Register hooks.
     22     */
     23    private static function init_hooks() {
     24        add_action( 'admin_init', array( '\NS_Airport_Transfers_Admin', 'init' ) );
     25        add_action( 'admin_menu', array( '\NS_Airport_Transfers_Admin', 'admin_menu' ) );
     26        add_action( 'admin_init', array( '\NS_Airport_Transfers_Admin', 'register_settings' ) );
    5127
    52   public static function ns_admin_texts() {
     28        self::$initiated = TRUE;
     29    }
    5330
    54     // prepare the texts
    55     global $texts;
    5631
    57     foreach ($texts as $text)
    58     {
    59       __($text,self::$textdomain);
    60       if(function_exists('pll_register_string'))
    61       {
    62         pll_register_string(__('Form elements',self::$textdomain), $text, 'Airport Transfers');   
    63       } 
    64     }
    65   }
    66  
    67   // ajax form handler
    68   public static function ns_admin_send() {   
    69     try {
    70       // check post at all
    71       if(empty($_POST)) {
    72         throw new Exception(airport_transfers_lang('Incorrect data!'));
    73       }
    74      
    75       $post = $_POST;
     32    /**
     33     * Admin menu.
     34     */
     35    public static function admin_menu() {
     36        add_submenu_page(
     37            'options-general.php',
     38            'Airport Transfers',
     39            'Airport Transfers',
     40            'edit_posts',
     41            'ns-airport-transfers-settings',
     42            array( '\NS_Airport_Transfers_Admin', 'settings_page' ),
     43            100
     44        );
     45    }
    7646
    77      
    78       $lang = sanitize_text_field($post['lang']);
    79      
    80       // check email
    81       $email = filter_var(sanitize_email($post['email']), FILTER_VALIDATE_EMAIL);
    82       if (!$email) {
    83         throw new Exception(airport_transfers_lang('Invalid email address!'));
    84       }
    85      
    86       // Subject
    87       $subject  = airport_transfers_lang('Request');
    8847
    89       // Message     
    90       $message = '';
    91      
    92       // information
    93       $message .= airport_transfers_lang('Your Name', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['name'])).PHP_EOL;
    94       $message .= airport_transfers_lang('Email Address', $lang).": ".$email.PHP_EOL;
    95       $message .= airport_transfers_lang('Mobile', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['phone'])).PHP_EOL;
    96       $message .= airport_transfers_lang('I would like to', $lang).": ".sanitize_text_field($post['like_to']).PHP_EOL;
    97       $message .= airport_transfers_lang('Transfer type', $lang).": ".airport_transfers_lang(sanitize_text_field($post['transfer_type']), $lang).PHP_EOL;
    98       $message .= airport_transfers_lang('No. of adults', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['adults'])).PHP_EOL;
    99       $message .= airport_transfers_lang('No. of children', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['children'])).PHP_EOL;
    100       $message .= airport_transfers_lang('No. of koffers', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['koffers'])).PHP_EOL;
    101       if(sanitize_text_field($post['resort'])==='winter') {
    102         $message .= airport_transfers_lang('No. of ski/snowboards', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['ski'])).PHP_EOL;
    103       }
    104  
    105       $message .= PHP_EOL;
    106      
    107       // transfer_type
    108       $transfer_type = sanitize_text_field($post['transfer_type']);
    109      
    110       // time format
    111       $time_format = sanitize_text_field($post['time_format']);
    112      
    113       // arrival 
    114       $post_arrival_us_time = sanitize_text_field($post['arrival_us_time']);
    115       $arrival_us_time = ($time_format==='12'&&$post_arrival_us_time!=='') ? $post_arrival_us_time : '';
    116       if($transfer_type==='two_way' || $transfer_type==='from_airport') {
    117         $message .= airport_transfers_lang('Date of arrival', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['arrival_date'])).PHP_EOL;       
    118         $message .= airport_transfers_lang('Time of arrival', $lang).": ".sanitize_text_field($post['arrival_hour']).':'.sanitize_text_field($post['arrival_minutes']).$arrival_us_time.PHP_EOL;       
    119         $message .= airport_transfers_lang('Airport', $lang).": ".sanitize_text_field($post['arrival_airport']).PHP_EOL;
    120         $message .= airport_transfers_lang('Flight number', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['arrival_flight'])).PHP_EOL;
    121         $message .= PHP_EOL;
    122       }
    123      
    124       // departure
    125       $post_out_us_time = sanitize_text_field($post['out_us_time']);
    126       $out_us_time = ($time_format==='12'&&$post_out_us_time!=='') ? $post_out_us_time : '';
    127       if($transfer_type==='two_way' || $transfer_type==='to_airport') {
    128         $message .= airport_transfers_lang('Date of departure', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['out_date'])).PHP_EOL;       
    129         $message .= airport_transfers_lang('Time of departure', $lang).": ".sanitize_text_field($post['out_hour']).':'.sanitize_text_field($post['out_minutes']).$out_us_time.PHP_EOL;       
    130         $message .= airport_transfers_lang('Airport', $lang).": ".sanitize_text_field($post['out_airport']).PHP_EOL;
    131         $message .= airport_transfers_lang('Flight number', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['out_flight'])).PHP_EOL;
    132         $message .= PHP_EOL;
    133       }
    134      
    135       // address in destination country
    136       $message .= airport_transfers_lang('Address in', $lang).' '.airport_transfers_lang(get_option('ns-airport-transfers-country'), $lang).PHP_EOL;
    137       $message .= airport_transfers_lang('Address of hotel/accommodation', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['adress'])).PHP_EOL;
    138      
    139       // instructions
    140       $message .= airport_transfers_lang('Remarks/instructions', $lang).": ".airport_transfers_check_val(sanitize_text_field($post['instructions'])).PHP_EOL;
    141      
    142       // Headers
    143       $headers  = 'MIME-Version: 1.0' . PHP_EOL;
    144       $headers .= 'Content-type: text/plain; charset=utf-8' . PHP_EOL;
    145       $headers .= 'Content-Transfer-Encoding: 7bit' . PHP_EOL;
    146       $headers .= 'Message-ID: <' . time() . '-'. md5($email).'>' . PHP_EOL;
    147       $headers .= 'From: '.get_option('blogname').' <'.get_option('admin_email').'>' . PHP_EOL;           
    148       $headers .= 'Return-Path: <'.get_option('admin_email').'>' . PHP_EOL;
    149      
    150       // get administrative emails for the form
    151       if(!mail(get_option('ns-airport-transfers-admin-email'), $subject, $message, $headers)) {
    152         $error_message  = 'Sending mail failed!'.PHP_EOL.PHP_EOL;
    153         $error_message  = 'Form message:'.PHP_EOL.PHP_EOL;
    154         $error_message .= print_r($message,TRUE).PHP_EOL;         
    155         mail(get_option('admin_email'), 'Airport Transfers Plugin', $error_message, $headers);
    156         throw new Exception(airport_transfers_lang('System Error!', $lang));
    157       }
    158      
    159       $result['status'] = 'success';
    160       $result['data'] = airport_transfers_lang('Thank you for your submission! We will answer as soon as possible!', $lang);
    161      
    162     } catch (Exception $e) {
    163       $result['status'] = 'error';
    164       $result['data'] = $e->getMessage();
    165     } finally {
    166       echo json_encode($result);     
    167     }
    168     wp_die();
    169   }
     48    /**
     49     * Register settings.
     50     */
     51    public static function register_settings() {
     52        register_setting( self::$settings, 'ns-airport-transfers-admin-email' );
     53        register_setting( self::$settings, 'ns-airport-transfers-contact-email' );
     54        register_setting( self::$settings, 'ns-airport-transfers-contact-phone' );
     55        register_setting( self::$settings, 'ns-airport-transfers-country' );
     56        register_setting( self::$settings, 'ns-airport-transfers-resort' );
     57        register_setting( self::$settings, 'ns-airport-transfers-time-format' );
     58    }
     59
     60
     61    /**
     62     * Settings page.
     63     */
     64    public static function settings_page() {
     65        require_once( NS_AIRPORT_TRANSFERS_PATH . 'admin/views/settings-page.php' );
     66    }
    17067}
    17168
  • airport-transfers/trunk/admin/views/settings-page.php

    r1725009 r2842501  
    33<div class="wrap">
    44<h1>Airport Transfers</h1>
    5 <p class="description"><span class="dashicons dashicons-admin-settings"></span> <?php echo __('Styling and functionality settings',self::$textdomain); ?>.</p>
     5<p class="description"><span class="dashicons dashicons-admin-settings"></span> <?php esc_html_e('Styling and functionality settings','ns-airport-transfers'); ?>.</p>
    66
    77<form method="post" action="options.php">
    88  <?php settings_fields( self::$settings ); ?>
    99  <?php do_settings_sections( self::$settings ); ?>
    10  
    11   <table class="form-table"> 
    12    
     10
     11  <table class="form-table">
     12
    1313    <tr>
    14       <th scope="row"><?php echo __('Admin email/emails',self::$textdomain); ?></th>
     14      <th scope="row"><?php esc_html_e('Admin email/emails','ns-airport-transfers'); ?></th>
    1515      <td>
    1616        <input type="text" name="ns-airport-transfers-admin-email" value="<?php echo esc_attr( get_option('ns-airport-transfers-admin-email') ); ?>" class="large-text" />
    17         <p class="description"><?php echo __('Email/emails for delivery. Comma separated if more than one (admin1@example.com, admin2@example.com, ...)',self::$textdomain); ?></p>
     17        <p class="description"><?php esc_html_e('Email/emails for delivery. Comma separated if more than one (admin1@example.com, admin2@example.com, ...)','ns-airport-transfers'); ?></p>
    1818      <br><hr></td>
    1919    </tr>
    20    
     20
    2121    <tr>
    22       <th scope="row"><?php echo __('Contact email',self::$textdomain); ?></th>
     22      <th scope="row"><?php esc_html_e('Contact email','ns-airport-transfers'); ?></th>
    2323      <td>
    2424        <input type="text" name="ns-airport-transfers-contact-email" value="<?php echo esc_attr( get_option('ns-airport-transfers-contact-email') ); ?>" class="large-text" />
    25         <p class="description"><?php echo __('Contact email.',self::$textdomain); ?></p>
     25        <p class="description"><?php esc_html_e('Contact email.','ns-airport-transfers'); ?></p>
    2626      <br><hr></td>
    2727    </tr>
    28    
     28
    2929    <tr>
    30       <th scope="row"><?php echo __('Contact phone/phones',self::$textdomain); ?></th>
     30      <th scope="row"><?php esc_html_e('Contact phone/phones','ns-airport-transfers'); ?></th>
    3131      <td>
    3232        <input type="text" name="ns-airport-transfers-contact-phone" value="<?php echo esc_attr( get_option('ns-airport-transfers-contact-phone') ); ?>" class="large-text" />
    33         <p class="description"><?php echo __('Contact phone/phones.',self::$textdomain); ?></p>
     33        <p class="description"><?php esc_html_e('Contact phone/phones.','ns-airport-transfers'); ?></p>
    3434      <br><hr></td>
    3535    </tr>
    36        
     36
    3737    <tr>
    38       <th scope="row"><?php echo __('Default destination country',self::$textdomain); ?></th>
     38      <th scope="row"><?php esc_html_e('Default destination country','ns-airport-transfers'); ?></th>
    3939      <td>
    4040        <input type="text" name="ns-airport-transfers-country" value="<?php echo esc_attr( get_option('ns-airport-transfers-country') ); ?>" />
    41         <p class="description"><?php echo __('Set the country (also can be set in the shortcode [airport-transfers-form country="Earthsea"])',self::$textdomain); ?></p> 
     41        <p class="description"><?php esc_html_e('Set the country (also can be set in the shortcode [airport-transfers-form country="Earthsea"])','ns-airport-transfers'); ?></p>
    4242      </td>
    4343    </tr>
    44    
     44
    4545    <tr>
    46       <th scope="row"><?php echo __('Resort type',self::$textdomain); ?></th>
     46      <th scope="row"><?php esc_html_e('Resort type','ns-airport-transfers'); ?></th>
    4747      <td>
    4848        <select name="ns-airport-transfers-resort">
     
    5454        <?php foreach ($options as $value => $name) : ?>
    5555          <?php $selected = ($format===$value) ? ' selected="selected"' : ''; ?>
    56           <option value="<?php echo $value; ?>"<?php echo $selected; ?>><?php echo __($name,self::$textdomain); ?></option>
     56          <option value="<?php echo $value; ?>"<?php echo $selected; ?>><?php esc_html_e($name,'ns-airport-transfers'); ?></option>
    5757        <?php endforeach; ?>
    5858        </select>
    59         <p class="description"><?php echo __('Select default resort type (also can be set in the shortcode [airport-transfers-form resort="summer/winter"])',self::$textdomain); ?></p> 
     59        <p class="description"><?php esc_html_e('Select default resort type (also can be set in the shortcode [airport-transfers-form resort="summer/winter"])','ns-airport-transfers'); ?></p>
    6060      </td>
    6161    </tr>
    62    
     62
    6363    <tr>
    64       <th scope="row"><?php echo __('Time format',self::$textdomain); ?></th>
     64      <th scope="row"><?php esc_html_e('Time format','ns-airport-transfers'); ?></th>
    6565      <td>
    6666        <select name="ns-airport-transfers-time-format">
     
    6969        <?php foreach ($options as $option) : ?>
    7070          <?php $selected = ($format===$option) ? ' selected="selected"' : ''; ?>
    71           <option value="<?php echo $option; ?>"<?php echo $selected; ?>><?php echo $option; ?> <?php echo __('Hours',self::$textdomain); ?></option>
     71          <option value="<?php echo $option; ?>"<?php echo $selected; ?>><?php echo $option; ?> <?php esc_html_e('Hours','ns-airport-transfers'); ?></option>
    7272        <?php endforeach; ?>
    7373        </select>
    74         <p class="description"><?php echo __('Select default time-format (also can be set in the shortcode [airport-transfers-form time-format="24"])',self::$textdomain); ?></p> 
     74        <p class="description"><?php esc_html_e('Select default time-format (also can be set in the shortcode [airport-transfers-form time-format="24"])','ns-airport-transfers'); ?></p>
    7575      </td>
    7676    </tr>
  • airport-transfers/trunk/airport-transfers.php

    r1725009 r2842501  
    1 <?php 
     1<?php
    22/*
    33Plugin Name: Airport Transfers
    4 Plugin URI:  https://github.com/atanasantonov/wordpress-plugins/tree/master/airport-transfers
     4Plugin URI:  https://github.com/atanasantonov/airport-transfers
    55Description: Plugin delivers multilingual form for airport transfers
    6 Version:     1.0
     6Version: master
    77Author:      Atanas Antonov
    8 Author URI:  http://nantstudio.eu/
     8Author URI:  https://unax.org
    99License:     GPL2
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111Text Domain: ns-airport-transfers
    12 Domain Path: /languages
     12Domain Path: /languages/
    1313*/
    1414
    1515defined( 'ABSPATH' ) or die( 'I can\'t do anything alone! Sorry!' );
    16  
     16
     17define( 'NS_AIRPORT_TRANSFERS_VERSION', 'master' );
     18define( 'NS_AIRPORT_TRANSFERS_PATH', plugin_dir_path( __FILE__ ) );
     19define( 'NS_AIRPORT_TRANSFERS_URL', plugins_url( '/', __FILE__ ) );
     20
     21load_plugin_textdomain('ns-airport-transfers', false, basename( dirname( __FILE__ ) ) . '/languages' );
     22
     23require_once( NS_AIRPORT_TRANSFERS_PATH . 'functions.php' );
     24require_once( NS_AIRPORT_TRANSFERS_PATH . 'admin/class-airport-transfers-admin.php' );
     25require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/class-airport-transfers.php' );
     26
    1727register_activation_hook( __FILE__, 'ns_airport_transfers_activate' );
    1828register_deactivation_hook( __FILE__, 'ns_airport_transfers_uninstall' );
    1929
    20 // add the options defaults
    21 function ns_airport_transfers_activate() {
    22   add_option( 'ns-airport-transfers-admin-email', get_option('admin_email')); // Admin email delivery and contact address
    23   add_option( 'ns-airport-transfers-contact-email', '' ); // Contant email
    24   add_option( 'ns-airport-transfers-contact-phone', '' ); // Contant phone
    25   add_option( 'ns-airport-transfers-country', 'Earthsea' ); // Can be set in plugin's settings page or trough the shortcode
    26   add_option( 'ns-airport-transfers-resort', 'summer' );  // Include ski field or not. Can be set in plugin's settings page or trough the shortcode
    27   add_option( 'ns-airport-transfers-time-format', '24' );  // 12 or 24 Hours time format. Can be set in plugin's settings page or trough the shortcode
     30if ( is_admin() ) {
     31    \NS_Airport_Transfers_Admin::init();
     32    add_action( 'init', array( '\NS_Airport_Transfers_Admin', 'init' ) );
    2833}
    2934
    30 // delete the unnecessary options from the database
    31 function ns_airport_transfers_uninstall() {
    32   delete_option('ns-airport-transfers-admin-email');
    33   delete_option('ns-airport-transfers-contact-email');
    34   delete_option('ns-airport-transfers-contact-phone');
    35   delete_option('ns-airport-transfers-country');
    36   delete_option('ns-airport-transfers-resort');
    37   delete_option('ns-airport-transfers-time-format');
    38 }
    39 
    40 load_plugin_textdomain('ns-airport-transfers', false, basename( dirname( __FILE__ ) ) . '/languages' );
    41 require_once( plugin_dir_path(__FILE__) . 'texts.php' );
    42 
    43 /**
    44  * airport_transfers_lang
    45  *
    46  * returns translation of the string
    47  * @param string $string - string to be translated
    48  * @param string $lang - desired language
    49  * Function check if Polylang plugin's 'pll_translate_string' function
    50  * is available. If so the plugin's function will be used. Otherwise Wordpress translation system will be used.
    51 */
    52 function airport_transfers_lang($string='',$lang=null) {
    53   if(function_exists('pll_translate_string')) {
    54     $string = isset($lang) ? pll_translate_string($string, $lang) : pll__($string);
    55   } else {
    56     $string = __($string, 'ns-airport-transfers');
    57   }
    58   return $string;
    59 }
    60 
    61 /**
    62  * airport_transfers_lang_e
    63  *
    64  * returns translation of the string with echo
    65  * @param string $string - string to be translated
    66  * @param string $lang - desired language
    67  * same as airport_transfers_lang but with echo
    68 */
    69 function airport_transfers_lang_e($string='',$lang=null) {
    70   if(function_exists('pll_translate_string')) {
    71     $string = isset($lang) ? pll_translate_string($string, $lang) : pll__($string);
    72   } else {
    73     $string = __($string, 'ns-airport-transfers');
    74   }
    75   echo $string;
    76   return;
    77 }
    78 
    79 /**
    80  * airport_transfers_check_val
    81  *
    82  * returns '-' if param is empty string
    83  * @param string $string
    84 */
    85 function airport_transfers_check_val($string='') {
    86   $string = ($string!='') ? $string : '-';
    87   return $string;
    88 }
    89 
    90 if (is_admin()) { 
    91   require_once( plugin_dir_path(__FILE__) . 'admin/class-airport-transfers-admin.php' );
    92   add_action( 'init', array( 'NS_Airport_Transfers_Admin', 'init' ) );
    93  
    94   // register ajax functions for the fronend
    95   add_action( 'wp_ajax_send', array( 'NS_Airport_Transfers_Admin', 'ns_admin_send' ));
    96   add_action( 'wp_ajax_nopriv_send', array( 'NS_Airport_Transfers_Admin', 'ns_admin_send' ));
    97 }
    98 else
    99 {
    100   function ns_enqueue_scripts() {
    101     // load css
    102     wp_enqueue_style( 'bootstrap', plugins_url('assets/bootstrap/css/bootstrap.min.css', __FILE__));
    103     wp_enqueue_style( 'jquery-ui', plugins_url('assets/jquery-ui/jquery-ui.min.css', __FILE__));
    104     wp_enqueue_style( 'ns-airport-transfers', plugins_url('assets/css/styles.css', __FILE__));
    105 
    106     // load scripts
    107     wp_enqueue_script('jquery');
    108     wp_enqueue_script('jquery-ui-datepicker');       
    109     wp_enqueue_script('bootstrap', plugins_url('assets/bootstrap/js/bootstrap.min.js',  __FILE__ ),array('jquery'));
    110   }
    111   add_action( 'wp_enqueue_scripts','ns_enqueue_scripts');
    112  
    113   require_once( plugin_dir_path(__FILE__) . 'public/class-airport-transfers.php' );   
    114   add_action( 'init', array( 'NS_Airport_Transfers', 'init' ) );
    115 }
     35\NS_Airport_Transfers::init();
  • airport-transfers/trunk/languages/ns-airport-transfers.pot

    r1725009 r2842501  
    22msgid ""
    33msgstr ""
    4 "Project-Id-Version: PACKAGE VERSION\n"
     4"Project-Id-Version: Airport Transfers\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2017-08-30 11:45+0000\n"
     6"POT-Creation-Date: 2023-01-02 17:48+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    99"Language-Team: \n"
    1010"Language: \n"
    11 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION\n"
     11"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
    1212"MIME-Version: 1.0\n"
    1313"Content-Type: text/plain; charset=UTF-8\n"
    1414"Content-Transfer-Encoding: 8bit\n"
    15 "X-Generator: Loco - https://localise.biz/"
     15"X-Generator: Loco https://localise.biz/\n"
     16"X-Loco-Version: 2.6.2; wp-6.0.3\n"
     17"X-Domain: ns-airport-transfers"
     18
     19#: public/class-airport-transfers.php:190 public/views/form.php:197
     20msgid "Address in"
     21msgstr ""
     22
     23#: public/class-airport-transfers.php:191 public/views/form.php:202
     24msgid "Address of hotel/accommodation"
     25msgstr ""
     26
     27#: admin/views/settings-page.php:14
     28msgid "Admin email/emails"
     29msgstr ""
     30
     31#: public/views/form.php:80
     32msgid "After arrival"
     33msgstr ""
     34
     35#: public/class-airport-transfers.php:173
     36#: public/class-airport-transfers.php:184 public/views/form.php:117
     37#: public/views/form.php:175
     38msgid "Airport"
     39msgstr ""
     40
     41#. Name of the plugin
     42msgid "Airport Transfers"
     43msgstr ""
     44
     45#. Author of the plugin
     46msgid "Atanas Antonov"
     47msgstr ""
     48
     49#: public/views/modal-error.php:7 public/views/modal-error.php:22
     50msgid "Close"
     51msgstr ""
     52
     53#: admin/views/settings-page.php:22
     54msgid "Contact email"
     55msgstr ""
     56
     57#: admin/views/settings-page.php:25
     58msgid "Contact email."
     59msgstr ""
     60
     61#: admin/views/settings-page.php:30
     62msgid "Contact phone/phones"
     63msgstr ""
     64
     65#: admin/views/settings-page.php:33
     66msgid "Contact phone/phones."
     67msgstr ""
     68
     69#: public/class-airport-transfers.php:171 public/views/form.php:83
     70msgid "Date of arrival"
     71msgstr ""
     72
     73#: public/class-airport-transfers.php:182 public/views/form.php:141
     74msgid "Date of departure"
     75msgstr ""
     76
     77#: admin/views/settings-page.php:38
     78msgid "Default destination country"
     79msgstr ""
     80
     81#: public/class-airport-transfers.php:56 public/class-airport-transfers.php:148
     82msgid "Email Address"
     83msgstr ""
     84
     85#: public/views/form.php:18
     86msgid "Email address"
     87msgstr ""
     88
     89#: admin/views/settings-page.php:17
     90msgid ""
     91"Email/emails for delivery. Comma separated if more than one (admin1@example."
     92"com, admin2@example.com, ...)"
     93msgstr ""
     94
     95#: public/views/modal-error.php:8
     96msgid "Error"
     97msgstr ""
     98
     99#: public/class-airport-transfers.php:174
     100#: public/class-airport-transfers.php:185 public/views/form.php:129
     101#: public/views/form.php:187
     102msgid "Flight number"
     103msgstr ""
     104
     105#: public/views/form.php:46 public/views/form.php:80
     106msgid "From airport"
     107msgstr ""
     108
     109#: public/views/form.php:93 public/views/form.php:151
     110msgid "Hour"
     111msgstr ""
     112
     113#: admin/views/settings-page.php:71
     114msgid "Hours"
     115msgstr ""
     116
     117#. URI of the plugin
     118msgid "https://github.com/atanasantonov/airport-transfers"
     119msgstr ""
     120
     121#. Author URI of the plugin
     122msgid "https://unax.org"
     123msgstr ""
     124
     125#: public/class-airport-transfers.php:150 public/views/form.php:34
     126msgid "I would like to"
     127msgstr ""
     128
     129#: public/class-airport-transfers.php:131
     130msgid "Incorrect data!"
     131msgstr ""
     132
     133#: public/views/form.php:8
     134msgid "Information about you"
     135msgstr ""
     136
     137#: public/class-airport-transfers.php:137
     138msgid "Invalid email address!"
     139msgstr ""
     140
     141#: public/views/form.php:29
     142msgid "It's mandatory to input your phone number"
     143msgstr ""
     144
     145#: public/views/form.php:4
     146msgid "Javascript must be enabled!"
     147msgstr ""
     148
     149#: public/views/form.php:138
     150msgid "Leaving"
     151msgstr ""
     152
     153#: public/views/form.php:36
     154msgid "Make reservation"
     155msgstr ""
     156
     157#: public/class-airport-transfers.php:58
     158msgid "Mandatory Field"
     159msgstr ""
     160
     161#: public/views/form.php:101 public/views/form.php:159
     162msgid "Min"
     163msgstr ""
     164
     165#: public/class-airport-transfers.php:57 public/class-airport-transfers.php:149
     166#: public/views/form.php:26
     167msgid "Mobile"
     168msgstr ""
     169
     170#: public/class-airport-transfers.php:152 public/views/form.php:53
     171msgid "No. of adults"
     172msgstr ""
     173
     174#: public/class-airport-transfers.php:153 public/views/form.php:58
     175msgid "No. of children"
     176msgstr ""
     177
     178#: public/class-airport-transfers.php:154 public/views/form.php:65
     179msgid "No. of koffers"
     180msgstr ""
     181
     182#: public/class-airport-transfers.php:156 public/views/form.php:71
     183msgid "No. of ski/snowboards"
     184msgstr ""
     185
     186#: public/views/form.php:21
     187msgid "On this Email you will recieve confirmation"
     188msgstr ""
     189
     190#: public/views/form.php:46 public/views/form.php:47
     191msgid "One way"
     192msgstr ""
     193
     194#. Description of the plugin
     195msgid "Plugin delivers multilingual form for airport transfers"
     196msgstr ""
     197
     198#: public/class-airport-transfers.php:194 public/views/form.php:211
     199msgid "Remarks/instructions"
     200msgstr ""
     201
     202#: public/class-airport-transfers.php:141
     203msgid "Request"
     204msgstr ""
     205
     206#: public/views/form.php:37
     207msgid "Request more information"
     208msgstr ""
     209
     210#: admin/views/settings-page.php:46
     211msgid "Resort type"
     212msgstr ""
     213
     214#: public/views/form.php:120 public/views/form.php:178
     215msgid "select"
     216msgstr ""
     217
     218#: admin/views/settings-page.php:59
     219msgid ""
     220"Select default resort type (also can be set in the shortcode [airport-"
     221"transfers-form resort=\"summer/winter\"])"
     222msgstr ""
     223
     224#: admin/views/settings-page.php:74
     225msgid ""
     226"Select default time-format (also can be set in the shortcode [airport-"
     227"transfers-form time-format=\"24\"])"
     228msgstr ""
     229
     230#: public/views/form.php:217
     231msgid "Send"
     232msgstr ""
     233
     234#: admin/views/settings-page.php:41
     235msgid ""
     236"Set the country (also can be set in the shortcode [airport-transfers-form "
     237"country=\"Earthsea\"])"
     238msgstr ""
     239
     240#: admin/views/settings-page.php:5
     241msgid "Styling and functionality settings"
     242msgstr ""
     243
     244#: public/class-airport-transfers.php:59
     245msgid "System Error"
     246msgstr ""
     247
     248#: public/class-airport-transfers.php:206
     249msgid "System Error!"
     250msgstr ""
     251
     252#: public/class-airport-transfers.php:210
     253msgid "Thank you for your submission! We will answer as soon as possible!"
     254msgstr ""
     255
     256#: admin/views/settings-page.php:64
     257msgid "Time format"
     258msgstr ""
     259
     260#: public/class-airport-transfers.php:172 public/views/form.php:90
     261msgid "Time of arrival"
     262msgstr ""
     263
     264#: public/class-airport-transfers.php:183 public/views/form.php:148
     265msgid "Time of departure"
     266msgstr ""
     267
     268#: public/views/form.php:47 public/views/form.php:138
     269msgid "To airport"
     270msgstr ""
     271
     272#: public/class-airport-transfers.php:151 public/views/form.php:42
     273msgid "Transfer type"
     274msgstr ""
     275
     276#: public/views/form.php:45
     277msgid "Two way"
     278msgstr ""
     279
     280#: public/class-airport-transfers.php:55 public/class-airport-transfers.php:147
     281msgid "Your Name"
     282msgstr ""
     283
     284#: public/views/form.php:11
     285msgid "Your name"
     286msgstr ""
  • airport-transfers/trunk/public/class-airport-transfers.php

    r1725009 r2842501  
    11<?php defined( 'ABSPATH' ) or die( 'I can\'t do anything alone! Sorry!' );
    22
    3 if( !class_exists('NS_Airport_Transfers') ) {
    4  
    5   class NS_Airport_Transfers {
    6  
    7     private static $initiated = false;
    8    
    9     private static $class       = 'NS_Airport_Transfers';
    10     public static  $textdomain  = 'ns-airport-transfers';
    11     public static  $prefix      = 'ns_';
    12    
    13     public static function init() {
    14       if ( !self::$initiated ) {
    15               self::init_hooks();
    16       }
     3if( ! class_exists( 'NS_Airport_Transfers' ) ) {
     4
     5    class NS_Airport_Transfers {
     6
     7        private static $initiated = false;
     8
     9        /**
     10         * Init.
     11         */
     12        public static function init() {
     13            if( ! self::$initiated ) {
     14                self::init_hooks();
     15            }
     16        }
     17
     18
     19        /**
     20         * Register hooks.
     21         */
     22        private static function init_hooks() {
     23            // Enqueue scripts.
     24            add_action( 'wp_enqueue_scripts', array( '\NS_Airport_Transfers', 'enqueue_scripts' ) );
     25
     26            // Register ajax functions for the fronend.
     27            add_action( 'wp_ajax_send', array( '\NS_Airport_Transfers', 'send' ) );
     28            add_action( 'wp_ajax_nopriv_send', array( '\NS_Airport_Transfers', 'send' ) );
     29
     30            // Shortcodes.
     31            add_shortcode('airport-transfers-form', array( '\NS_Airport_Transfers', 'form' ) );
     32
     33            self::$initiated = true;
     34        }
     35
     36
     37        /**
     38         * Enqueue scripts.
     39         */
     40        public static function enqueue_scripts() {
     41            // Load css.
     42            wp_enqueue_style( 'bootstrap', NS_AIRPORT_TRANSFERS_URL . 'assets/bootstrap/css/bootstrap.min.css', array(), '3.3.7' );
     43            wp_enqueue_style( 'jquery-ui', NS_AIRPORT_TRANSFERS_URL . 'assets/jquery-ui/jquery-ui.min.css', array(), '1.12.1' );
     44            wp_enqueue_style( 'ns-airport-transfers',  NS_AIRPORT_TRANSFERS_URL . 'assets/css/styles.css', array( 'bootstrap', 'jquery-ui' ), NS_AIRPORT_TRANSFERS_VERSION );
     45
     46            // Load scripts.
     47            wp_enqueue_script( 'bootstrap', NS_AIRPORT_TRANSFERS_URL . 'assets/bootstrap/js/bootstrap.min.js', array( 'jquery', 'jquery-ui-datepicker' ), '3.3.7', true );
     48            wp_enqueue_script( 'ns-airport-transfers', NS_AIRPORT_TRANSFERS_URL . 'assets/js/index.js', array( 'bootstrap' ), NS_AIRPORT_TRANSFERS_VERSION, true );
     49            wp_localize_script(
     50                'ns-airport-transfers',
     51                'nsAirportTransfers',
     52                array(
     53                    'adminUrl' => admin_url( 'admin-ajax.php' ),
     54                    'texts' => array(
     55                        'yourName' => esc_html__( 'Your Name', 'ns-airport-transfers' ),
     56                        'emailAddress' => esc_html__( 'Email Address', 'ns-airport-transfers' ),
     57                        'mobile' => esc_html__( 'Mobile', 'ns-airport-transfers' ),
     58                        'MandatoryField' => esc_html__( 'Mandatory Field', 'ns-airport-transfers' ),
     59                        'SystemError' => esc_html__( 'System Error', 'ns-airport-transfers' ),
     60                    )
     61                )
     62            );
     63        }
     64
     65
     66        /**
     67         * Main function to display and process the form.
     68         *
     69         * Option provided are:
     70         *      resort - if summer [no. of ski] field is skipped,
     71         *      country - concatenated with [Addres in] label, default is [add country option please]
     72         *      time-format - if 12 we use the 12 Hour format, default is 24
     73         *
     74         * @param array $atts    Array of options.
     75         * @param sring $content Content provides comma separeted airports for the dropdown, default is one option [add Airports in content please].
     76         *
     77         * @return string
     78         */
     79        public static function form( $atts, $content = '' ) {
     80
     81          $params = shortcode_atts( array(
     82            'resort' => get_option( 'ns-airport-transfers-resort' ),
     83            'time-format' => get_option( 'ns-airport-transfers-time-format' ),
     84            'show-contacts' => '1'
     85          ), $atts );
     86
     87          // Adjust dropdowns depending on Time format (12 or 24 Hours).
     88          if( strtolower( $params['time-format']) === '12' ) :
     89            for($i=1; $i<=12; $i++) :
     90              $hours[] = strval($i);
     91            endfor;
     92            $am_pm = '<option>AM/PM</option>
     93                    <option value="AM">AM</option>
     94                    <option value="PM">PM</option>';
     95          else :
     96            for($i=0; $i<=23; $i++) :
     97              $hours[] = ($i<10) ? '0' . strval($i) : strval($i);
     98            endfor;
     99            $am_pm = FALSE;
     100          endif;
     101
     102          // Adjust minutes dropdown.
     103          for($i=0; $i<=55; $i++) :
     104            if($i%5===0) :
     105              $minutes[] = ($i<10) ? '0' . strval($i) : strval($i);
     106            endif;
     107          endfor;
     108
     109          // Process the content from the shortcode.
     110          $options = explode(",", $content);
     111          $options = (sizeof($options)>0) ? $options : array();
     112
     113          array_map( 'trim', $options );
     114
     115          ob_start();
     116
     117          require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/views/form.php' );
     118          require_once( NS_AIRPORT_TRANSFERS_PATH . 'public/views/modal-error.php' );
     119
     120          return ob_get_clean();
     121        }
     122
     123
     124        /**
     125         * Ajax form handler.
     126         */
     127        public static function send() {
     128          try {
     129            // Check post at all.
     130            if( empty( $_POST ) ) {
     131                throw new \Exception( esc_html__( 'Incorrect data!', 'ns-airport-transfers' ) );
     132            }
     133
     134            // Check email.
     135            $email = filter_var( sanitize_email( $_POST['email'] ), FILTER_VALIDATE_EMAIL );
     136            if ( ! $email ) {
     137              throw new \Exception(esc_html__( 'Invalid email address!', 'ns-airport-transfers' ) );
     138            }
     139
     140            // Subject.
     141            $subject  = esc_html__( 'Request', 'ns-airport-transfers' );
     142
     143            // Message.
     144            $message = '';
     145
     146            // Information.
     147            $message .= esc_html__( 'Your Name', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['name'] ) ) . PHP_EOL;
     148            $message .= esc_html__( 'Email Address', 'ns-airport-transfers' ).": " . $email . PHP_EOL;
     149            $message .= esc_html__( 'Mobile', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field($_POST['phone'] ) ) . PHP_EOL;
     150            $message .= esc_html__( 'I would like to', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['like_to'] ) . PHP_EOL;
     151            $message .= esc_html__( 'Transfer type', 'ns-airport-transfers' ).": " . sanitize_text_field( $_POST['transfer_type'] ) . PHP_EOL;
     152            $message .= esc_html__( 'No. of adults', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['adults'] ) ) . PHP_EOL;
     153            $message .= esc_html__( 'No. of children', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['children'] ) ) . PHP_EOL;
     154            $message .= esc_html__( 'No. of koffers', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['koffers'] ) ) . PHP_EOL;
     155            if(sanitize_text_field( $_POST['resort'])==='winter' ) {
     156              $message .= esc_html__( 'No. of ski/snowboards', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field($_POST['ski'] ) ) . PHP_EOL;
     157            }
     158
     159            $message .= PHP_EOL;
     160
     161            // transfer_type
     162            $transfer_type = sanitize_text_field( $_POST['transfer_type'] );
     163
     164            // time format
     165            $time_format = sanitize_text_field( $_POST['time_format']);
     166
     167            // arrival
     168            $post_arrival_us_time = sanitize_text_field( $_POST['arrival_us_time']);
     169            $arrival_us_time = ($time_format==='12'&&$post_arrival_us_time!=='') ? $post_arrival_us_time : '';
     170            if($transfer_type==='two_way' || $transfer_type==='from_airport') {
     171              $message .= esc_html__( 'Date of arrival', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['arrival_date'] ) ) . PHP_EOL;
     172              $message .= esc_html__( 'Time of arrival', 'ns-airport-transfers' ).": " . sanitize_text_field(  $_POST['arrival_hour'] ) . ':' . sanitize_text_field(  $_POST['arrival_minutes']).$arrival_us_time . PHP_EOL;
     173              $message .= esc_html__( 'Airport', 'ns-airport-transfers' ).": ".sanitize_text_field(  $_POST['arrival_airport'] ) . PHP_EOL;
     174              $message .= esc_html__( 'Flight number', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field(  $_POST['arrival_flight'] ) ) . PHP_EOL;
     175              $message .= PHP_EOL;
     176            }
     177
     178            // departure
     179            $post_out_us_time = sanitize_text_field(  $_POST['out_us_time'] );
     180            $out_us_time = ($time_format==='12'&&$post_out_us_time!=='') ? $post_out_us_time : '';
     181            if($transfer_type==='two_way' || $transfer_type==='to_airport') {
     182              $message .= esc_html__( 'Date of departure', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['out_date'])) . PHP_EOL;
     183              $message .= esc_html__( 'Time of departure', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['out_hour']).':'.sanitize_text_field( $_POST['out_minutes']).$out_us_time . PHP_EOL;
     184              $message .= esc_html__( 'Airport', 'ns-airport-transfers' ).": ".sanitize_text_field( $_POST['out_airport']) . PHP_EOL;
     185              $message .= esc_html__( 'Flight number', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['out_flight'])) . PHP_EOL;
     186              $message .= PHP_EOL;
     187            }
     188
     189            // address in destination country
     190            $message .= esc_html__( 'Address in', 'ns-airport-transfers' ).' '.esc_html__( get_option( 'ns-airport-transfers-country' ), 'ns-airport-transfers' ) . PHP_EOL;
     191            $message .= esc_html__( 'Address of hotel/accommodation', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['adress'])) . PHP_EOL;
     192
     193            // instructions
     194            $message .= esc_html__( 'Remarks/instructions', 'ns-airport-transfers' ).": " . airport_transfers_check_val( sanitize_text_field( $_POST['instructions'])) . PHP_EOL;
     195
     196            // Headers
     197            $headers  = 'MIME-Version: 1.0' . PHP_EOL;
     198            $headers .= 'Content-type: text/plain; charset=utf-8' . PHP_EOL;
     199            $headers .= 'Content-Transfer-Encoding: 7bit' . PHP_EOL;
     200            $headers .= 'Message-ID: <' . time() . '-'. md5($email).'>' . PHP_EOL;
     201            $headers .= 'From: '.get_option('blogname').' <'.get_option('admin_email').'>' . PHP_EOL;
     202            $headers .= 'Return-Path: <'.get_option('admin_email').'>' . PHP_EOL;
     203
     204            // get administrative emails for the form
     205            if( ! wp_mail( get_option('ns-airport-transfers-admin-email'), $subject, $message, $headers ) ) {
     206              throw new \Exception(esc_html__( 'System Error!', 'ns-airport-transfers' ));
     207            }
     208
     209            $result['status'] = 'success';
     210            $result['data'] = esc_html__( 'Thank you for your submission! We will answer as soon as possible!', 'ns-airport-transfers' );
     211
     212          } catch (Exception $e) {
     213            $result['status'] = 'error';
     214            $result['data'] = $e->getMessage();
     215
     216            $error_message  = 'Sending mail failed!'.PHP_EOL . PHP_EOL;
     217            $error_message .= 'Form message:'.PHP_EOL . PHP_EOL;
     218            $error_message .= print_r($e->getMessage(),TRUE) . PHP_EOL;
     219
     220            wp_mail( get_option('admin_email'), 'Airport Transfers Error', $error_message, $headers );
     221          } finally {
     222            echo json_encode($result);
     223          }
     224          wp_die();
     225        }
     226
    17227    }
    18    
    19     /**
    20     * Initializes WordPress hooks
    21     */
    22     private static function init_hooks() {
    23       // add javascript for the form
    24       add_action('wp_footer', array(self::$class, self::$prefix.'form_js'));
    25       // form shortcode     
    26       add_shortcode('airport-transfers-form', array(self::$class, self::$prefix.'form'));
    27       self::$initiated = true;
    28     }
    29    
    30    
    31     public static function ns_form_js() { ?>
    32 <script type="text/javascript">
    33  
    34 jQuery(document).ready(function($) {
    35  
    36     var prefix = '#ns-airport-transfer-form ';
    37    
    38     // load datepicker
    39     if((prefix+".date").length > 0 ){
    40       $(prefix+".date" ).datepicker();
    41     }
    42    
    43     $(prefix+'#transfer_type').on('change', function(){
    44       let val= $(prefix+'#transfer_type option:selected').val();
    45       if(val==='from_airport') {
    46         $(prefix+"#arrival").css('display','block');
    47         $(prefix+"#departure").css('display','none');
    48       } else if(val==='to_airport') {
    49         $(prefix+"#arrival").css('display','none');
    50         $(prefix+"#departure").css('display','block');
    51       } else {
    52         $(prefix+"#arrival").css('display','block');
    53         $(prefix+"#departure").css('display','block');
    54       }
    55     });
    56    
    57 
    58     $(prefix+'#submit').on('click', function(){
    59      
    60       if(!ns_form_validate(prefix+'#name','<?=airport_transfers_lang_e('Your Name')?>')) {
    61         return;
    62       }
    63      
    64       if(!ns_form_validate(prefix+'#email','<?=airport_transfers_lang_e('Email Address')?>')) {
    65         return;
    66       }
    67      
    68       if(!ns_form_validate(prefix+'#phone','<?=airport_transfers_lang_e('Mobile')?>')) {
    69         return;
    70       }
    71      
    72       $('body').last('div').after('<div id="loading" class="loading"></div>');
    73      
    74       $.post( '<?=admin_url('admin-ajax.php?action=send')?>', {
    75        
    76         // form data
    77         lang: '<?php echo function_exists('pll_current_language')?pll_current_language('locale'):get_locale(); ?>',       
    78         resort: $(prefix+"#resort").val(),       
    79         time_format: $(prefix+"#time_format").val(),       
    80        
    81         // personal data
    82         name: $(prefix+"#name").val(),
    83         email: $(prefix+"#email").val(),
    84         phone: $(prefix+"#phone").val(),
    85         like_to: $(prefix+'input[name=like_to]:checked').val(),
    86         transfer_type: $(prefix+"#transfer_type option:selected").val(),
    87         adults: $(prefix+"#adults").val(),
    88         children: $(prefix+"#children").val(),
    89         koffers: $(prefix+"#koffers").val(),
    90         ski: ($(prefix+"#ski").length>0) ? $("#ski").val() : '',
    91        
    92         // arrival data
    93         arrival_date: $(prefix+"#arrival_date").val(),
    94         arrival_hour: $(prefix+"#arrival_hour option:selected").val(),
    95         arrival_minutes: $(prefix+"#arrival_minutes option:selected").val(),
    96         arrival_us_time: ($(prefix+"#arrival_us_time").length>0) ? $("#arrival_us_time option:selected").val() : '',
    97         arrival_airport: $(prefix+"#arrival_airport option:selected").val(),
    98         arrival_flight: $(prefix+"#arrival_flight").val(),
    99        
    100         // departure data
    101         out_date: $(prefix+"#out_date").val(),
    102         out_hour: $(prefix+"#out_hour option:selected").val(),
    103         out_minutes: $(prefix+"#out_minutes option:selected").val(),
    104         out_us_time: ($(prefix+"#out_us_time").length>0) ? $("#out_us_time option:selected").val() : '',
    105         out_airport: $(prefix+"#out_airport option:selected").val(),
    106         out_flight: $(prefix+"#out_flight").val(),
    107        
    108         // address and instructions
    109         adress: $(prefix+"#adress").val(),
    110         instructions: $(prefix+"#instructions").val()
    111       }).done(function(data) {
    112         let response = $.parseJSON(data);
    113         if(response.status==='error') {
    114           $('#modal-error-message').text(response.data);
    115           $('#modal-error').modal();
    116           return;
    117         }
    118        
    119         $('html, body').animate({
    120           scrollTop: $(".main-container").offset().top
    121         }, 500);
    122                
    123         setTimeout(function(){
    124             $("#ns-airport-transfer-form").empty();
    125             $("#ns-airport-transfer-form").html('<h3 class="text-success">'+response.data+'</h3>');
    126         },500);
    127       }).fail(function() {
    128         $('#modal-error-message').text('<?=airport_transfers_lang_e('System Error!')?>');
    129         $('#modal-error').modal();
    130       })
    131       .always(function() {
    132         $("#loading").remove();
    133       });
    134     });
    135    
    136     function ns_form_validate(el,message) {
    137       if($(el).val()==='') {
    138         $('html, body').animate({
    139           scrollTop: $(".main-container").offset().top
    140         }, 500);
    141         $('#modal-error-message').text('<?=airport_transfers_lang_e('Please input')?> '+message);
    142         $('#modal-error').modal();
    143         return false;
    144       }
    145       return true;
    146     }
    147 
    148   });
    149 
    150 </script>
    151     <?php }
    152        
    153     /**
    154     * Main function to display and process the form
    155     *
    156     * option provided are:
    157     * resort - if summer [no. of ski] field is skipped,
    158     * country - concatenated with [Addres in] label, default is [add country option please]
    159     * time-format - if 12 we use the 12 Hour format, default is 24
    160     *
    161     * content provides comma separeted airports for the dropdown, default is one option [add Airports in content please]
    162     */
    163     public static function ns_form($atts, $content = '') {
    164      
    165       $params = shortcode_atts( array(
    166         'resort' => get_option('ns-airport-transfers-resort'),
    167         'time-format' => get_option('ns-airport-transfers-time-format'),
    168         'show-contacts' => 'true'
    169       ), $atts);
    170      
    171       // adjust dropdowns depending on Time format (12 or 24 Hours)
    172       if(strtolower($params['time-format'])==='12') :
    173         for($i=1; $i<=12; $i++) :
    174           $hours[] = strval($i);
    175         endfor;
    176         $am_pm = '<option>AM/PM</option>
    177                 <option value="AM">AM</option>
    178                 <option value="PM">PM</option>';
    179       else :
    180         for($i=0; $i<=23; $i++) :
    181           $hours[] = ($i<10) ? '0' . strval($i) : strval($i);
    182         endfor;
    183         $am_pm = FALSE;
    184       endif;
    185      
    186       // adjust minutes dropdown
    187       for($i=0; $i<=55; $i++) :
    188         if($i%5===0) :
    189           $minutes[] = ($i<10) ? '0' . strval($i) : strval($i);
    190         endif;
    191       endfor;
    192      
    193       // process the content from the shortcode
    194       $options = explode(",", $content);     
    195       $options = (sizeof($options)>0) ? $options : array();
    196      
    197       ob_start();
    198       require_once( plugin_dir_path(__FILE__) . 'views/form.php' );
    199       require_once( plugin_dir_path(__FILE__) . 'views/modal-error.php' );
    200       return ob_get_clean();
    201     }
    202    
    203   } // class ends here
    204228}
    205 
  • airport-transfers/trunk/public/views/form.php

    r1725009 r2842501  
    22
    33<form id="ns-airport-transfer-form" action="<?=get_permalink()?>" class="form-horizontal" method="post" accept-charset="utf-8">
    4 <noscript><?=airport_transfers_lang_e('Javascript must be enabled!');?></noscript><br><br>
     4<noscript><?php esc_html_e( 'Javascript must be enabled!', 'ns-airport-transfers' ); ?></noscript><br><br>
    55<input type="hidden" id="resort" value="<?=$params['resort']?>">
    66<input type="hidden" id="time_format" value="<?=$params['time-format']?>">
    77
    8   <h4 class="text-success"><?=airport_transfers_lang_e('Information about you');?></h4>
    9 
    10   <div class="form-group">
    11     <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Your name');?><span class="text-danger">*</span></label>
     8  <h4 class="text-success"><?php esc_html_e( 'Information about you', 'ns-airport-transfers' ); ?></h4>
     9
     10  <div class="form-group">
     11    <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Your name', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    1212      <div class="col-sm-8 col-xs-12">
    1313        <input type="text" id="name" class="form-control" value="" placeholder="">
     
    1616  <div class="clear"><br></div>
    1717  <div class="form-group">
    18       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Email address');?><span class="text-danger">*</span></label>
     18      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Email address', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    1919      <div class="col-sm-8 col-xs-12">
    2020        <input type="text" id="email" class="form-control" value="" placeholder="">
    21         <span class="explanation">(<?=airport_transfers_lang_e('On this Email you will recieve confirmation');?>)</span>
    22       </div>         
    23   </div>
    24   <div class="clear"></div>
    25   <div class="form-group">
    26       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Mobile');?><span class="text-danger">*</span></label>
     21        <span class="explanation">(<?php esc_html_e( 'On this Email you will recieve confirmation', 'ns-airport-transfers' ); ?>)</span>
     22      </div>
     23  </div>
     24  <div class="clear"></div>
     25  <div class="form-group">
     26      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Mobile', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    2727      <div class="col-sm-8 col-xs-12">
    2828        <input type="text" id="phone" class="form-control" value="" placeholder="">
    29         <span class="explanation">(<?=airport_transfers_lang_e('It\'s mandatory to input your phone number');?>)</span>
    30       </div>         
    31   </div>
    32   <div class="clear"></div>
    33   <div class="form-group">
    34       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('I would like to');?>:<span class="text-danger">*</span></label>
    35       <div class="col-sm-8 col-xs-12">
    36         <input type="radio" name="like_to" value="<?=airport_transfers_lang_e('Make reservation');?>" checked> <?=airport_transfers_lang_e('Make reservation');?><br>
    37         <input type="radio" name="like_to" value="<?=airport_transfers_lang_e('Request more information');?>"> <?=airport_transfers_lang_e('Request more information');?>
    38       </div> 
     29        <span class="explanation">(<?php esc_html_e( 'It\'s mandatory to input your phone number', 'ns-airport-transfers' ); ?>)</span>
     30      </div>
     31  </div>
     32  <div class="clear"></div>
     33  <div class="form-group">
     34      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'I would like to', 'ns-airport-transfers' ); ?>:<span class="text-danger">*</span></label>
     35      <div class="col-sm-8 col-xs-12">
     36        <input type="radio" name="like_to" value="<?php esc_html_e( 'Make reservation', 'ns-airport-transfers' ); ?>" checked> <?php esc_html_e( 'Make reservation', 'ns-airport-transfers' ); ?><br>
     37        <input type="radio" name="like_to" value="<?php esc_html_e( 'Request more information', 'ns-airport-transfers' ); ?>"> <?php esc_html_e( 'Request more information', 'ns-airport-transfers' ); ?>
     38      </div>
    3939  </div><hr>
    4040  <div class="clear"></div>
    4141  <div class="form-group">
    42       <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Transfer type');?><span class="text-danger">*</span></label>
     42      <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Transfer type', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    4343      <div class="col-sm-8 col-xs-12">
    4444        <select id="transfer_type" class="form-control">
    45           <option value="two_way"><?=airport_transfers_lang_e('Two way');?></option>
    46           <option value="from_airport"><?=airport_transfers_lang_e('One way');?> (<?=airport_transfers_lang_e('From airport');?>)</option>
    47           <option value="to_airport"><?=airport_transfers_lang_e('One way');?> (<?=airport_transfers_lang_e('To airport');?>)</option>
     45          <option value="two_way"><?php esc_html_e( 'Two way', 'ns-airport-transfers' ); ?></option>
     46          <option value="from_airport"><?php esc_html_e( 'One way', 'ns-airport-transfers' ); ?> (<?php esc_html_e( 'From airport', 'ns-airport-transfers' ); ?>)</option>
     47          <option value="to_airport"><?php esc_html_e( 'One way', 'ns-airport-transfers' ); ?> (<?php esc_html_e( 'To airport', 'ns-airport-transfers' ); ?>)</option>
    4848        </select>
    4949      </div>
     
    5151  <div class="clear"></div><br>
    5252  <div class="form-group">
    53       <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of adults');?><span class="text-danger">*</span></label>
     53      <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of adults', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    5454      <div class="col-md-2 col-sm-2 col-xs-4">
    5555        <input type="text" id="adults" class="form-control" value="" placeholder="">
    56       </div> 
    57      
    58       <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of children');?><span class="text-danger">*</span></label>
     56      </div>
     57
     58      <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of children', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    5959      <div class="col-md-2 col-sm-2 col-xs-4">
    6060        <input type="text" id="children" class="form-control" value="" placeholder="">
     
    6262  </div>
    6363  <div class="clear"></div><br>
    64   <div class="form-group"> 
    65       <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of koffers');?><span class="text-danger">*</span></label>
     64  <div class="form-group">
     65      <label class="col-md-4 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of koffers', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    6666      <div class="col-md-2 col-sm-2 col-xs-4">
    6767        <input type="text" id="koffers" class="form-control" value="" placeholder="">
    68       </div> 
    69      
     68      </div>
     69
    7070      <?php if(strtolower($params['resort'])==='winter') : ?>
    71       <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('No. of ski/snowboards');?><span class="text-danger">*</span></label>
     71      <label class="col-md-3 col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'No. of ski/snowboards', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    7272      <div class="col-md-2 col-sm-2 col-xs-4">
    7373        <input type="text" id="ski" class="form-control" value="" placeholder="">
    74       </div>         
     74      </div>
    7575      <?php endif; ?>
    7676  </div>
    7777  <div class="clear"></div><hr>
    78  
     78
    7979  <div id="arrival">
    80     <h4><span class="text-success"><?=airport_transfers_lang_e('After arrival');?></span> <span class="small">(<?=airport_transfers_lang_e('From airport');?>)</span></h4>
    81 
    82     <div class="form-group">
    83         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Date of arrival');?><span class="text-danger">*</span></label>
     80    <h4><span class="text-success"><?php esc_html_e( 'After arrival', 'ns-airport-transfers' ); ?></span> <span class="small">(<?php esc_html_e( 'From airport', 'ns-airport-transfers' ); ?>)</span></h4>
     81
     82    <div class="form-group">
     83        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Date of arrival', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    8484        <div class="col-sm-3 col-xs-4">
    8585          <input type="text" id="arrival_date" value="" class="date form-control" placeholder="">
     
    8888    <div class="clear"></div><br>
    8989    <div class="form-group">
    90         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Time of arrival');?><span class="text-danger">*</span></label>
     90        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Time of arrival', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    9191        <div class="col-sm-3 col-xs-4">
    9292          <select id="arrival_hour" class="form-control">
    93             <option value="-"><?=airport_transfers_lang_e('Hour')?></option>
     93            <option value="-"><?php esc_html_e( 'Hour', 'ns-airport-transfers' ); ?></option>
    9494            <?php foreach ($hours as $hour) : ?>
    9595            <option value="<?=$hour?>"><?=$hour?></option>
     
    9999        <div class="col-sm-3 col-xs-4">
    100100          <select id="arrival_minutes" class="form-control">
    101             <option value="-"><?=airport_transfers_lang_e('Min')?></option>
     101            <option value="-"><?php esc_html_e( 'Min', 'ns-airport-transfers' ); ?></option>
    102102            <?php foreach ($minutes as $minute) : ?>
    103103            <option value="<?=$minute?>"><?=$minute?></option>
     
    115115    <div class="clear"></div><br>
    116116    <div class="form-group">
    117         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Airport')?><span class="text-danger">*</span></label>
    118         <div class="col-sm-6 col-xs-12">
    119           <select id="arrival_airport" class="form-control">         
    120             <option value="-"><?=airport_transfers_lang_e('select')?></option>
     117        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Airport', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
     118        <div class="col-sm-6 col-xs-12">
     119          <select id="arrival_airport" class="form-control">
     120            <option value="-"><?php esc_html_e( 'select', 'ns-airport-transfers' ); ?></option>
    121121            <?php foreach ($options as $option) : ?>
    122122            <option value="<?=$option?>"><?=$option?></option>
     
    127127    <div class="clear"></div><br>
    128128    <div class="form-group">
    129         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Flight number')?><span class="text-danger">*</span></label>
     129        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Flight number', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    130130        <div class="col-sm-6 col-xs-12">
    131131          <input type="text" class="form-control" id="arrival_flight" value="" placeholder="">
     
    134134    <div class="clear"></div><br>
    135135  </div>
    136  
     136
    137137  <div id="departure">
    138     <h4><span class="text-success"><?=airport_transfers_lang_e('Leaving')?></span> <span class="small">(<?=airport_transfers_lang_e('To airport');?>)</span></h4>
    139 
    140     <div class="form-group">
    141         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Date of departure')?><span class="text-danger">*</span></label>
     138    <h4><span class="text-success"><?php esc_html_e( 'Leaving', 'ns-airport-transfers' ); ?></span> <span class="small">(<?php esc_html_e( 'To airport', 'ns-airport-transfers' ); ?>)</span></h4>
     139
     140    <div class="form-group">
     141        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Date of departure', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    142142        <div class="col-sm-3 col-xs-4">
    143143          <input type="text" id="out_date" value="" class="date form-control" placeholder="">
     
    146146    <div class="clear"></div><br>
    147147    <div class="form-group">
    148         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Time of departure');?><span class="text-danger">*</span></label>
     148        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Time of departure', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    149149        <div class="col-sm-3 col-xs-4">
    150150          <select id="out_hour" class="form-control">
    151             <option value="-"><?=airport_transfers_lang_e('Hour')?></option>
     151            <option value="-"><?php esc_html_e( 'Hour', 'ns-airport-transfers' ); ?></option>
    152152            <?php foreach ($hours as $hour) : ?>
    153153            <option value="<?=$hour?>"><?=$hour?></option>
     
    157157        <div class="col-sm-3 col-xs-4">
    158158          <select id="out_minutes" class="form-control">
    159             <option value="-"><?=airport_transfers_lang_e('Min')?></option>
     159            <option value="-"><?php esc_html_e( 'Min', 'ns-airport-transfers' ); ?></option>
    160160            <?php foreach ($minutes as $minute) : ?>
    161161            <option value="<?=$minute?>"><?=$minute?></option>
     
    173173    <div class="clear"></div><br>
    174174    <div class="form-group">
    175         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Airport')?><span class="text-danger">*</span></label>
    176         <div class="col-sm-6 col-xs-12">
    177           <select id="out_airport" class="form-control">         
    178             <option value="-"><?=airport_transfers_lang_e('select')?></option>
     175        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Airport', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
     176        <div class="col-sm-6 col-xs-12">
     177          <select id="out_airport" class="form-control">
     178            <option value="-"><?php esc_html_e( 'select', 'ns-airport-transfers' ); ?></option>
    179179            <?php foreach ($options as $option) : ?>
    180180            <option value="<?=$option?>"><?=$option?></option>
     
    185185    <div class="clear"></div><br>
    186186    <div class="form-group">
    187         <label class="col-sm-4 col-xs-12 control-label"><?=airport_transfers_lang_e('Flight number')?><span class="text-danger">*</span></label>
     187        <label class="col-sm-4 col-xs-12 control-label"><?php esc_html_e( 'Flight number', 'ns-airport-transfers' ); ?><span class="text-danger">*</span></label>
    188188        <div class="col-sm-6 col-xs-12">
    189189          <input type="text" id="out_flight" class="form-control" value="" placeholder="">
     
    192192    <div class="clear"></div><br>
    193193  </div>
    194  
     194
    195195  <div class="clear"></div><hr>
    196196
    197   <h4 class="text-success"><?=airport_transfers_lang_e('Address in')?> <?=airport_transfers_lang_e(get_option('ns-airport-transfers-country'))?></h4>
    198  
    199   <div class="clear"></div>
    200  
    201   <div class="form-group">
    202     <label class="col-md-4 col-sm-12 col-xs-12"><?=airport_transfers_lang_e('Address of hotel/accommodation')?>: <span class="text-danger">*</span></label>
     197  <h4 class="text-success"><?php esc_html_e( 'Address in', 'ns-airport-transfers' ); ?> <?php esc_html_e( get_option('ns-airport-transfers-country'))?></h4>
     198
     199  <div class="clear"></div>
     200
     201  <div class="form-group">
     202    <label class="col-md-4 col-sm-12 col-xs-12"><?php esc_html_e( 'Address of hotel/accommodation', 'ns-airport-transfers' ); ?>: <span class="text-danger">*</span></label>
    203203    <div class="col-md-8 col-sm-12 col-xs-12">
    204204      <textarea id="adress" class="form-control" rows="2" placeholder=""></textarea>
    205     </div>     
    206   </div>
    207  
     205    </div>
     206  </div>
     207
    208208  <div class="clear"></div><br>
    209  
    210   <div class="form-group">
    211     <label class="col-md-4 col-sm-12 col-xs-12"><?=airport_transfers_lang_e('Remarks/instructions')?>:</label>
     209
     210  <div class="form-group">
     211    <label class="col-md-4 col-sm-12 col-xs-12"><?php esc_html_e( 'Remarks/instructions', 'ns-airport-transfers' ); ?>:</label>
    212212    <div class="col-md-8 col-sm-12 col-xs-12">
    213213      <textarea id="instructions" class="form-control" rows="2" placeholder=""></textarea>
     
    215215  </div>
    216216  <br><br>
    217   <div id="submit" class="btn btn-default"><?=airport_transfers_lang_e('Send')?></div>
    218  
     217  <div id="submit" class="btn btn-default"><?php esc_html_e( 'Send', 'ns-airport-transfers' ); ?></div>
     218
    219219</form>
    220220
    221 <?php if($params['show-contacts']==='true') : ?>
     221<?php if($params['show-contacts']==='1') : ?>
    222222<div class="clear"></div><br>
    223 <i><?php printf(airport_transfers_lang('If you need transfer from airport to another destination, wich is not specified please call us at %s or send an e-mail to %s'), get_option('ns-airport-transfers-contact-phone'), get_option('ns-airport-transfers-contact-email'))?></i>
     223<i><?php
     224    printf(
     225        esc_html__( 'If you need transfer from airport to another destination, wich is not specified please call us at %s or send an e-mail to %s' ),
     226        get_option( 'ns-airport-transfers-contact-phone' ),
     227        get_option( 'ns-airport-transfers-contact-email' )
     228    ); ?></i>
    224229<?php endif; ?>
  • airport-transfers/trunk/public/views/modal-error.php

    r1725009 r2842501  
    55    <div class="modal-content">
    66      <div class="modal-header">
    7         <button type="button" class="close" data-dismiss="modal" aria-label="<?=airport_transfers_lang_e('close'); ?>"><span aria-hidden="true">&times;</span></button>
    8         <h4 class="modal-title" id="modal-error-title"><?=airport_transfers_lang_e('Error'); ?></h4>
     7        <button type="button" class="close" data-dismiss="modal" aria-label="<?php esc_html_e( 'Close', 'ns-airport-transfers' ); ?>"><span aria-hidden="true">&times;</span></button>
     8        <h4 class="modal-title" id="modal-error-title"><?php esc_html_e( 'Error', 'ns-airport-transfers' ); ?></h4>
    99      </div>
    1010      <div class="modal-body">
    1111        <div class="box box-danger">
    12           <div class="box-body"> 
     12          <div class="box-body">
    1313            <div class="row">
    1414              <div class="col-xs-12">
     
    2020      </div>
    2121      <div class="modal-footer">
    22         <button type="button" id="cancel" class="btn btn-default" data-dismiss="modal"><?=airport_transfers_lang_e('close'); ?></button>
     22        <button type="button" id="cancel" class="btn btn-default" data-dismiss="modal"><?php esc_html_e( 'Close', 'ns-airport-transfers' ); ?></button>
    2323      </div>
    2424    </div>
Note: See TracChangeset for help on using the changeset viewer.