Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'rcl_fields', 'add_field_type_rangedate' );
- function add_field_type_rangedate( $fields ) {
- $fields['rangedate'] = array(
- 'label' => __( 'Диапазон дат' ),
- 'class' => 'Rcl_Field_RangeDate'
- );
- return $fields;
- }
- class Rcl_Field_RangeDate extends Rcl_Field_Abstract {
- public $required;
- public $placeholder_from;
- public $placeholder_to;
- function __construct( $args ) {
- parent::__construct( $args );
- }
- function get_options() {
- return array(
- array(
- 'slug' => 'icon',
- 'default' => 'fa-calendar',
- 'placeholder' => 'fa-calendar',
- 'class' => 'rcl-iconpicker',
- 'type' => 'text',
- 'title' => __( 'Icon class of font-awesome', 'wp-recall' ),
- 'notice' => __( 'Source', 'wp-recall' ) . ' <a href="https://fontawesome.com/v4.7.0/icons/" target="_blank">http://fontawesome.io/</a>'
- ),
- array(
- 'slug' => 'placeholder_from',
- 'default' => $this->placeholder_from,
- 'type' => 'text',
- 'title' => __( 'Placeholder from', 'wp-recall' )
- ),
- array(
- 'slug' => 'placeholder_to',
- 'default' => $this->placeholder_to,
- 'type' => 'text',
- 'title' => __( 'Placeholder to', 'wp-recall' )
- )
- );
- }
- function get_placeholder( $type = 'from' ) {
- if ( $type == 'from' && $this->placeholder_from ) {
- return 'placeholder="' . $this->placeholder_from . '"';
- } else if ( $type == 'to' && $this->placeholder_to ) {
- return 'placeholder="' . $this->placeholder_to . '"';
- }
- return;
- }
- function get_input() {
- rcl_datepicker_scripts();
- $this->classes = 'rcl-datepicker';
- $content .= '<input type="text" ' . $this->get_class() . ' onclick="rcl_show_datepicker(this);" title="' . __( 'Use the format', 'wp-recall' ) . ': yyyy-mm-dd" pattern="(\d{4}-\d{2}-\d{2})" ' . $this->get_required() . ' ' . $this->get_placeholder( 'from' ) . ' name="' . $this->input_name . '[]" id="' . $this->input_id . '_from" value="' . $this->value[0] . '"/>';
- $content .= ' - ';
- $content .= '<input type="text" ' . $this->get_class() . ' onclick="rcl_show_datepicker(this);" title="' . __( 'Use the format', 'wp-recall' ) . ': yyyy-mm-dd" pattern="(\d{4}-\d{2}-\d{2})" ' . $this->get_required() . ' ' . $this->get_placeholder( 'to' ) . ' name="' . $this->input_name . '[]" id="' . $this->input_id . '_to" value="' . $this->value[1] . '"/>';
- return $content;
- }
- }
Add Comment
Please, Sign In to add comment