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,69 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'ES_Recipient_Rules' ) ) {
/**
* Class ES_Recipient_Rules
*
* @since 5.6.0
*/
class ES_Recipient_Rules {
private $rules = array();
// class constructor
public function __construct() {
$this->init();
}
public function init() {
$this->register_rules();
}
public function register_rules() {
$this->rules = array(
'list' => 'ES_Recipient_Rule_List',
);
$this->rules = apply_filters( 'ig_es_recipient_rules', $this->rules );
}
/**
* Function to get rules
*
* @return $rules mixed
*/
public function get_rules() {
$rules = $this->rules;
$recipient_rules = array();
foreach ( $rules as $rule_name => $rule_class ) {
$rule_obj = new $rule_class( $rule_name );
$rule_title = $rule_obj->get_title();
$rule_operators = $rule_obj->get_operators();
$rule_group = $rule_obj->get_group();
$rule_allowed_values = $rule_obj->get_allowed_values();
$value_field_type = $rule_obj->get_field_value_type();
if ( ! isset( $recipient_rules[ $rule_group ] ) ) {
$recipient_rules[ $rule_group ] = array();
}
$recipient_rules[ $rule_group ][ $rule_name ] = array(
'name' => $rule_name,
'title' => $rule_title,
'group' => $rule_group,
'operators' => $rule_operators,
'allowed_values' => $rule_allowed_values,
'value_field_type' => $value_field_type,
);
if ( 'number' === $value_field_type && $rule_obj instanceof ES_Recipient_Rule_Number ) {
$recipient_rules[ $rule_group ][ $rule_name ]['min_value'] = $rule_obj->get_min_value();
$recipient_rules[ $rule_group ][ $rule_name ]['max_value'] = $rule_obj->get_max_value();
}
}
return $recipient_rules;
}
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Class for Rule_Boolean
*
* @since 2.5.0
* @version 1.0.0
*
* @package affiliate-for-woocommerce/includes/commission_rules
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'ES_Recipient_Rule_Boolean' ) ) {
abstract class ES_Recipient_Rule_Boolean extends ES_Recipient_Rule {
/**
* Constructor
*
* @param array $props props.
*/
public function __construct( $rule_name ) {
parent::__construct( $rule_name);
$this->operators = array(
array(
'op' => 'is',
'label' => __( 'is', 'email-subscribers' )
),
array(
'op' => 'is_not',
'label' => __( 'is not', 'email-subscribers' )
),
);
}
}
}

View File

@@ -0,0 +1,149 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'ES_Recipient_Rule' ) ) {
/**
* Base class for ES recipient rules
*/
abstract class ES_Recipient_Rule {
/**
* Name of the rule
*
* @var string
*/
protected $name;
/**
* Title of the rule
*
* @var string
*/
protected $title;
/**
* Group that rules belongs to
*
* @var string
*/
protected $group;
/**
* Variable to hold possible operators
*
* @var $operators
*/
protected $operators;
/**
* Variable to hold operator
*
* @var $operator
*/
protected $operator;
/**
* Variable to hold value
*
* @var $value
*/
protected $value;
/**
* Variable to hold allowed_values
*
* @var $allowed_values
*/
protected $allowed_values;
protected $value_field_type;
/**
* Constructor
*
* @param array $props props.
*/
public function __construct( $rule_name ) {
$this->set_rule_details();
}
abstract public function set_rule_details();
public function get_name() {
return $this->name;
}
public function set_name( $name ) {
$this->name = $name;
}
public function get_title() {
return $this->title;
}
public function set_title( $title ) {
$this->title = $title;
}
/**
* Function to get rule group
*
* @return string
*/
public function get_group() {
return $this->group;
}
public function set_group( $group ) {
$this->group = $group;
}
/**
* Function to get possible values
*
* @return $allowed_values mixed
*/
public function get_allowed_values() {
return $this->allowed_values;
}
/**
* Function to set possible values
*
* @param array $v mixed.
*/
public function set_allowed_values( $v ) {
$this->allowed_values = $v;
}
/**
* Function to get possible values
*
* @return $operators mixed
*/
public function set_operators( $operators ) {
$this->operators = $operators;
}
/**
* Function to get possible values
*
* @return $operators mixed
*/
public function get_operators() {
return $this->operators;
}
public function set_value_field_type( $type ) {
$this->value_field_type = $type;
}
public function get_field_value_type() {
return $this->value_field_type;
}
}
}

View File

@@ -0,0 +1,24 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if ( ! class_exists( 'ES_Recipient_Rule_List' ) ) {
class ES_Recipient_Rule_List extends ES_Recipient_Rule_Boolean {
public function set_rule_details() {
$this->set_name( 'list' );
$this->set_title( __( 'List', 'email-subscribers' ) );
$this->set_group( __( 'List', 'email-subscribers' ) );
$lists = ES()->lists_db->get_list_id_name_map();
$this->set_allowed_values( $lists );
if ( ES()->is_pro() ) {
$this->set_value_field_type( 'multi-select' );
} else {
$this->set_value_field_type( 'select' );
}
}
}
}