first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
/**
* Email Subscribers' checkbox field
*
* @since 4.4.3
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for workflow checkbox field
*
* @class ES_Checkbox
*/
class ES_Checkbox extends ES_Field {
protected $name = 'checkbox';
protected $type = 'checkbox';
public $default_to_checked = false;
/**
* Constructor
*
* @since 4.4.3
*/
public function __construct() {
parent::__construct();
$this->set_title( __( 'Checkbox', 'email-subscribers' ) );
}
/**
* Render checkbox field
*
* @param $value
*
* @since 4.4.3
*/
public function render( $value ) {
if ( null === $value || '' === $value ) {
$value = $this->default_to_checked;
}
?>
<label>
<input type="checkbox"
name="<?php echo esc_attr( $this->get_full_name() ); ?>"
value="1"
<?php echo ( $value ? 'checked' : '' ); ?>
class="<?php echo esc_attr( $this->get_classes() ); ?>"
<?php $this->output_extra_attrs(); ?>
>
<?php
echo esc_html( $this->get_title() );
?>
</label>
<?php
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* Email Subscribers' date field
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for date field
*
* @class Date
*
* @since 4.4.1
*/
class ES_Date extends ES_Text {
/**
* Constructor
*
* @since 4.4.1
*/
public function __construct() {
parent::__construct();
$this->title = __( 'Date', 'email-subscribers' );
$this->name = 'date';
$this->set_placeholder( 'YYYY-MM-DD' );
$this->add_extra_attr( 'autocomplete', 'off' );
$this->add_classes( 'ig-es-date-picker date-picker' );
}
}

View File

@@ -0,0 +1,475 @@
<?php
/**
* Email Subscribers' field abstract class
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
/**
* Abstract class Email Subsribers' fields.
*
* @class ES_Field
*
* @since 4.4.1
*/
abstract class ES_Field {
/**
* Field title
*
* @since 4.4.1
*
* @var string
*/
protected $title;
/**
* Field id
*
* @since 5.0.8
*
* @var string
*/
protected $id;
/**
* Field name
*
* @since 4.4.1
*
* @var string
*/
protected $name;
/**
* Field type
*
* @since 4.4.1
*
* @var string
*/
protected $type;
/**
* Field description
*
* @since 4.4.6
*
* @var string
*/
protected $description;
/**
* Field name base
*
* @since 4.4.1
*
* @var string
*/
protected $name_base;
/**
* Is field required
*
* @since 4.4.1
*
* @var bool
*/
protected $required = false;
/**
* Field classes
*
* @since 4.4.1
*
* @var array
*/
protected $classes = array();
/**
* Container element classes
*
* @since 5.3.9
*
* @var array
*/
protected $container_classes = array();
/**
* Extra attributes that will appended to the HTML field element.
*
* @since 4.4.1
*
* @var array
*/
protected $extra_attrs = array();
/**
* Field placeholder
*
* @since 4.4.1
*
* @var string
*/
protected $placeholder = '';
/**
* Output the field HTML.
*
* @since 4.4.1
*
* @param mixed $value Field value.
*/
abstract public function render( $value );
/**
* Field constructor.
*
* @since 4.4.1
*/
public function __construct() {
$this->classes[] = 'ig-es-field';
$this->classes[] = 'ig-es-field--type-' . $this->type;
}
/**
* Set field id
*
* @since 5.0.8
*
* @param string $name Field name.
*
* @return $this
*/
public function set_id( $id ) {
$this->id = $id;
return $this;
}
/**
* Set field name
*
* @since 4.4.1
*
* @param string $name Field name.
*
* @return $this
*/
public function set_name( $name ) {
$this->name = $name;
return $this;
}
/**
* Set field title
*
* @since 4.4.1
*
* @param string $title Field title.
*
* @return $this
*/
public function set_title( $title ) {
$this->title = $title;
return $this;
}
/**
*
* Get field title
*
* @since 4.4.1
*
* @return string
*/
public function get_title() {
return $this->title ? $this->title : '';
}
/**
*
* Get field id
*
* @since 5.0.8
*
* @return string
*/
public function get_id() {
return $this->id ? $this->id : '';
}
/**
*
* Get field name
*
* @since 4.4.1
*
* @return string
*/
public function get_name() {
return $this->name ? $this->name : '';
}
/**
* Get field type
*
* @since 4.4.1
*
* @return string
*/
public function get_type() {
return $this->type;
}
/**
* Set field description
*
* @since 4.4.6
*
* @param $description
*
* @return $this
*/
public function set_description( $description ) {
$this->description = $description;
return $this;
}
/**
* Get field description
*
* @since 4.4.6
*
* @return string
*/
public function get_description() {
return $this->description;
}
/**
*
* Set field placeholder
*
* @since 4.4.1
*
* @param string $placeholder Field placeholder.
*
* @return $this
*/
public function set_placeholder( $placeholder ) {
$this->placeholder = $placeholder;
return $this;
}
/**
*
* Get field placeholder
*
* @since 4.4.1
*
* @return string
*/
public function get_placeholder() {
return $this->placeholder;
}
/**
*
* Add field classes
*
* @since 4.4.1
*
* @param string $classes field classes.
*
* @return $this
*/
public function add_classes( $classes ) {
$this->classes = array_merge( $this->classes, explode( ' ', $classes ) );
return $this;
}
/**
* Get field classes
*
* @since 4.4.1
*
* @param bool $implode Should implode.
*
* @return array|string
*/
public function get_classes( $implode = true ) {
if ( $implode ) {
return implode( ' ', $this->classes );
}
return $this->classes;
}
/**
*
* Add container field classes
*
* @since 5.3.9
*
* @param string $container_classes container field classes.
*
* @return $this
*/
public function add_container_classes( $container_classes ) {
$this->container_classes = array_merge( $this->container_classes, explode( ' ', $container_classes ) );
return $this;
}
/**
* Get container field classes
*
* @since 5.3.9
*
* @param bool $implode Should implode.
*
* @return array|string
*/
public function get_container_classes( $implode = true ) {
if ( $implode ) {
return implode( ' ', $this->container_classes );
}
return $this->container_classes;
}
/**
* Get extra attributes for field.
*
* @since 4.4.1
*
* @param string $name Field name.
* @param string $value Field value.
*
* @return $this
*/
public function add_extra_attr( $name, $value = null ) {
$this->extra_attrs[ $name ] = $value;
return $this;
}
/**
* Add data attribute to field
*
* @since 4.4.1
*
* @param string $name Field name.
* @param string $value Field value.
*
* @return $this
*/
public function add_data_attr( $name, $value = null ) {
$this->add_extra_attr( 'data-' . $name, $value );
return $this;
}
/**
* Outputs the extra field attrs in HTML attribute format.
*
* @since 4.4.1
*
* @modified 4.5.4 Removed echo to allow escaping of attribute.
*/
public function output_extra_attrs() {
foreach ( $this->extra_attrs as $name => $value ) {
if ( is_null( $value ) ) {
echo esc_attr( $name ) . ' ';
} else {
echo esc_attr( $name ) . '="' . esc_attr( $value ) . '" ';
}
}
}
/**
* Set field to be required
*
* @since 4.4.1
*
* @param bool $required Should be required.
*
* @return $this
*/
public function set_required( $required = true ) {
$this->required = $required;
return $this;
}
/**
* Check if field is required
*
* @since 4.4.1
*
* @return bool
*/
public function get_required() {
return $this->required;
}
/**
* Set field name attribute
*
* @since 4.4.1
*
* @param string $name_base Field base name.
*
* @return $this
*/
public function set_name_base( $name_base ) {
$this->name_base = $name_base;
return $this;
}
/**
* Get field base name value
*
* @since 4.4.1
*
* @return bool
*/
public function get_name_base() {
return $this->name_base;
}
/**
* Get field full name including base name and field name.
*
* @since 4.4.1
*
* @return string
*/
public function get_full_name() {
return ( $this->get_name_base() ? $this->get_name_base() . '[' . $this->get_name() . ']' : $this->get_name() );
}
/**
* Sanitizes the value of the field.
*
* This method runs before WRITING a value to the DB but doesn't run before READING.
*
* Defaults to sanitize as a single line string. Override this method for fields that should be sanitized differently.
*
* @since 4.4.1
*
* @param string $value Field value.
*
* @return string
*/
public function sanitize_value( $value ) {
return ES_Clean::string( $value );
}
}

View File

@@ -0,0 +1,104 @@
<?php
/**
* Email Subscribers' text field
*
* @since 5.0.2
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for text field
*
* @class ES_Hidden_Field
*/
class ES_Hidden_Field extends ES_Field {
/**
* Input name
*
* @since 5.0.2
*
* @var string
*/
protected $name = 'hidden_input';
/**
* Input type
*
* @since 5.0.2
*
* @var string
*/
protected $type = 'hidden';
/**
* Is multiple
*
* @since 5.0.2
*
* @var boolean
*/
public $multiple = false;
/**
* Define whether HTML entities should be decoded before the field is rendered.
*
* @since 5.0.2
*
* @var bool
*/
public $decode_html_entities_before_render = true;
/**
* Constructor
*
* @since 5.0.2
*/
public function __construct() {
parent::__construct();
}
/**
* Set multiple
*
* @since 5.0.2
*
* @param bool $multi Flag for multiple field.
*
* @return $this
*/
public function set_multiple( $multi = true ) {
$this->multiple = $multi;
return $this;
}
/**
* Output the field HTML.
*
* @since 5.0.2
*
* @param string $value Field value.
*/
public function render( $value ) {
if ( $this->decode_html_entities_before_render ) {
$value = html_entity_decode( $value );
}
?>
<input type="<?php echo esc_attr( $this->get_type() ); ?>"
name="<?php echo esc_attr( $this->get_full_name() ); ?><?php echo $this->multiple ? '[]' : ''; ?>"
value="<?php echo esc_attr( $value ); ?>"
class="<?php echo esc_attr( $this->get_classes() ); ?>"
placeholder="<?php echo esc_attr( $this->get_placeholder() ); ?>"
<?php $this->output_extra_attrs(); ?>
<?php echo ( $this->get_required() ? 'required' : '' ); ?>
>
<?php
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Icegram Express' number field
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for number field
*
* @class ES_Number
*
* @since 4.4.1
*/
class ES_Number extends ES_Text {
/**
* Field type
*
* @since 4.4.1
*
* @var string
*/
protected $name = 'number_input';
/**
* Field type
*
* @since 4.4.1
*
* @var string
*/
protected $type = 'number';
/**
* Constructor
*
* @since 4.4.1
*/
public function __construct() {
parent::__construct();
$this->title = __( 'Number', 'email-subscribers' );
}
/**
* Set minimumu allowed value
*
* @since 4.4.1
*
* @param string $min minimum value.
*
* @return $this
*/
public function set_min( $min ) {
$this->add_extra_attr( 'min', $min );
return $this;
}
/**
* Set maimum allowed value
*
* @since 4.4.1
*
* @param string $max maximum value.
*
* @return $this
*/
public function set_max( $max ) {
$this->add_extra_attr( 'max', $max );
return $this;
}
/**
* Sanitizes the value of a number field.
*
* If the field is not required, the field can be left blank.
*
* @since 4.4.0
*
* @param string $value Field value.
*
* @return string|float
*/
public function sanitize_value( $value ) {
$value = trim( $value );
if ( ! $this->get_required() ) {
// preserve empty string values, don't cast to float.
if ( '' === $value ) {
return '';
}
}
return (float) $value;
}
}

View File

@@ -0,0 +1,263 @@
<?php
/**
* Icegram Express' select field
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for select field
*
* @class Select
*/
class ES_Select extends ES_Field {
/**
* Field name
*
* @since 4.4.1
*
* @var string
*/
protected $name = 'select';
/**
* Field type
*
* @since 4.4.1
*
* @var string
*/
protected $type = 'select';
/**
* Field options
*
* @since 4.4.1
*
* @var string
*/
protected $default_option;
/**
* Allow multiple choices
*
* @since 4.4.1
*
* @var boolean
*/
public $multiple = false;
/**
* Select field options
*
* @since 4.4.1
*
* @var array
*/
protected $options = array();
/**
* Construct
*
* @since 4.4.1
*
* @param bool $show_placeholder Should show placeholder.
*/
public function __construct( $show_placeholder = true ) {
parent::__construct();
$this->set_title( __( 'Select', 'email-subscribers' ) );
if ( $show_placeholder ) {
$this->set_placeholder( __( '[Select]', 'email-subscribers' ) );
}
}
/**
* Set select options
*
* @since 4.4.1
*
* @param array $options Select options.
*
* @return $this
*/
public function set_options( $options ) {
$this->options = $options;
return $this;
}
/**
* Get select options
*
* @since 4.4.1
*
* @return array
*/
public function get_options() {
return $this->options;
}
/**
* Set select default option
*
* @since 4.4.1
*
* @param string $option default option.
*
* @return $this
*/
public function set_default( $option ) {
$this->default_option = $option;
return $this;
}
/**
* Set multiple flag
*
* @since 4.4.1
*
* @param bool $multi Is multiple.
*
* @return $this
*/
public function set_multiple( $multi = true ) {
$this->multiple = $multi;
return $this;
}
/**
* Render field
*
* @since 4.4.1
*
* @param string $value field value.
*
* @return void
*/
public function render( $value = false ) {
$value = ES_Clean::recursive( $value );
if ( $this->multiple ) {
if ( ! $value ) {
$value = $this->default_option ? $this->default_option : array();
}
$this->render_multiple( (array) $value );
} else {
if ( empty( $value ) && $this->default_option ) {
$value = $this->default_option;
}
$this->render_single( (string) $value );
}
}
/**
* Render a single select box.
*
* @since 4.4.1
*
* @param string $value field value.
*/
protected function render_single( $value ) {
?>
<select name="<?php echo esc_attr( $this->get_full_name() ); ?>"
data-name="<?php echo esc_attr( $this->get_name() ); ?>"
class="<?php echo esc_attr( $this->get_classes() ); ?>"
<?php $this->output_extra_attrs(); ?>
<?php echo ( $this->get_required() ? 'required' : '' ); ?>
>
<?php if ( $this->get_placeholder() ) : ?>
<option value=""><?php echo esc_html( $this->get_placeholder() ); ?></option>
<?php endif; ?>
<?php foreach ( $this->get_options() as $opt_name => $opt_value ) : ?>
<?php if ( is_array( $opt_value ) ) : ?>
<optgroup label="<?php echo esc_attr( $opt_name ); ?>">
<?php foreach ( $opt_value as $opt_sub_name => $opt_sub_value ) : ?>
<option value="<?php echo esc_attr( $opt_sub_name ); ?>" <?php selected( $value, $opt_sub_name ); ?>><?php echo esc_html( $opt_sub_value ); ?></option>
<?php endforeach ?>
</optgroup>
<?php else : ?>
<option value="<?php echo esc_attr( $opt_name ); ?>" <?php selected( $value, $opt_name ); ?>><?php echo esc_html( $opt_value ); ?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<?php
}
/**
* Render a multi-select box.
*
* @since 4.4.1
*
* @param array $values field value.
*/
protected function render_multiple( $values ) {
?>
<select name="<?php echo esc_attr( $this->get_full_name() ); ?>[]"
data-name="<?php echo esc_attr( $this->get_name() ); ?>"
class="<?php echo esc_attr( $this->get_classes() ); ?> wc-enhanced-select"
multiple="multiple"
data-placeholder="<?php echo esc_attr( $this->get_placeholder() ); ?>"
<?php $this->output_extra_attrs(); ?>
>
<?php foreach ( $this->get_options() as $opt_name => $opt_value ) : ?>
<option value="<?php echo esc_attr( $opt_name ); ?>"
<?php echo in_array( (string) $opt_name, $values, true ) ? 'selected="selected"' : ''; ?>
><?php echo esc_html( $opt_value ); ?></option>
<?php endforeach; ?>
</select>
<script type="text/javascript">
jQuery(document).ready(function(){
if( 'function' === typeof jQuery.fn.ig_es_select2 ) {
jQuery('.ig-es-form-multiselect[data-name="<?php echo esc_attr( $this->get_name() ); ?>"]').ig_es_select2();
}
});
</script>
<?php
}
/**
* Sanitizes the value of the field.
*
* @since 4.4.1
*
* @param array|string $value Field value.
*
* @return array|string
*/
public function sanitize_value( $value ) {
if ( $this->multiple ) {
return ES_Clean::recursive( $value );
} else {
return ES_Clean::string( $value );
}
}
}

View File

@@ -0,0 +1,105 @@
<?php
/**
* Icegram Express' text field
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for text field
*
* @class ES_Text
*/
class ES_Text extends ES_Field {
/**
* Input name
*
* @since 4.4.1
*
* @var string
*/
protected $name = 'text_input';
/**
* Input type
*
* @since 4.4.1
*
* @var string
*/
protected $type = 'text';
/**
* Is multiple
*
* @since 4.4.1
*
* @var boolean
*/
public $multiple = false;
/**
* Define whether HTML entities should be decoded before the field is rendered.
*
* @since 4.4.1
*
* @var bool
*/
public $decode_html_entities_before_render = true;
/**
* Constructor
*
* @since 4.4.1
*/
public function __construct() {
parent::__construct();
$this->title = __( 'Text Input', 'email-subscribers' );
}
/**
* Set multiple
*
* @since 4.4.1
*
* @param bool $multi Flag for multiple field.
*
* @return $this
*/
public function set_multiple( $multi = true ) {
$this->multiple = $multi;
return $this;
}
/**
* Output the field HTML.
*
* @since 4.4.1
*
* @param string $value Field value.
*/
public function render( $value ) {
if ( $this->decode_html_entities_before_render ) {
$value = html_entity_decode( $value );
}
?>
<input type="<?php echo esc_attr( $this->get_type() ); ?>"
name="<?php echo esc_attr( $this->get_full_name() ); ?><?php echo $this->multiple ? '[]' : ''; ?>"
value="<?php echo esc_attr( $value ); ?>"
class="<?php echo esc_attr( $this->get_classes() ); ?>"
placeholder="<?php echo esc_attr( $this->get_placeholder() ); ?>"
<?php $this->output_extra_attrs(); ?>
<?php echo ( $this->get_required() ? 'required' : '' ); ?>
>
<?php
}
}

View File

@@ -0,0 +1,152 @@
<?php
/**
* Icegram Express' time field
*
* @since 4.4.1
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for Time field
*
* @class ES_Time
*
* @since 4.4.1
*/
class ES_Time extends ES_Field {
/**
* Field name
*
* @since 4.4.1
*
* @var string
*/
protected $name = 'time';
/**
* Field type
*
* @var string
*/
protected $type = 'text';
/**
* Flag to show 24 hours note
*
* @since 4.4.1
*
* @var boolean
*/
protected $show_24hr_note = true;
/**
* Set the maximum value for the hours field.
*
* @since 4.4.1
*
* @var int
*/
public $max_hours = 23;
/**
* Constructor
*
* @since 4.4.1
*/
public function __construct() {
parent::__construct();
$this->title = __( 'Time', 'email-subscribers' );
}
/**
* Set 24 Hours note
*
* @since 4.4.1
*
* @param boolean $show Flag to show 24 hours notice.
*
* @return $this
*/
public function set_show_24hr_note( $show ) {
$this->show_24hr_note = $show;
return $this;
}
/**
* Render field
*
* @since 4.4.1
*
* @param array $value Field value.
*/
public function render( $value ) {
if ( $value ) {
$value = ES_Clean::recursive( (array) $value );
} else {
$value = array( '', '' );
}
?>
<div class="ig-es-time-field-group">
<div class="ig-es-time-field-group__fields">
<?php
$field = new ES_Number();
$field
->set_name_base( $this->get_name_base() )
->set_name( $this->get_name() )
->set_min( 0 )
->set_max( $this->max_hours )
->set_multiple()
->set_placeholder( _x( 'HH', 'time field', 'email-subscribers' ) )
->render( $value[0] );
echo '<div class="ig-es-time-field-group__sep">:</div>';
$field = new ES_Number();
$field
->set_name_base( $this->get_name_base() )
->set_name( $this->get_name() )
->set_min( 0 )
->set_max( 59 )
->set_multiple()
->set_placeholder( _x( 'MM', 'time field', 'email-subscribers' ) )
->render( $value[1] );
?>
</div>
<?php if ( $this->show_24hr_note ) : ?>
<span class="ig-es-time-field-group__24hr-note"><?php esc_html_e( '(24 hour time)', 'email-subscribers' ); ?></span>
<?php endif; ?>
</div>
<?php
}
/**
* Sanitizes the value of the field.
*
* @since 4.4.1
*
* @param array $value Field value.
*
* @return array
*/
public function sanitize_value( $value ) {
$value = ES_Clean::recursive( $value );
$value[0] = min( $this->max_hours, $value[0] );
return $value;
}
}

View File

@@ -0,0 +1,90 @@
<?php
/**
* Icegram Express' WP Editor field
*
* @since 4.5.3
* @version 1.0
* @package Email Subscribers
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class for WP Editor field
*
* @class ES_WP_Editor
*
* @since 4.5.3
*/
class ES_WP_Editor extends ES_Field {
protected $name = 'ig_es_wp_editor';
protected $type = 'textarea';
public function __construct() {
parent::__construct();
$this->set_title( __( 'WP Editor', 'email-subscribers' ) );
}
/**
* Render wp editor field
*
* @param string $value
*
* @since 4.5.3
*/
public function render( $value ) {
$id = $this->get_id();
$value = ES_Clean::editor_content( $value );
// If it is an ajax request then load wp editor using js library.
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
?>
<textarea name="<?php echo esc_attr( $this->get_full_name() ); ?>" id="<?php echo esc_attr( $id ); ?>">
</textarea>
<?php
$this->ajax_init( $id );
} else {
// If it is not an ajax request then load wp editor using WordPress wp_editor PHP function.
wp_editor( $value, $id, array(
'textarea_name' => $this->get_full_name(),
'tinymce' => true, // default to visual
'quicktags' => true,
));
}
}
/**
* Initialize ajax loading of wp editor field
*
* @param int $id ID of the field.
*
* @since 4.5.3
*/
public function ajax_init( $id ) {
?>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#<?php echo esc_js( $id ); ?>').wp_js_editor();
});
</script>
<?php
}
/**
* Sanitizes the value of the field.
*
* @param string $value
*
* @return string
*
* @since 4.5.3
*/
public function sanitize_value( $value ) {
return ES_Clean::editor_content( $value );
}
}