Ejemplo n.º 1
0
 /**
  * Render the form. The included template has $this available.
  *
  * The rendered template file can be overridden by themes by making a theme
  * directory `wprsrv` and creating a file named `reservation-form.php` inside it.
  *
  * The template file can be filtered to pick any other file which is needed.
  *
  * @since 0.1.0
  * @return void
  */
 public function render()
 {
     if (!$this->reservable->isActive()) {
         $this->reservationDisabledNotice();
         return;
     }
     if (!is_user_logged_in() && $this->reservable->isLoginRequired()) {
         $this->reservationRestrictedNotice();
         return;
     }
     try {
         $this->formFieldMarkup = $this->generateFormFieldsMarkup();
     } catch (\Exception $e) {
         \Wprsrv\wprsrv()->logger->critical('Cannot render reservation form: {msg}', ['msg' => $e->getMessage()]);
         return;
     }
     $themeTemplateFile = get_stylesheet_directory() . RDS . 'wprsrv' . 'reservation-form.php';
     $pluginTemplateFile = \Wprsrv\wprsrv()->templateDirectory . RDS . 'frontend' . RDS . 'reservation-form.php';
     // If a theme overrides the template file, load it. Otherwise use the plugin's own template.
     if (file_exists($themeTemplateFile)) {
         $templateFile = $themeTemplateFile;
     } else {
         $templateFile = $pluginTemplateFile;
     }
     /**
      * Filter the reservation form template file absolute path.
      *
      * @since 0.1.0
      *
      * @param String $templateFile Absolute path to template file.
      */
     $templateFile = apply_filters('wprsrv/reservation_form/template_file', $templateFile);
     include $templateFile;
 }
Ejemplo n.º 2
0
        <tr>
            <th class="wprsrv-mainlabel" scope="row">
                <label for=""><?php 
_ex('Only logged in users can reserve', 'reservable metabox form', 'wprsrv');
?>
</label>
                <em><?php 
_e('Disable reservations from guests.', 'wprsrv');
?>
</em>
            </th>
            <td>
                <label for="wprsrv-reservable-loggedin">
                    <input type="checkbox" name="wprsrv[reservable_loggedin_only]" <?php 
echo $reservable->isLoginRequired() ? 'checked' : '';
?>
 id="wprsrv-reservable-loggedin">
                    <?php 
_e('Require login', 'wprsrv');
?>
                </label>
            </td>
        </tr>

        <tr>
            <th class="wprsrv-mainlabel" scope="row">
                <label for="wprsrv-reservable-allow-overlapping"><?php 
_ex('Allow reservation overlaps', 'reservable metabox form', 'wprsrv');
?>
</label>