/** * 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; }
<tr> <th class="wprsrv-mainlabel" scope="row"> <label for=""><?php _ex('Reservable active', 'reservable metabox form', 'wprsrv'); ?> </label> <em><?php _e('If the reservable is not active, it will be visible in the frontend but no reservation form will be shown.', 'wprsrv'); ?> </em> </th> <td> <label for="wprsrv-reservable-active"> <input type="checkbox" name="wprsrv[reservable_active]" <?php echo $reservable->isActive() ? 'checked="checked"' : ''; ?> id="wprsrv-reservable-active"> <?php _e('Active', 'wprsrv'); ?> </label> </td> </tr> <tr> <th class="wprsrv-mainlabel" scope="row"> <label for=""><?php _ex('Only single-day reservations', 'reservable metabox form', 'wprsrv'); ?> </label>