customs
5 months ago
holders
5 months ago
checkbox.php
5 months ago
color-and-opacity.php
5 months ago
color.php
5 months ago
datepicker-range.php
5 months ago
dropdown-and-colors.php
5 months ago
dropdown.php
5 months ago
font.php
5 months ago
google-font.php
5 months ago
gradient.php
5 months ago
hidden.php
5 months ago
index.php
6 months ago
integer.php
5 months ago
list.php
5 months ago
multiple-textbox.php
5 months ago
paddings-editor.php
5 months ago
pattern.php
5 months ago
radio-colors.php
5 months ago
radio.php
5 months ago
textarea.php
5 months ago
textbox.php
5 months ago
url.php
5 months ago
wp-editor.php
5 months ago
datepicker-range.php
107 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Datepicker range control |
| 5 | * |
| 6 | * Example: |
| 7 | * 'type' => 'datetimepicker-range', |
| 8 | * 'name' => 'facebook_start_date_filter', |
| 9 | * 'range_1' => array( |
| 10 | * 'format' => 'YYYY/MM/DD HH:mm', |
| 11 | * 'default' => date('Y/m/d H:i', strtotime('-1 week')) |
| 12 | * ), |
| 13 | * 'range_2' => array( |
| 14 | * 'format' => 'YYYY/MM/DD HH:mm', |
| 15 | * 'default' => date('Y/m/d H:i') |
| 16 | * ), |
| 17 | * 'title' => __('Выберите период', 'wpcr-scrapes'), |
| 18 | * 'hint' => __('Если Вкл., вы сможете установить настройки выбора записей за установленный период времени.', 'wpcr-scrapes') |
| 19 | * |
| 20 | * @package factory-forms |
| 21 | * @since 1.0.0 |
| 22 | */ |
| 23 | |
| 24 | // Exit if accessed directly |
| 25 | if ( ! defined( 'ABSPATH' ) ) { |
| 26 | exit; |
| 27 | } |
| 28 | |
| 29 | if ( ! class_exists( 'Wbcr_FactoryForms600_DatepickerRangeControl' ) ) { |
| 30 | |
| 31 | class Wbcr_FactoryForms600_DatepickerRangeControl extends Wbcr_FactoryForms600_ComplexControl { |
| 32 | |
| 33 | public $type = 'datetimepicker-range'; |
| 34 | |
| 35 | public function __construct( $options, $form, $provider = null ) { |
| 36 | parent::__construct( $options, $form, $provider ); |
| 37 | |
| 38 | if ( ! isset( $options['range_1'] ) ) { |
| 39 | $options['range_1'] = []; |
| 40 | } |
| 41 | |
| 42 | $options['range_1'] = array_merge( |
| 43 | [ |
| 44 | 'scope' => isset( $options['scope'] ) |
| 45 | ? $options['scope'] |
| 46 | : 'factory', |
| 47 | 'name' => $this->options['name'] . '__range_1', |
| 48 | 'format' => 'YYYY/MM/DD HH:mm', |
| 49 | 'default' => date( 'Y/m/d H:i' ), |
| 50 | ], |
| 51 | $options['range_1'] |
| 52 | ); |
| 53 | |
| 54 | if ( ! isset( $options['range_2'] ) ) { |
| 55 | $options['range_2'] = []; |
| 56 | } |
| 57 | |
| 58 | $options['range_2'] = array_merge( |
| 59 | [ |
| 60 | 'scope' => isset( $options['scope'] ) |
| 61 | ? $options['scope'] |
| 62 | : 'factory', |
| 63 | 'name' => $this->options['name'] . '__range_2', |
| 64 | 'format' => 'YYYY/MM/DD HH:mm', |
| 65 | 'default' => date( 'Y/m/d H:i', strtotime( '+1 month' ) ), |
| 66 | ], |
| 67 | $options['range_2'] |
| 68 | ); |
| 69 | |
| 70 | $this->range_1 = new Wbcr_FactoryForms600_TextboxControl( $options['range_1'], $form, $provider ); |
| 71 | $this->range_2 = new Wbcr_FactoryForms600_TextboxControl( $options['range_2'], $form, $provider ); |
| 72 | $this->inner_controls = [ $this->range_1, $this->range_2 ]; |
| 73 | |
| 74 | foreach ( $this->inner_controls as $key => $control ) { |
| 75 | $control->addCssClass( 'factory-datetimepicker-range-' . $key ); |
| 76 | $control->addHtmlAttr( 'data-date-show-today-button', 'true' ); |
| 77 | $control->addHtmlAttr( 'data-date-show-clear', 'true' ); |
| 78 | |
| 79 | $format = $control->getOption( 'format' ); |
| 80 | |
| 81 | if ( ! empty( $format ) ) { |
| 82 | // 'YYYY/MM/DD HH:mm' |
| 83 | $control->addHtmlAttr( 'data-date-format', $format ); |
| 84 | } |
| 85 | |
| 86 | $locale_parts = explode( '_', get_locale() ); |
| 87 | |
| 88 | $locale = isset( $locale_parts[0] ) |
| 89 | ? $locale_parts[0] |
| 90 | : 'en'; |
| 91 | |
| 92 | $control->addHtmlAttr( 'data-date-locale', $locale ); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | public function render() { |
| 97 | ?> |
| 98 | <div class='input-group date factory-datetimepicker-input-group' style="display:inline-block; width: 200px"> |
| 99 | <?php $this->range_1->render(); ?> |
| 100 | </div> |
| 101 | <div class='input-group date factory-datetimepicker-input-group' style="display:inline-block; width: 200px"> |
| 102 | <?php $this->range_2->render(); ?> |
| 103 | </div> |
| 104 | <?php |
| 105 | } |
| 106 | } |
| 107 | } |