Completed
Branch master (24c3eb)
by
unknown
34:49 queued 28:57
created
core/db_models/relations/EE_Has_Many_Relation.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
         $pk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
47 47
             $model_relation_chain,
48 48
             $this->get_this_model()->get_this_model_name()
49
-        ) . $this_table_pk_field->get_table_alias();
50
-        $fk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
49
+        ).$this_table_pk_field->get_table_alias();
50
+        $fk_table_alias = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
51 51
             $model_relation_chain,
52 52
             $this->get_other_model()->get_this_model_name()
53
-        ) . $other_table_fk_field->get_table_alias();
54
-        $fk_table             = $this->get_other_model()->get_table_for_alias($fk_table_alias);
53
+        ).$other_table_fk_field->get_table_alias();
54
+        $fk_table = $this->get_other_model()->get_table_for_alias($fk_table_alias);
55 55
 
56 56
         return $this->_left_join(
57 57
             $fk_table,
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
             $other_table_fk_field->get_table_column(),
60 60
             $pk_table_alias,
61 61
             $this_table_pk_field->get_table_column()
62
-        ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
62
+        ).$this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
63 63
     }
64 64
 
65 65
 
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -10,113 +10,113 @@
 block discarded – undo
10 10
  */
11 11
 class EE_Has_Many_Relation extends EE_Model_Relation_Base
12 12
 {
13
-    /**
14
-     * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the
15
-     * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but
16
-     * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get
17
-     * related models across the relation, and add-and-remove the relationships.
18
-     *
19
-     * @param bool   $block_deletes                  For this type of r elation, we block by default. If there are
20
-     *                                               related models across this relation, block (prevent and add an
21
-     *                                               error) the deletion of this model
22
-     * @param string $blocking_delete_error_message  a customized error message on blocking deletes instead of the
23
-     *                                               default
24
-     */
25
-    public function __construct(bool $block_deletes = true, string $blocking_delete_error_message = '')
26
-    {
27
-        parent::__construct($block_deletes, $blocking_delete_error_message);
28
-    }
13
+	/**
14
+	 * Object representing the relationship between two models. Has_Many_Relations are where the OTHER model has the
15
+	 * foreign key this model. IE, there can be many other model objects related to one of this model's objects (but
16
+	 * NOT through a JOIN table, which is the case for EE_HABTM_Relations). This knows how to join the models, get
17
+	 * related models across the relation, and add-and-remove the relationships.
18
+	 *
19
+	 * @param bool   $block_deletes                  For this type of r elation, we block by default. If there are
20
+	 *                                               related models across this relation, block (prevent and add an
21
+	 *                                               error) the deletion of this model
22
+	 * @param string $blocking_delete_error_message  a customized error message on blocking deletes instead of the
23
+	 *                                               default
24
+	 */
25
+	public function __construct(bool $block_deletes = true, string $blocking_delete_error_message = '')
26
+	{
27
+		parent::__construct($block_deletes, $blocking_delete_error_message);
28
+	}
29 29
 
30 30
 
31
-    /**
32
-     * Gets the SQL string for performing the join between this model and the other model.
33
-     *
34
-     * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
35
-     * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk =
36
-     *                                     other_model_primary_table.fk" etc
37
-     * @throws EE_Error
38
-     * @throws Exception
39
-     */
40
-    public function get_join_statement(string $model_relation_chain): string
41
-    {
42
-        // create the sql string like
43
-        // LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
44
-        $this_table_pk_field  = $this->get_this_model()->get_primary_key_field();
45
-        $other_table_fk_field =
46
-            $this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
47
-        $pk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
48
-            $model_relation_chain,
49
-            $this->get_this_model()->get_this_model_name()
50
-        ) . $this_table_pk_field->get_table_alias();
51
-        $fk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
52
-            $model_relation_chain,
53
-            $this->get_other_model()->get_this_model_name()
54
-        ) . $other_table_fk_field->get_table_alias();
55
-        $fk_table             = $this->get_other_model()->get_table_for_alias($fk_table_alias);
31
+	/**
32
+	 * Gets the SQL string for performing the join between this model and the other model.
33
+	 *
34
+	 * @param string $model_relation_chain like 'Event.Event_Venue.Venue'
35
+	 * @return string of SQL, eg "LEFT JOIN table_name AS table_alias ON this_model_primary_table.pk =
36
+	 *                                     other_model_primary_table.fk" etc
37
+	 * @throws EE_Error
38
+	 * @throws Exception
39
+	 */
40
+	public function get_join_statement(string $model_relation_chain): string
41
+	{
42
+		// create the sql string like
43
+		// LEFT JOIN other_table AS table_alias ON this_table_alias.pk = other_table_alias.fk extra_join_conditions
44
+		$this_table_pk_field  = $this->get_this_model()->get_primary_key_field();
45
+		$other_table_fk_field =
46
+			$this->get_other_model()->get_foreign_key_to($this->get_this_model()->get_this_model_name());
47
+		$pk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
48
+			$model_relation_chain,
49
+			$this->get_this_model()->get_this_model_name()
50
+		) . $this_table_pk_field->get_table_alias();
51
+		$fk_table_alias       = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix(
52
+			$model_relation_chain,
53
+			$this->get_other_model()->get_this_model_name()
54
+		) . $other_table_fk_field->get_table_alias();
55
+		$fk_table             = $this->get_other_model()->get_table_for_alias($fk_table_alias);
56 56
 
57
-        return $this->_left_join(
58
-            $fk_table,
59
-            $fk_table_alias,
60
-            $other_table_fk_field->get_table_column(),
61
-            $pk_table_alias,
62
-            $this_table_pk_field->get_table_column()
63
-        ) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
64
-    }
57
+		return $this->_left_join(
58
+			$fk_table,
59
+			$fk_table_alias,
60
+			$other_table_fk_field->get_table_column(),
61
+			$pk_table_alias,
62
+			$this_table_pk_field->get_table_column()
63
+		) . $this->get_other_model()->_construct_internal_join_to_table_with_alias($fk_table_alias);
64
+	}
65 65
 
66 66
 
67
-    /**
68
-     * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if
69
-     * you like.
70
-     *
71
-     * @param EE_Base_Class|int $this_obj_or_id
72
-     * @param EE_Base_Class|int $other_obj_or_id
73
-     * @param array             $extra_join_model_fields_n_values
74
-     * @return EE_Base_Class
75
-     * @throws EE_Error
76
-     * @throws Exception
77
-     */
78
-    public function add_relation_to(
79
-        $this_obj_or_id,
80
-        $other_obj_or_id,
81
-        array $extra_join_model_fields_n_values = []
82
-    ): EE_Base_Class {
83
-        $this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
84
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
67
+	/**
68
+	 * Sets the other model object's foreign key to this model object's primary key. Feel free to do this manually if
69
+	 * you like.
70
+	 *
71
+	 * @param EE_Base_Class|int $this_obj_or_id
72
+	 * @param EE_Base_Class|int $other_obj_or_id
73
+	 * @param array             $extra_join_model_fields_n_values
74
+	 * @return EE_Base_Class
75
+	 * @throws EE_Error
76
+	 * @throws Exception
77
+	 */
78
+	public function add_relation_to(
79
+		$this_obj_or_id,
80
+		$other_obj_or_id,
81
+		array $extra_join_model_fields_n_values = []
82
+	): EE_Base_Class {
83
+		$this_model_obj  = $this->get_this_model()->ensure_is_obj($this_obj_or_id, true);
84
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
85 85
 
86
-        // find the field on the other model which is a foreign key to this model
87
-        $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to(
88
-            $this->get_this_model()->get_this_model_name()
89
-        );
90
-        if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) {
91
-            // set that field on the other model to this model's ID
92
-            $other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID());
93
-            $other_model_obj->save();
94
-        }
95
-        return $other_model_obj;
96
-    }
86
+		// find the field on the other model which is a foreign key to this model
87
+		$fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to(
88
+			$this->get_this_model()->get_this_model_name()
89
+		);
90
+		if ($other_model_obj->get($fk_field_on_other_model->get_name()) != $this_model_obj->ID()) {
91
+			// set that field on the other model to this model's ID
92
+			$other_model_obj->set($fk_field_on_other_model->get_name(), $this_model_obj->ID());
93
+			$other_model_obj->save();
94
+		}
95
+		return $other_model_obj;
96
+	}
97 97
 
98 98
 
99
-    /**
100
-     * Sets the other model object's foreign key to its default, instead of pointing to this model object.
101
-     * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it
102
-     *
103
-     * @param EE_Base_Class|int $this_obj_or_id
104
-     * @param EE_Base_Class|int $other_obj_or_id
105
-     * @param array             $where_query
106
-     * @return EE_Base_Class
107
-     * @throws EE_Error
108
-     * @throws Exception
109
-     */
110
-    public function remove_relation_to($this_obj_or_id, $other_obj_or_id, array $where_query = []): EE_Base_Class
111
-    {
112
-        $other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
113
-        // find the field on the other model which is a foreign key to this model
114
-        $fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to(
115
-            $this->get_this_model()->get_this_model_name()
116
-        );
117
-        // set that field on the other model to this model's ID
118
-        $other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
119
-        $other_model_obj->save();
120
-        return $other_model_obj;
121
-    }
99
+	/**
100
+	 * Sets the other model object's foreign key to its default, instead of pointing to this model object.
101
+	 * If $other_obj_or_id doesn't have any other relations, this function is essentially orphaning it
102
+	 *
103
+	 * @param EE_Base_Class|int $this_obj_or_id
104
+	 * @param EE_Base_Class|int $other_obj_or_id
105
+	 * @param array             $where_query
106
+	 * @return EE_Base_Class
107
+	 * @throws EE_Error
108
+	 * @throws Exception
109
+	 */
110
+	public function remove_relation_to($this_obj_or_id, $other_obj_or_id, array $where_query = []): EE_Base_Class
111
+	{
112
+		$other_model_obj = $this->get_other_model()->ensure_is_obj($other_obj_or_id, true);
113
+		// find the field on the other model which is a foreign key to this model
114
+		$fk_field_on_other_model = $this->get_other_model()->get_foreign_key_to(
115
+			$this->get_this_model()->get_this_model_name()
116
+		);
117
+		// set that field on the other model to this model's ID
118
+		$other_model_obj->set($fk_field_on_other_model->get_name(), null, true);
119
+		$other_model_obj->save();
120
+		return $other_model_obj;
121
+	}
122 122
 }
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messenger_Collection.lib.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -189,7 +189,7 @@
 block discarded – undo
189 189
             $this->rewind();
190 190
             while ($this->valid()) {
191 191
                 echo '<h5 style="color:#2EA2CC;">
192
-                    ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
192
+                    ' . __CLASS__.' class : . <span style="color:#E76700">'.esc_html($this->getInfo()).'</span>
193 193
                     </h5>';
194 194
                 $this->next();
195 195
             }
Please login to merge, or discard this patch.
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,128 +13,128 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Messenger_Collection extends EE_Object_Collection
15 15
 {
16
-    /**
17
-     * EE_Messenger_Collection constructor.
18
-     */
19
-    public function __construct()
20
-    {
21
-        $this->interface = 'EE_messenger';
22
-    }
23
-
24
-
25
-
26
-    /**
27
-     * attaches an object to the Collection
28
-     * and sets any supplied data associated with the current iterator entry
29
-     * by calling EE_Object_Collection::set_info()
30
-     *
31
-     * @param object $object
32
-     * @param mixed  $info
33
-     * @return bool
34
-     */
35
-    public function add($object, $info = ''): bool
36
-    {
37
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
-        return parent::add($object, $info);
39
-    }
40
-
41
-
42
-
43
-    /**
44
-     * Sets the data associated with an object in the Collection
45
-     * if no $info is supplied, then the spl_object_hash() is used
46
-     *
47
-     * @param object $object
48
-     * @param array|int|string $info
49
-     * @return bool
50
-     */
51
-    public function set_info($object, $info = ''): bool
52
-    {
53
-        $info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
-        return parent::set_info($object, $info);
55
-    }
56
-
57
-
58
-
59
-    /**
60
-     * finds and returns an object in the Collection based on the info that was set using addObject()
61
-     * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
-     *
63
-     * @param string|null $info
64
-     * @return null | object
65
-     */
66
-    public function get_by_info($info = '')
67
-    {
68
-        return parent::get_by_info(str_replace(' ', '_', strtolower((string) $info)));
69
-    }
70
-
71
-
72
-
73
-    /**
74
-     * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
-     *
76
-     * @param object $object
77
-     * @return bool
78
-     */
79
-    public function has($object): bool
80
-    {
81
-        return parent::has($object);
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
88
-     *
89
-     * @param string $messenger_name
90
-     * @return bool
91
-     */
92
-    public function has_by_name(string $messenger_name): bool
93
-    {
94
-        return $this->get_by_info($messenger_name) instanceof $this->interface;
95
-    }
96
-
97
-
98
-
99
-    /**
100
-     * detaches an object from the Collection
101
-     *
102
-     * @param $object
103
-     * @return bool
104
-     */
105
-    public function remove($object): bool
106
-    {
107
-        return parent::remove($object);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * current object from the Collection
114
-     *
115
-     * @return EE_messenger
116
-     */
117
-    public function current(): EE_messenger
118
-    {
119
-        return parent::current();
120
-    }
121
-
122
-
123
-    /**
124
-     * displays list of collection classes if WP_DEBUG is on
125
-     *
126
-     * @return void
127
-     */
128
-    public function show_collection_classes()
129
-    {
130
-        if (WP_DEBUG) {
131
-            $this->rewind();
132
-            while ($this->valid()) {
133
-                echo '<h5 style="color:#2EA2CC;">
16
+	/**
17
+	 * EE_Messenger_Collection constructor.
18
+	 */
19
+	public function __construct()
20
+	{
21
+		$this->interface = 'EE_messenger';
22
+	}
23
+
24
+
25
+
26
+	/**
27
+	 * attaches an object to the Collection
28
+	 * and sets any supplied data associated with the current iterator entry
29
+	 * by calling EE_Object_Collection::set_info()
30
+	 *
31
+	 * @param object $object
32
+	 * @param mixed  $info
33
+	 * @return bool
34
+	 */
35
+	public function add($object, $info = ''): bool
36
+	{
37
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
38
+		return parent::add($object, $info);
39
+	}
40
+
41
+
42
+
43
+	/**
44
+	 * Sets the data associated with an object in the Collection
45
+	 * if no $info is supplied, then the spl_object_hash() is used
46
+	 *
47
+	 * @param object $object
48
+	 * @param array|int|string $info
49
+	 * @return bool
50
+	 */
51
+	public function set_info($object, $info = ''): bool
52
+	{
53
+		$info = empty($info) && $object instanceof $this->interface ? $object->name : $info;
54
+		return parent::set_info($object, $info);
55
+	}
56
+
57
+
58
+
59
+	/**
60
+	 * finds and returns an object in the Collection based on the info that was set using addObject()
61
+	 * PLZ NOTE: the pointer is reset to the beginning of the collection before returning
62
+	 *
63
+	 * @param string|null $info
64
+	 * @return null | object
65
+	 */
66
+	public function get_by_info($info = '')
67
+	{
68
+		return parent::get_by_info(str_replace(' ', '_', strtolower((string) $info)));
69
+	}
70
+
71
+
72
+
73
+	/**
74
+	 * returns TRUE or FALSE depending on whether the supplied object is within the Collection
75
+	 *
76
+	 * @param object $object
77
+	 * @return bool
78
+	 */
79
+	public function has($object): bool
80
+	{
81
+		return parent::has($object);
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 * returns TRUE or FALSE depending on whether the supplied messenger name is within the Collection
88
+	 *
89
+	 * @param string $messenger_name
90
+	 * @return bool
91
+	 */
92
+	public function has_by_name(string $messenger_name): bool
93
+	{
94
+		return $this->get_by_info($messenger_name) instanceof $this->interface;
95
+	}
96
+
97
+
98
+
99
+	/**
100
+	 * detaches an object from the Collection
101
+	 *
102
+	 * @param $object
103
+	 * @return bool
104
+	 */
105
+	public function remove($object): bool
106
+	{
107
+		return parent::remove($object);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * current object from the Collection
114
+	 *
115
+	 * @return EE_messenger
116
+	 */
117
+	public function current(): EE_messenger
118
+	{
119
+		return parent::current();
120
+	}
121
+
122
+
123
+	/**
124
+	 * displays list of collection classes if WP_DEBUG is on
125
+	 *
126
+	 * @return void
127
+	 */
128
+	public function show_collection_classes()
129
+	{
130
+		if (WP_DEBUG) {
131
+			$this->rewind();
132
+			while ($this->valid()) {
133
+				echo '<h5 style="color:#2EA2CC;">
134 134
                     ' . __CLASS__ . ' class : . <span style="color:#E76700">' . esc_html($this->getInfo()) . '</span>
135 135
                     </h5>';
136
-                $this->next();
137
-            }
138
-        }
139
-    }
136
+				$this->next();
137
+			}
138
+		}
139
+	}
140 140
 }
Please login to merge, or discard this patch.
admin_pages/transactions/templates/txn_admin_details_header.template.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -18,14 +18,14 @@
 block discarded – undo
18 18
 <div class="ee-admin-page-nav-strip-wrap">
19 19
     <div class='ee-admin-page-nav-strip'>
20 20
     <?php
21
-    echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
22
-    echo '&nbsp;' . sprintf(
23
-        /* translators: %s: transaction number */
24
-        esc_html__('Transaction # %1$s', 'event_espresso'),
25
-        esc_html($txn_nmbr['value'])
26
-    ) . '&nbsp;';
27
-    echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
28
-    ?>
21
+	echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
22
+	echo '&nbsp;' . sprintf(
23
+		/* translators: %s: transaction number */
24
+		esc_html__('Transaction # %1$s', 'event_espresso'),
25
+		esc_html($txn_nmbr['value'])
26
+	) . '&nbsp;';
27
+	echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
28
+	?>
29 29
     </div>
30 30
 </div>
31 31
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
     <div class='ee-admin-page-nav-strip'>
20 20
     <?php
21 21
     echo wp_kses($previous_transaction, AllowedTags::getAllowedTags());
22
-    echo '&nbsp;' . sprintf(
22
+    echo '&nbsp;'.sprintf(
23 23
         /* translators: %s: transaction number */
24 24
         esc_html__('Transaction # %1$s', 'event_espresso'),
25 25
         esc_html($txn_nmbr['value'])
26
-    ) . '&nbsp;';
26
+    ).'&nbsp;';
27 27
     echo wp_kses($next_transaction, AllowedTags::getAllowedTags());
28 28
     ?>
29 29
     </div>
Please login to merge, or discard this patch.
core/services/locators/FqcnLocator.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected function setNamespace(?string $namespace, ?string $namespace_base_dir)
36 36
     {
37
-        if (! is_string($namespace)) {
37
+        if ( ! is_string($namespace)) {
38 38
             throw new InvalidDataTypeException('$namespace', $namespace, 'string');
39 39
         }
40
-        if (! is_string($namespace_base_dir)) {
40
+        if ( ! is_string($namespace_base_dir)) {
41 41
             throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
42 42
         }
43
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
43
+        $this->namespaces[$namespace] = $namespace_base_dir;
44 44
     }
45 45
 
46 46
 
@@ -72,12 +72,12 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function locate($namespaces): array
74 74
     {
75
-        if (! (is_string($namespaces) || is_array($namespaces))) {
75
+        if ( ! (is_string($namespaces) || is_array($namespaces))) {
76 76
             throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
77 77
         }
78 78
         foreach ((array) $namespaces as $namespace) {
79 79
             foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
80
-                $this->FQCNs[ $key ] = $file;
80
+                $this->FQCNs[$key] = $file;
81 81
             }
82 82
         }
83 83
         return $this->FQCNs;
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
         }
107 107
         foreach ($iterator as $file) {
108 108
             if ($file->isFile() && $file->getExtension() === 'php') {
109
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
109
+                $file = $file->getPath().'/'.$file->getBasename('.php');
110 110
                 foreach ($this->namespaces as $namespace => $base_dir) {
111 111
                     $namespace .= Psr4Autoloader::NS;
112 112
                     if (strpos($file, $base_dir) === 0) {
113
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
113
+                        $this->FQCNs[] = Psr4Autoloader::NS.str_replace(
114 114
                             [$base_dir, '/'],
115 115
                             [$namespace, Psr4Autoloader::NS],
116 116
                             $file
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
         // we're only interested in the Vendor and secondary base, so pull those from the array
144 144
         $vendor_base = array_slice($namespace_segments, 0, 2);
145 145
         $namespace   = $prefix = null;
146
-        while (! empty($vendor_base)) {
146
+        while ( ! empty($vendor_base)) {
147 147
             $namespace = implode(Psr4Autoloader::NS, $vendor_base);
148 148
             // check if there's a base directory registered for that namespace
149
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
150
-            if (! empty($prefix) && ! empty($prefix[0])) {
149
+            $prefix = $psr4_loader->prefixes($namespace.Psr4Autoloader::NS);
150
+            if ( ! empty($prefix) && ! empty($prefix[0])) {
151 151
                 // found one!
152 152
                 break;
153 153
             }
@@ -160,6 +160,6 @@  discard block
 block discarded – undo
160 160
         }
161 161
         $this->setNamespace($namespace, $prefix[0]);
162 162
         // but if it's good, add that base directory to the rest of the path, and return it
163
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
163
+        return $prefix[0].implode('/', array_diff($namespace_segments, $vendor_base)).'/';
164 164
     }
165 165
 }
Please login to merge, or discard this patch.
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -18,146 +18,146 @@
 block discarded – undo
18 18
  */
19 19
 class FqcnLocator extends Locator
20 20
 {
21
-    protected array $FQCNs      = [];
22
-
23
-    protected array $namespaces = [];
24
-
25
-
26
-    /**
27
-     * @param string|null $namespace
28
-     * @param string|null $namespace_base_dir
29
-     */
30
-    protected function setNamespace(?string $namespace, ?string $namespace_base_dir)
31
-    {
32
-        if (! is_string($namespace)) {
33
-            throw new InvalidDataTypeException('$namespace', $namespace, 'string');
34
-        }
35
-        if (! is_string($namespace_base_dir)) {
36
-            throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
37
-        }
38
-        $this->namespaces[ $namespace ] = $namespace_base_dir;
39
-    }
40
-
41
-
42
-    /**
43
-     * @return array
44
-     */
45
-    public function getFQCNs(): array
46
-    {
47
-        return $this->FQCNs;
48
-    }
49
-
50
-
51
-    /**
52
-     * @return int
53
-     */
54
-    public function count(): int
55
-    {
56
-        return count($this->FQCNs);
57
-    }
58
-
59
-
60
-    /**
61
-     * given a valid namespace, will find all files that match the provided mask
62
-     *
63
-     * @param string|array $namespaces
64
-     * @return array
65
-     * @throws InvalidClassException
66
-     * @throws InvalidDataTypeException
67
-     * @throws EE_Error
68
-     */
69
-    public function locate($namespaces): array
70
-    {
71
-        if (! (is_string($namespaces) || is_array($namespaces))) {
72
-            throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
73
-        }
74
-        foreach ((array) $namespaces as $namespace) {
75
-            foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
76
-                $this->FQCNs[ $key ] = $file;
77
-            }
78
-        }
79
-        return $this->FQCNs;
80
-    }
81
-
82
-
83
-    /**
84
-     * given a partial namespace, will find all files in that folder
85
-     * ** PLZ NOTE **
86
-     * This assumes that all files within the specified folder should be loaded
87
-     *
88
-     * @param string $partial_namespace
89
-     * @return array
90
-     * @throws InvalidClassException
91
-     * @throws InvalidDataTypeException
92
-     * @throws EE_Error
93
-     */
94
-    protected function findFQCNsByNamespace(string $partial_namespace): array
95
-    {
96
-        $iterator = new FilesystemIterator(
97
-            $this->getDirectoryFromPartialNamespace($partial_namespace)
98
-        );
99
-        $iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
100
-        $iterator->setFlags(FilesystemIterator::UNIX_PATHS);
101
-        if (iterator_count($iterator) === 0) {
102
-            return [];
103
-        }
104
-        foreach ($iterator as $file) {
105
-            if ($file->isFile() && $file->getExtension() === 'php') {
106
-                $file = $file->getPath() . '/' . $file->getBasename('.php');
107
-                foreach ($this->namespaces as $namespace => $base_dir) {
108
-                    $namespace .= Psr4Autoloader::NS;
109
-                    if (strpos($file, $base_dir) === 0) {
110
-                        $this->FQCNs[] = Psr4Autoloader::NS . str_replace(
111
-                            [$base_dir, '/'],
112
-                            [$namespace, Psr4Autoloader::NS],
113
-                            $file
114
-                        );
115
-                    }
116
-                }
117
-            }
118
-        }
119
-        return $this->FQCNs;
120
-    }
121
-
122
-
123
-    /**
124
-     * getDirectoryFromPartialNamespace
125
-     *
126
-     * @param string $partial_namespace almost fully qualified class name ?
127
-     * @return string
128
-     * @throws InvalidDataTypeException
129
-     * @throws InvalidClassException
130
-     * @throws EE_Error
131
-     */
132
-    protected function getDirectoryFromPartialNamespace(string $partial_namespace): string
133
-    {
134
-        if (empty($partial_namespace)) {
135
-            throw new InvalidClassException($partial_namespace);
136
-        }
137
-        // load our PSR-4 Autoloader so we can get the list of registered namespaces from it
138
-        $psr4_loader = EE_Psr4AutoloaderInit::psr4_loader();
139
-        // breakup the incoming namespace into segments so we can loop thru them
140
-        $namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
141
-        // we're only interested in the Vendor and secondary base, so pull those from the array
142
-        $vendor_base = array_slice($namespace_segments, 0, 2);
143
-        $namespace   = $prefix = null;
144
-        while (! empty($vendor_base)) {
145
-            $namespace = implode(Psr4Autoloader::NS, $vendor_base);
146
-            // check if there's a base directory registered for that namespace
147
-            $prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
148
-            if (! empty($prefix) && ! empty($prefix[0])) {
149
-                // found one!
150
-                break;
151
-            }
152
-            // remove base and try vendor only portion of namespace
153
-            array_pop($vendor_base);
154
-        }
155
-        // nope? then the incoming namespace is invalid
156
-        if (empty($prefix) || empty($prefix[0])) {
157
-            throw new InvalidClassException($partial_namespace);
158
-        }
159
-        $this->setNamespace($namespace, $prefix[0]);
160
-        // but if it's good, add that base directory to the rest of the path, and return it
161
-        return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
162
-    }
21
+	protected array $FQCNs      = [];
22
+
23
+	protected array $namespaces = [];
24
+
25
+
26
+	/**
27
+	 * @param string|null $namespace
28
+	 * @param string|null $namespace_base_dir
29
+	 */
30
+	protected function setNamespace(?string $namespace, ?string $namespace_base_dir)
31
+	{
32
+		if (! is_string($namespace)) {
33
+			throw new InvalidDataTypeException('$namespace', $namespace, 'string');
34
+		}
35
+		if (! is_string($namespace_base_dir)) {
36
+			throw new InvalidDataTypeException('$namespace_base_dir', $namespace_base_dir, 'string');
37
+		}
38
+		$this->namespaces[ $namespace ] = $namespace_base_dir;
39
+	}
40
+
41
+
42
+	/**
43
+	 * @return array
44
+	 */
45
+	public function getFQCNs(): array
46
+	{
47
+		return $this->FQCNs;
48
+	}
49
+
50
+
51
+	/**
52
+	 * @return int
53
+	 */
54
+	public function count(): int
55
+	{
56
+		return count($this->FQCNs);
57
+	}
58
+
59
+
60
+	/**
61
+	 * given a valid namespace, will find all files that match the provided mask
62
+	 *
63
+	 * @param string|array $namespaces
64
+	 * @return array
65
+	 * @throws InvalidClassException
66
+	 * @throws InvalidDataTypeException
67
+	 * @throws EE_Error
68
+	 */
69
+	public function locate($namespaces): array
70
+	{
71
+		if (! (is_string($namespaces) || is_array($namespaces))) {
72
+			throw new InvalidDataTypeException('$namespaces', $namespaces, 'string or array');
73
+		}
74
+		foreach ((array) $namespaces as $namespace) {
75
+			foreach ($this->findFQCNsByNamespace($namespace) as $key => $file) {
76
+				$this->FQCNs[ $key ] = $file;
77
+			}
78
+		}
79
+		return $this->FQCNs;
80
+	}
81
+
82
+
83
+	/**
84
+	 * given a partial namespace, will find all files in that folder
85
+	 * ** PLZ NOTE **
86
+	 * This assumes that all files within the specified folder should be loaded
87
+	 *
88
+	 * @param string $partial_namespace
89
+	 * @return array
90
+	 * @throws InvalidClassException
91
+	 * @throws InvalidDataTypeException
92
+	 * @throws EE_Error
93
+	 */
94
+	protected function findFQCNsByNamespace(string $partial_namespace): array
95
+	{
96
+		$iterator = new FilesystemIterator(
97
+			$this->getDirectoryFromPartialNamespace($partial_namespace)
98
+		);
99
+		$iterator->setFlags(FilesystemIterator::CURRENT_AS_FILEINFO);
100
+		$iterator->setFlags(FilesystemIterator::UNIX_PATHS);
101
+		if (iterator_count($iterator) === 0) {
102
+			return [];
103
+		}
104
+		foreach ($iterator as $file) {
105
+			if ($file->isFile() && $file->getExtension() === 'php') {
106
+				$file = $file->getPath() . '/' . $file->getBasename('.php');
107
+				foreach ($this->namespaces as $namespace => $base_dir) {
108
+					$namespace .= Psr4Autoloader::NS;
109
+					if (strpos($file, $base_dir) === 0) {
110
+						$this->FQCNs[] = Psr4Autoloader::NS . str_replace(
111
+							[$base_dir, '/'],
112
+							[$namespace, Psr4Autoloader::NS],
113
+							$file
114
+						);
115
+					}
116
+				}
117
+			}
118
+		}
119
+		return $this->FQCNs;
120
+	}
121
+
122
+
123
+	/**
124
+	 * getDirectoryFromPartialNamespace
125
+	 *
126
+	 * @param string $partial_namespace almost fully qualified class name ?
127
+	 * @return string
128
+	 * @throws InvalidDataTypeException
129
+	 * @throws InvalidClassException
130
+	 * @throws EE_Error
131
+	 */
132
+	protected function getDirectoryFromPartialNamespace(string $partial_namespace): string
133
+	{
134
+		if (empty($partial_namespace)) {
135
+			throw new InvalidClassException($partial_namespace);
136
+		}
137
+		// load our PSR-4 Autoloader so we can get the list of registered namespaces from it
138
+		$psr4_loader = EE_Psr4AutoloaderInit::psr4_loader();
139
+		// breakup the incoming namespace into segments so we can loop thru them
140
+		$namespace_segments = explode(Psr4Autoloader::NS, trim($partial_namespace, Psr4Autoloader::NS));
141
+		// we're only interested in the Vendor and secondary base, so pull those from the array
142
+		$vendor_base = array_slice($namespace_segments, 0, 2);
143
+		$namespace   = $prefix = null;
144
+		while (! empty($vendor_base)) {
145
+			$namespace = implode(Psr4Autoloader::NS, $vendor_base);
146
+			// check if there's a base directory registered for that namespace
147
+			$prefix = $psr4_loader->prefixes($namespace . Psr4Autoloader::NS);
148
+			if (! empty($prefix) && ! empty($prefix[0])) {
149
+				// found one!
150
+				break;
151
+			}
152
+			// remove base and try vendor only portion of namespace
153
+			array_pop($vendor_base);
154
+		}
155
+		// nope? then the incoming namespace is invalid
156
+		if (empty($prefix) || empty($prefix[0])) {
157
+			throw new InvalidClassException($partial_namespace);
158
+		}
159
+		$this->setNamespace($namespace, $prefix[0]);
160
+		// but if it's good, add that base directory to the rest of the path, and return it
161
+		return $prefix[0] . implode('/', array_diff($namespace_segments, $vendor_base)) . '/';
162
+	}
163 163
 }
Please login to merge, or discard this patch.
events_archive_caff/templates/admin-event-list-settings.template.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
             </label>
57 57
         </th>
58 58
         <td>
59
-            <span class="base-url"><?php echo site_url() . '/ ';?></span>
59
+            <span class="base-url"><?php echo site_url().'/ '; ?></span>
60 60
             <?php echo EEH_Form_Fields::text(
61 61
                 'not_used',
62 62
                 EE_Registry::instance()->CFG->core->event_cpt_slug,
Please login to merge, or discard this patch.
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
 add_filter('FHEE__EEH_Form_Fields__label_html', '__return_empty_string');
24 24
 
25 25
 $values = EEH_Form_Fields::prep_answer_options(
26
-    array(
27
-        array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
28
-        array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
29
-    )
26
+	array(
27
+		array('id' => 1, 'text' => esc_html__('Yes', 'event_espresso')),
28
+		array('id' => 0, 'text' => esc_html__('No', 'event_espresso')),
29
+	)
30 30
 );
31 31
 
32 32
 $description = EEH_Form_Fields::prep_answer_options(
33
-    array(
34
-        array('id' => 0, 'text' => esc_html__('none', 'event_espresso')),
35
-        array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')),
36
-        array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')),
37
-    )
33
+	array(
34
+		array('id' => 0, 'text' => esc_html__('none', 'event_espresso')),
35
+		array('id' => 1, 'text' => esc_html__('excerpt (short desc)', 'event_espresso')),
36
+		array('id' => 2, 'text' => esc_html__('full description', 'event_espresso')),
37
+	)
38 38
 );
39 39
 
40 40
 ?>
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
         <th>
54 54
             <label for="event_listings_url">
55 55
                 <?php esc_html_e('Events List URL', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
56
-                    'event_listings_url_info'
57
-                ); ?>
56
+					'event_listings_url_info'
57
+				); ?>
58 58
             </label>
59 59
         </th>
60 60
         <td>
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
                 <span class="dashicons dashicons-external"></span>
64 64
             </a>
65 65
             <p class="description"><?php
66
-                esc_html_e(
67
-                    'This is the URL where all events will be displayed.  You can change the slug below.',
68
-                    'event_espresso'
69
-                ); ?></p>
66
+				esc_html_e(
67
+					'This is the URL where all events will be displayed.  You can change the slug below.',
68
+					'event_espresso'
69
+				); ?></p>
70 70
         </td>
71 71
     </tr>
72 72
 
@@ -79,29 +79,29 @@  discard block
 block discarded – undo
79 79
         <td>
80 80
             <span class="base-url"><?php echo site_url() . '/ ';?></span>
81 81
             <?php echo EEH_Form_Fields::text(
82
-                'not_used',
83
-                EE_Registry::instance()->CFG->core->event_cpt_slug,
84
-                'event_cpt_slug',
85
-                'event_cpt_slug',
86
-                'regular'
87
-            ); ?>
82
+				'not_used',
83
+				EE_Registry::instance()->CFG->core->event_cpt_slug,
84
+				'event_cpt_slug',
85
+				'event_cpt_slug',
86
+				'regular'
87
+			); ?>
88 88
             <p class="description"><?php
89
-                esc_html_e(
90
-                    'This allows you to configure what slug is used for the url of all event pages.',
91
-                    'event_espresso'
92
-                ); ?></p>
89
+				esc_html_e(
90
+					'This allows you to configure what slug is used for the url of all event pages.',
91
+					'event_espresso'
92
+				); ?></p>
93 93
             <?php if (has_filter('FHEE__EE_Register_CPTs__register_CPT__rewrite')) : ?>
94 94
                 <p class="important-notice">
95 95
                     <?php
96
-                    sprintf(
97
-                        esc_html__(
98
-                            'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected.  Please be aware that while this filter is being used, this setting has no affect.',
99
-                            'event_espresso'
100
-                        ),
101
-                        '<code>',
102
-                        '</code>'
103
-                    );
104
-                    ?>
96
+					sprintf(
97
+						esc_html__(
98
+							'Usage of the %1$s FHEE__EE_Register_CPTs__register_CPT__rewrite %2$s filter has been detected.  Please be aware that while this filter is being used, this setting has no affect.',
99
+							'event_espresso'
100
+						),
101
+						'<code>',
102
+						'</code>'
103
+					);
104
+					?>
105 105
                 </p>
106 106
             <?php endif; ?>
107 107
         </td>
@@ -115,20 +115,20 @@  discard block
 block discarded – undo
115 115
         </th>
116 116
         <td>
117 117
             <?php echo wp_kses(
118
-                EEH_Form_Fields::select(
119
-                    'display_status_banner',
120
-                    (int) $display_status_banner,
121
-                    $values,
122
-                    'EED_Events_Archive_display_status_banner',
123
-                    'EED_Events_Archive_display_status_banner'
124
-                ),
125
-                AllowedTags::getWithFormTags()
126
-            ); ?>
118
+				EEH_Form_Fields::select(
119
+					'display_status_banner',
120
+					(int) $display_status_banner,
121
+					$values,
122
+					'EED_Events_Archive_display_status_banner',
123
+					'EED_Events_Archive_display_status_banner'
124
+				),
125
+				AllowedTags::getWithFormTags()
126
+			); ?>
127 127
             <p class="description"><?php
128
-                esc_html_e(
129
-                    'Whether the status banner should be shown on the events list page next to the Event title.  The status banner is the banner that shows the status of the event (e.g. "Upcoming", "Expired", etc.).',
130
-                    'event_espresso'
131
-                ); ?></p>
128
+				esc_html_e(
129
+					'Whether the status banner should be shown on the events list page next to the Event title.  The status banner is the banner that shows the status of the event (e.g. "Upcoming", "Expired", etc.).',
130
+					'event_espresso'
131
+				); ?></p>
132 132
         </td>
133 133
     </tr>
134 134
 
@@ -136,26 +136,26 @@  discard block
 block discarded – undo
136 136
         <th>
137 137
             <label for="EED_Events_Archive_display_description">
138 138
                 <?php esc_html_e('Display Description', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
139
-                    'display_description_info'
140
-                ); ?>
139
+					'display_description_info'
140
+				); ?>
141 141
             </label>
142 142
         </th>
143 143
         <td>
144 144
             <?php echo wp_kses(
145
-                EEH_Form_Fields::select(
146
-                    'description',
147
-                    (int) $display_description,
148
-                    $description,
149
-                    'EED_Events_Archive_display_description',
150
-                    'EED_Events_Archive_display_description'
151
-                ),
152
-                AllowedTags::getWithFormTags()
153
-            ); ?>
145
+				EEH_Form_Fields::select(
146
+					'description',
147
+					(int) $display_description,
148
+					$description,
149
+					'EED_Events_Archive_display_description',
150
+					'EED_Events_Archive_display_description'
151
+				),
152
+				AllowedTags::getWithFormTags()
153
+			); ?>
154 154
             <p class="description"><?php
155
-                esc_html_e(
156
-                    'Whether the event description should be shown on the events list page.  If you choose "none" then the description will not be shown.  If you choose "excerpt" then the short description will be shown.  If you choose "full description" then the full description will be shown.',
157
-                    'event_espresso'
158
-                ); ?></p>
155
+				esc_html_e(
156
+					'Whether the event description should be shown on the events list page.  If you choose "none" then the description will not be shown.  If you choose "excerpt" then the short description will be shown.  If you choose "full description" then the full description will be shown.',
157
+					'event_espresso'
158
+				); ?></p>
159 159
         </td>
160 160
     </tr>
161 161
 
@@ -163,26 +163,26 @@  discard block
 block discarded – undo
163 163
         <th>
164 164
             <label for="EED_Events_Archive_display_ticket_selector">
165 165
                 <?php esc_html_e('Display Ticket Selector', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
166
-                    'display_ticket_selector_info'
167
-                ); ?>
166
+					'display_ticket_selector_info'
167
+				); ?>
168 168
             </label>
169 169
         </th>
170 170
         <td>
171 171
             <?php echo wp_kses(
172
-                EEH_Form_Fields::select(
173
-                    'ticket_selector',
174
-                    (int) $display_ticket_selector,
175
-                    $values,
176
-                    'EED_Events_Archive_display_ticket_selector',
177
-                    'EED_Events_Archive_display_ticket_selector'
178
-                ),
179
-                AllowedTags::getWithFormTags()
180
-            ); ?>
172
+				EEH_Form_Fields::select(
173
+					'ticket_selector',
174
+					(int) $display_ticket_selector,
175
+					$values,
176
+					'EED_Events_Archive_display_ticket_selector',
177
+					'EED_Events_Archive_display_ticket_selector'
178
+				),
179
+				AllowedTags::getWithFormTags()
180
+			); ?>
181 181
             <p class="description"><?php
182
-                esc_html_e(
183
-                    'Whether the ticket selector should be shown on the events list page.',
184
-                    'event_espresso'
185
-                ); ?></p>
182
+				esc_html_e(
183
+					'Whether the ticket selector should be shown on the events list page.',
184
+					'event_espresso'
185
+				); ?></p>
186 186
         </td>
187 187
     </tr>
188 188
 
@@ -190,26 +190,26 @@  discard block
 block discarded – undo
190 190
         <th>
191 191
             <label for="EED_Events_Archive_display_datetimes">
192 192
                 <?php esc_html_e('Display Datetimes', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
193
-                    'display_datetimes_info'
194
-                ); ?>
193
+					'display_datetimes_info'
194
+				); ?>
195 195
             </label>
196 196
         </th>
197 197
         <td>
198 198
             <?php echo wp_kses(
199
-                EEH_Form_Fields::select(
200
-                    'venue_details',
201
-                    (int) $display_datetimes,
202
-                    $values,
203
-                    'EED_Events_Archive_display_datetimes',
204
-                    'EED_Events_Archive_display_datetimes'
205
-                ),
206
-                AllowedTags::getWithFormTags()
207
-            ); ?>
199
+				EEH_Form_Fields::select(
200
+					'venue_details',
201
+					(int) $display_datetimes,
202
+					$values,
203
+					'EED_Events_Archive_display_datetimes',
204
+					'EED_Events_Archive_display_datetimes'
205
+				),
206
+				AllowedTags::getWithFormTags()
207
+			); ?>
208 208
             <p class="description"><?php
209
-                esc_html_e(
210
-                    'Whether the date and time details should be shown on the events list page.',
211
-                    'event_espresso'
212
-                ); ?></p>
209
+				esc_html_e(
210
+					'Whether the date and time details should be shown on the events list page.',
211
+					'event_espresso'
212
+				); ?></p>
213 213
         </td>
214 214
     </tr>
215 215
 
@@ -217,26 +217,26 @@  discard block
 block discarded – undo
217 217
         <th>
218 218
             <label for="EED_Events_Archive_display_venue">
219 219
                 <?php esc_html_e('Display Venue Details', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
220
-                    'display_venue_details_info'
221
-                ); ?>
220
+					'display_venue_details_info'
221
+				); ?>
222 222
             </label>
223 223
         </th>
224 224
         <td>
225 225
             <?php echo wp_kses(
226
-                EEH_Form_Fields::select(
227
-                    'display_venue',
228
-                    (int) $display_venue,
229
-                    $values,
230
-                    'EED_Events_Archive_display_venue',
231
-                    'EED_Events_Archive_display_venue'
232
-                ),
233
-                AllowedTags::getWithFormTags()
234
-            ); ?>
226
+				EEH_Form_Fields::select(
227
+					'display_venue',
228
+					(int) $display_venue,
229
+					$values,
230
+					'EED_Events_Archive_display_venue',
231
+					'EED_Events_Archive_display_venue'
232
+				),
233
+				AllowedTags::getWithFormTags()
234
+			); ?>
235 235
             <p class="description"><?php
236
-                esc_html_e(
237
-                    'Whether the venue details should be shown on the events list page.',
238
-                    'event_espresso'
239
-                ); ?></p>
236
+				esc_html_e(
237
+					'Whether the venue details should be shown on the events list page.',
238
+					'event_espresso'
239
+				); ?></p>
240 240
         </td>
241 241
     </tr>
242 242
 
@@ -244,26 +244,26 @@  discard block
 block discarded – undo
244 244
         <th>
245 245
             <label for="EED_Events_Archive_display_expired_events">
246 246
                 <?php esc_html_e('Display Expired Events', 'event_espresso'); ?><?php echo EEH_Template::get_help_tab_link(
247
-                    'display_expired_events_info'
248
-                ); ?>
247
+					'display_expired_events_info'
248
+				); ?>
249 249
             </label>
250 250
         </th>
251 251
         <td>
252 252
             <?php echo wp_kses(
253
-                EEH_Form_Fields::select(
254
-                    'expired_events',
255
-                    (int) $display_expired_events,
256
-                    $values,
257
-                    'EED_Events_Archive_display_expired_events',
258
-                    'EED_Events_Archive_display_expired_events'
259
-                ),
260
-                AllowedTags::getWithFormTags()
261
-            ); ?>
253
+				EEH_Form_Fields::select(
254
+					'expired_events',
255
+					(int) $display_expired_events,
256
+					$values,
257
+					'EED_Events_Archive_display_expired_events',
258
+					'EED_Events_Archive_display_expired_events'
259
+				),
260
+				AllowedTags::getWithFormTags()
261
+			); ?>
262 262
             <p class="description"><?php
263
-                esc_html_e(
264
-                    'Whether expired events should be shown on the events list page.',
265
-                    'event_espresso'
266
-                ); ?></p>
263
+				esc_html_e(
264
+					'Whether expired events should be shown on the events list page.',
265
+					'event_espresso'
266
+				); ?></p>
267 267
         </td>
268 268
     </tr>
269 269
 
@@ -275,20 +275,20 @@  discard block
 block discarded – undo
275 275
         </th>
276 276
         <td>
277 277
             <?php echo wp_kses(
278
-                EEH_Form_Fields::select(
279
-                    'expired_tickets',
280
-                    (int) $display_events_with_expired_tickets,
281
-                    $values,
282
-                    'EED_Events_Archive_display_events_with_expired_tickets',
283
-                    'EED_Events_Archive_display_events_with_expired_tickets'
284
-                ),
285
-                AllowedTags::getWithFormTags()
286
-            ); ?>
278
+				EEH_Form_Fields::select(
279
+					'expired_tickets',
280
+					(int) $display_events_with_expired_tickets,
281
+					$values,
282
+					'EED_Events_Archive_display_events_with_expired_tickets',
283
+					'EED_Events_Archive_display_events_with_expired_tickets'
284
+				),
285
+				AllowedTags::getWithFormTags()
286
+			); ?>
287 287
             <p class="description">
288 288
                 <?php esc_html_e(
289
-                    'Whether events where ALL tickets are expired should be shown on the events list page.',
290
-                    'event_espresso'
291
-                ); ?>
289
+					'Whether events where ALL tickets are expired should be shown on the events list page.',
290
+					'event_espresso'
291
+				); ?>
292 292
             </p>
293 293
             <span class="ee-feature-highlight-2024-notice">
294 294
                 ✨ <?php esc_html_e('NEW', 'event_espresso'); ?>
@@ -300,51 +300,51 @@  discard block
 block discarded – undo
300 300
         <th>
301 301
             <label for="EED_Events_Archive_use_sortable_display_order">
302 302
                 <?php esc_html_e(
303
-                    'Use Custom Display Order?',
304
-                    'event_espresso'
305
-                ); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?>
303
+					'Use Custom Display Order?',
304
+					'event_espresso'
305
+				); ?><?php // echo EEH_Template::get_help_tab_link('use_sortable_display_order_info');?>
306 306
             </label>
307 307
         </th>
308 308
         <td>
309 309
             <?php echo wp_kses(
310
-                EEH_Form_Fields::select(
311
-                    'use_sortable_display_order',
312
-                    (int) $use_sortable_display_order,
313
-                    $values,
314
-                    'EED_Events_Archive_use_sortable_display_order',
315
-                    'EED_Events_Archive_use_sortable_display_order'
316
-                ),
317
-                AllowedTags::getWithFormTags()
318
-            ); ?>
310
+				EEH_Form_Fields::select(
311
+					'use_sortable_display_order',
312
+					(int) $use_sortable_display_order,
313
+					$values,
314
+					'EED_Events_Archive_use_sortable_display_order',
315
+					'EED_Events_Archive_use_sortable_display_order'
316
+				),
317
+				AllowedTags::getWithFormTags()
318
+			); ?>
319 319
             <p class="description"><?php
320
-                esc_html_e(
321
-                    'Selecting "Yes" will allow you to drag and drop the order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
322
-                    'event_espresso'
323
-                ); ?></p>
320
+				esc_html_e(
321
+					'Selecting "Yes" will allow you to drag and drop the order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
322
+					'event_espresso'
323
+				); ?></p>
324 324
         </td>
325 325
     </tr>
326 326
 
327 327
     <tr>
328 328
         <th>
329 329
             <?php esc_html_e(
330
-                'Display Order',
331
-                'event_espresso'
332
-            ); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?>
330
+				'Display Order',
331
+				'event_espresso'
332
+			); ?><?php // echo EEH_Template::get_help_tab_link( 'event_archive_order_info' ); ?>
333 333
         </th>
334 334
         <td>
335 335
 
336 336
             <?php wp_nonce_field(
337
-                'espresso_update_event_archive_order',
338
-                'espresso_update_event_archive_order_nonce',
339
-                false
340
-            ); ?>
337
+				'espresso_update_event_archive_order',
338
+				'espresso_update_event_archive_order_nonce',
339
+				false
340
+			); ?>
341 341
             <?php echo wp_kses($event_archive_display_order, AllowedTags::getWithFormTags()); ?>
342 342
 
343 343
             <p class="description"><?php
344
-                esc_html_e(
345
-                    'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
346
-                    'event_espresso'
347
-                ); ?></p>
344
+				esc_html_e(
345
+					'Drag and Drop the above to determine the display order of the Event Description, Date and Times, Ticket Selector, and Venue Information on the event archive page.',
346
+					'event_espresso'
347
+				); ?></p>
348 348
 
349 349
         </td>
350 350
     </tr>
@@ -357,20 +357,20 @@  discard block
 block discarded – undo
357 357
         </th>
358 358
         <td>
359 359
             <?php echo wp_kses(
360
-                EEH_Form_Fields::select(
361
-                    'reset_event_list_settings',
362
-                    0,
363
-                    $values,
364
-                    'EED_Events_Archive_reset_event_list_settings',
365
-                    'EED_Events_Archive_reset_event_list_settings'
366
-                ),
367
-                AllowedTags::getWithFormTags()
368
-            ); ?>
360
+				EEH_Form_Fields::select(
361
+					'reset_event_list_settings',
362
+					0,
363
+					$values,
364
+					'EED_Events_Archive_reset_event_list_settings',
365
+					'EED_Events_Archive_reset_event_list_settings'
366
+				),
367
+				AllowedTags::getWithFormTags()
368
+			); ?>
369 369
             <p class="description"><?php
370
-                esc_html_e(
371
-                    'Selecting "Yes" will reset the Event List Settings to their default values.',
372
-                    'event_espresso'
373
-                ); ?></p>
370
+				esc_html_e(
371
+					'Selecting "Yes" will reset the Event List Settings to their default values.',
372
+					'event_espresso'
373
+				); ?></p>
374 374
         </td>
375 375
     </tr>
376 376
 
Please login to merge, or discard this patch.
core/admin/templates/admin_wrapper.template.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
     <?php echo wp_kses($nav_tabs, AllowedTags::getWithFormTags()); ?>
22 22
 
23 23
     <?php
24
-    do_action('AHEE__admin_wrapper__template__before_admin_page_content');
25
-    echo wp_kses($before_admin_page_content, AllowedTags::getWithFormTags());
26
-    echo wp_kses($admin_page_content, AllowedTags::getWithFullTags());
27
-    echo wp_kses($after_admin_page_content, AllowedTags::getWithFormTags());
28
-    do_action('AHEE__admin_wrapper__template__after_admin_page_content');
29
-    ?>
24
+	do_action('AHEE__admin_wrapper__template__before_admin_page_content');
25
+	echo wp_kses($before_admin_page_content, AllowedTags::getWithFormTags());
26
+	echo wp_kses($admin_page_content, AllowedTags::getWithFullTags());
27
+	echo wp_kses($after_admin_page_content, AllowedTags::getWithFormTags());
28
+	do_action('AHEE__admin_wrapper__template__after_admin_page_content');
29
+	?>
30 30
 
31 31
 </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 <div class="wrap espresso-admin">
16 16
 
17 17
     <h1>
18
-        <?php echo esc_html__('Event Espresso', 'event_espresso') . ' ' . wp_kses($admin_page_title, AllowedTags::getWithFormTags()); ?>
18
+        <?php echo esc_html__('Event Espresso', 'event_espresso').' '.wp_kses($admin_page_title, AllowedTags::getWithFormTags()); ?>
19 19
     </h1>
20 20
 
21 21
     <div id="ajax-notices-container"></div>
Please login to merge, or discard this patch.
core/db_classes/EE_Datetime.class.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             $date_or_time,
533 533
             $echo
534 534
         );
535
-        if (! $echo) {
535
+        if ( ! $echo) {
536 536
             return $dtt;
537 537
         }
538 538
         return '';
@@ -629,12 +629,12 @@  discard block
 block discarded – undo
629 629
             '&nbsp;',
630 630
             $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)
631 631
         );
632
-        $end     = str_replace(
632
+        $end = str_replace(
633 633
             ' ',
634 634
             '&nbsp;',
635 635
             $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
636 636
         );
637
-        return $start !== $end ? $start . $conjunction . $end : $start;
637
+        return $start !== $end ? $start.$conjunction.$end : $start;
638 638
     }
639 639
 
640 640
 
@@ -737,12 +737,12 @@  discard block
 block discarded – undo
737 737
             '&nbsp;',
738 738
             $this->get_i18n_datetime('DTT_EVT_start', $tm_format)
739 739
         );
740
-        $end       = str_replace(
740
+        $end = str_replace(
741 741
             ' ',
742 742
             '&nbsp;',
743 743
             $this->get_i18n_datetime('DTT_EVT_end', $tm_format)
744 744
         );
745
-        return $start !== $end ? $start . $conjunction . $end : $start;
745
+        return $start !== $end ? $start.$conjunction.$end : $start;
746 746
     }
747 747
 
748 748
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
     ) {
788 788
         $dt_format   = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
789 789
         $tm_format   = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
790
-        $full_format = $dt_format . $separator . $tm_format;
790
+        $full_format = $dt_format.$separator.$tm_format;
791 791
         // the range output depends on various conditions
792 792
         switch (true) {
793 793
             // start date timestamp and end date timestamp are the same.
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
         // tickets remaining available for purchase
1029 1029
         // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1030 1030
         $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1031
-        if (! $consider_tickets) {
1031
+        if ( ! $consider_tickets) {
1032 1032
             return $dtt_remaining;
1033 1033
         }
1034 1034
         $tickets_remaining = $this->tickets_remaining();
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
     {
1054 1054
         $sum     = 0;
1055 1055
         $tickets = $this->tickets($query_params);
1056
-        if (! empty($tickets)) {
1056
+        if ( ! empty($tickets)) {
1057 1057
             foreach ($tickets as $ticket) {
1058 1058
                 if ($ticket instanceof EE_Ticket) {
1059 1059
                     // get the actual amount of tickets that can be sold
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
     {
1206 1206
         if ($use_dtt_name) {
1207 1207
             $dtt_name = $this->name();
1208
-            if (! empty($dtt_name)) {
1208
+            if ( ! empty($dtt_name)) {
1209 1209
                 return $dtt_name;
1210 1210
             }
1211 1211
         }
@@ -1213,14 +1213,14 @@  discard block
 block discarded – undo
1213 1213
         if (
1214 1214
             date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1215 1215
         ) {
1216
-            $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1216
+            $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a');
1217 1217
             // next condition is if its the same month but different day
1218 1218
         } else {
1219 1219
             if (
1220 1220
                 date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1221 1221
                 && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1222 1222
             ) {
1223
-                $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1223
+                $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y');
1224 1224
             } else {
1225 1225
                 $display_date = $this->start_date('F j\, Y')
1226 1226
                                 . ' @ '
Please login to merge, or discard this patch.
Indentation   +1568 added lines, -1568 removed lines patch added patch discarded remove patch
@@ -13,1576 +13,1576 @@
 block discarded – undo
13 13
  */
14 14
 class EE_Datetime extends EE_Soft_Delete_Base_Class
15 15
 {
16
-    /**
17
-     * constant used by get_active_status, indicates datetime has no more available spaces
18
-     */
19
-    const sold_out = 'DTS';
20
-
21
-    /**
22
-     * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for)
23
-     */
24
-    const active = 'DTA';
25
-
26
-    /**
27
-     * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not
28
-     * expired
29
-     */
30
-    const upcoming = 'DTU';
31
-
32
-    /**
33
-     * Datetime is postponed
34
-     */
35
-    const postponed = 'DTP';
36
-
37
-    /**
38
-     * Datetime is cancelled
39
-     */
40
-    const cancelled = 'DTC';
41
-
42
-    /**
43
-     * constant used by get_active_status, indicates datetime has expired (event is over)
44
-     */
45
-    const expired = 'DTE';
46
-
47
-    /**
48
-     * constant used in various places indicating that an event is INACTIVE (not yet ready to be published)
49
-     */
50
-    const inactive = 'DTI';
51
-
52
-
53
-    /**
54
-     * @param array  $props_n_values    incoming values
55
-     * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
56
-     * @param array  $date_formats      incoming date_formats in an array where the first value is the date_format
57
-     *                                  and the second value is the time format
58
-     * @return EE_Datetime
59
-     * @throws ReflectionException
60
-     * @throws InvalidArgumentException
61
-     * @throws InvalidInterfaceException
62
-     * @throws InvalidDataTypeException
63
-     * @throws EE_Error
64
-     */
65
-    public static function new_instance($props_n_values = [], $timezone = '', $date_formats = [])
66
-    {
67
-        $has_object = parent::_check_for_object(
68
-            $props_n_values,
69
-            __CLASS__,
70
-            $timezone,
71
-            $date_formats
72
-        );
73
-        return $has_object
74
-            ? $has_object
75
-            : new self($props_n_values, false, $timezone, $date_formats);
76
-    }
77
-
78
-
79
-    /**
80
-     * @param array  $props_n_values  incoming values from the database
81
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
-     *                                the website will be used.
83
-     * @return EE_Datetime
84
-     * @throws ReflectionException
85
-     * @throws InvalidArgumentException
86
-     * @throws InvalidInterfaceException
87
-     * @throws InvalidDataTypeException
88
-     * @throws EE_Error
89
-     */
90
-    public static function new_instance_from_db($props_n_values = [], $timezone = '')
91
-    {
92
-        return new self($props_n_values, true, $timezone);
93
-    }
94
-
95
-
96
-    /**
97
-     * @param $name
98
-     * @throws ReflectionException
99
-     * @throws InvalidArgumentException
100
-     * @throws InvalidInterfaceException
101
-     * @throws InvalidDataTypeException
102
-     * @throws EE_Error
103
-     */
104
-    public function set_name($name)
105
-    {
106
-        $this->set('DTT_name', $name);
107
-    }
108
-
109
-
110
-    /**
111
-     * @param $description
112
-     * @throws ReflectionException
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws EE_Error
117
-     */
118
-    public function set_description($description)
119
-    {
120
-        $this->set('DTT_description', $description);
121
-    }
122
-
123
-
124
-    /**
125
-     * Set event start date
126
-     * set the start date for an event
127
-     *
128
-     * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
129
-     * @throws ReflectionException
130
-     * @throws InvalidArgumentException
131
-     * @throws InvalidInterfaceException
132
-     * @throws InvalidDataTypeException
133
-     * @throws EE_Error
134
-     */
135
-    public function set_start_date($date)
136
-    {
137
-        $this->_set_date_for($date, 'DTT_EVT_start');
138
-    }
139
-
140
-
141
-    /**
142
-     * Set event start time
143
-     * set the start time for an event
144
-     *
145
-     * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
146
-     * @throws ReflectionException
147
-     * @throws InvalidArgumentException
148
-     * @throws InvalidInterfaceException
149
-     * @throws InvalidDataTypeException
150
-     * @throws EE_Error
151
-     */
152
-    public function set_start_time($time)
153
-    {
154
-        $this->_set_time_for($time, 'DTT_EVT_start');
155
-    }
156
-
157
-
158
-    /**
159
-     * Set event end date
160
-     * set the end date for an event
161
-     *
162
-     * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
163
-     * @throws ReflectionException
164
-     * @throws InvalidArgumentException
165
-     * @throws InvalidInterfaceException
166
-     * @throws InvalidDataTypeException
167
-     * @throws EE_Error
168
-     */
169
-    public function set_end_date($date)
170
-    {
171
-        $this->_set_date_for($date, 'DTT_EVT_end');
172
-    }
173
-
174
-
175
-    /**
176
-     * Set event end time
177
-     * set the end time for an event
178
-     *
179
-     * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
180
-     * @throws ReflectionException
181
-     * @throws InvalidArgumentException
182
-     * @throws InvalidInterfaceException
183
-     * @throws InvalidDataTypeException
184
-     * @throws EE_Error
185
-     */
186
-    public function set_end_time($time)
187
-    {
188
-        $this->_set_time_for($time, 'DTT_EVT_end');
189
-    }
190
-
191
-
192
-    /**
193
-     * Set registration limit
194
-     * set the maximum number of attendees that can be registered for this datetime slot
195
-     *
196
-     * @param int|float $reg_limit
197
-     * @throws ReflectionException
198
-     * @throws InvalidArgumentException
199
-     * @throws InvalidInterfaceException
200
-     * @throws InvalidDataTypeException
201
-     * @throws EE_Error
202
-     */
203
-    public function set_reg_limit($reg_limit)
204
-    {
205
-        $this->set('DTT_reg_limit', $reg_limit);
206
-    }
207
-
208
-
209
-    /**
210
-     * get the number of tickets sold for this datetime slot
211
-     *
212
-     * @return mixed int on success, FALSE on fail
213
-     * @throws ReflectionException
214
-     * @throws InvalidArgumentException
215
-     * @throws InvalidInterfaceException
216
-     * @throws InvalidDataTypeException
217
-     * @throws EE_Error
218
-     */
219
-    public function sold()
220
-    {
221
-        return $this->get_raw('DTT_sold');
222
-    }
223
-
224
-
225
-    /**
226
-     * @param int $sold
227
-     * @throws ReflectionException
228
-     * @throws InvalidArgumentException
229
-     * @throws InvalidInterfaceException
230
-     * @throws InvalidDataTypeException
231
-     * @throws EE_Error
232
-     */
233
-    public function set_sold($sold)
234
-    {
235
-        // sold can not go below zero
236
-        $sold = max(0, $sold);
237
-        $this->set('DTT_sold', $sold);
238
-    }
239
-
240
-
241
-    /**
242
-     * Increments sold by amount passed by $qty, and persists it immediately to the database.
243
-     * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false.
244
-     *
245
-     * @param int     $qty
246
-     * @param boolean $also_decrease_reserved
247
-     * @return boolean indicating success
248
-     * @throws ReflectionException
249
-     * @throws InvalidArgumentException
250
-     * @throws InvalidInterfaceException
251
-     * @throws InvalidDataTypeException
252
-     * @throws EE_Error
253
-     */
254
-    public function increaseSold(int $qty = 1, bool $also_decrease_reserved = true): bool
255
-    {
256
-        $qty = absint($qty);
257
-        if ($also_decrease_reserved) {
258
-            $success = $this->adjustNumericFieldsInDb(
259
-                [
260
-                    'DTT_reserved' => $qty * -1,
261
-                    'DTT_sold'     => $qty,
262
-                ]
263
-            );
264
-        } else {
265
-            $success = $this->adjustNumericFieldsInDb(
266
-                [
267
-                    'DTT_sold' => $qty,
268
-                ]
269
-            );
270
-        }
271
-
272
-        do_action(
273
-            'AHEE__EE_Datetime__increase_sold',
274
-            $this,
275
-            $qty,
276
-            $this->sold(),
277
-            $success
278
-        );
279
-        return $success;
280
-    }
281
-
282
-
283
-    /**
284
-     * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
285
-     * to save afterwards.)
286
-     *
287
-     * @param int $qty
288
-     * @return boolean indicating success
289
-     * @throws ReflectionException
290
-     * @throws InvalidArgumentException
291
-     * @throws InvalidInterfaceException
292
-     * @throws InvalidDataTypeException
293
-     * @throws EE_Error
294
-     */
295
-    public function decreaseSold(int $qty = 1): bool
296
-    {
297
-        $qty     = absint($qty);
298
-        $success = $this->adjustNumericFieldsInDb(
299
-            [
300
-                'DTT_sold' => $qty * -1,
301
-            ]
302
-        );
303
-        do_action(
304
-            'AHEE__EE_Datetime__decrease_sold',
305
-            $this,
306
-            $qty,
307
-            $this->sold(),
308
-            $success
309
-        );
310
-        return $success;
311
-    }
312
-
313
-
314
-    /**
315
-     * Gets qty of reserved tickets for this datetime
316
-     *
317
-     * @return int
318
-     * @throws ReflectionException
319
-     * @throws InvalidArgumentException
320
-     * @throws InvalidInterfaceException
321
-     * @throws InvalidDataTypeException
322
-     * @throws EE_Error
323
-     */
324
-    public function reserved(): int
325
-    {
326
-        return $this->get_raw('DTT_reserved');
327
-    }
328
-
329
-
330
-    /**
331
-     * Sets qty of reserved tickets for this datetime
332
-     *
333
-     * @param int $reserved
334
-     * @throws ReflectionException
335
-     * @throws InvalidArgumentException
336
-     * @throws InvalidInterfaceException
337
-     * @throws InvalidDataTypeException
338
-     * @throws EE_Error
339
-     */
340
-    public function set_reserved(int $reserved)
341
-    {
342
-        // reserved can not go below zero
343
-        $reserved = max(0, $reserved);
344
-        $this->set('DTT_reserved', $reserved);
345
-    }
346
-
347
-
348
-    /**
349
-     * Increments reserved by amount passed by $qty, and persists it immediately to the database.
350
-     *
351
-     * @param int $qty
352
-     * @return boolean indicating success
353
-     * @throws ReflectionException
354
-     * @throws InvalidArgumentException
355
-     * @throws InvalidInterfaceException
356
-     * @throws InvalidDataTypeException
357
-     * @throws EE_Error
358
-     */
359
-    public function increaseReserved(int $qty = 1): bool
360
-    {
361
-        $qty     = absint($qty);
362
-        $success = $this->incrementFieldConditionallyInDb(
363
-            'DTT_reserved',
364
-            'DTT_sold',
365
-            'DTT_reg_limit',
366
-            $qty
367
-        );
368
-        do_action(
369
-            'AHEE__EE_Datetime__increase_reserved',
370
-            $this,
371
-            $qty,
372
-            $this->reserved(),
373
-            $success
374
-        );
375
-        return $success;
376
-    }
377
-
378
-
379
-    /**
380
-     * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
381
-     *
382
-     * @param int $qty
383
-     * @return boolean indicating success
384
-     * @throws ReflectionException
385
-     * @throws InvalidArgumentException
386
-     * @throws InvalidInterfaceException
387
-     * @throws InvalidDataTypeException
388
-     * @throws EE_Error
389
-     */
390
-    public function decreaseReserved(int $qty = 1): bool
391
-    {
392
-        $qty     = absint($qty);
393
-        $success = $this->adjustNumericFieldsInDb(
394
-            [
395
-                'DTT_reserved' => $qty * -1,
396
-            ]
397
-        );
398
-        do_action(
399
-            'AHEE__EE_Datetime__decrease_reserved',
400
-            $this,
401
-            $qty,
402
-            $this->reserved(),
403
-            $success
404
-        );
405
-        return $success;
406
-    }
407
-
408
-
409
-    /**
410
-     * total sold and reserved tickets
411
-     *
412
-     * @return int
413
-     * @throws ReflectionException
414
-     * @throws InvalidArgumentException
415
-     * @throws InvalidInterfaceException
416
-     * @throws InvalidDataTypeException
417
-     * @throws EE_Error
418
-     */
419
-    public function sold_and_reserved(): int
420
-    {
421
-        return $this->sold() + $this->reserved();
422
-    }
423
-
424
-
425
-    /**
426
-     * returns the datetime name
427
-     *
428
-     * @return string
429
-     * @throws ReflectionException
430
-     * @throws InvalidArgumentException
431
-     * @throws InvalidInterfaceException
432
-     * @throws InvalidDataTypeException
433
-     * @throws EE_Error
434
-     */
435
-    public function name(): string
436
-    {
437
-        return $this->get('DTT_name');
438
-    }
439
-
440
-
441
-    /**
442
-     * returns the datetime description
443
-     *
444
-     * @return string
445
-     * @throws ReflectionException
446
-     * @throws InvalidArgumentException
447
-     * @throws InvalidInterfaceException
448
-     * @throws InvalidDataTypeException
449
-     * @throws EE_Error
450
-     */
451
-    public function description(): string
452
-    {
453
-        return $this->get('DTT_description');
454
-    }
455
-
456
-
457
-    /**
458
-     * This helper simply returns whether the event_datetime for the current datetime is a primary datetime
459
-     *
460
-     * @return boolean  TRUE if is primary, FALSE if not.
461
-     * @throws ReflectionException
462
-     * @throws InvalidArgumentException
463
-     * @throws InvalidInterfaceException
464
-     * @throws InvalidDataTypeException
465
-     * @throws EE_Error
466
-     */
467
-    public function is_primary(): bool
468
-    {
469
-        return $this->get('DTT_is_primary');
470
-    }
471
-
472
-
473
-    /**
474
-     * This helper simply returns the order for the datetime
475
-     *
476
-     * @return int  The order of the datetime for this event.
477
-     * @throws ReflectionException
478
-     * @throws InvalidArgumentException
479
-     * @throws InvalidInterfaceException
480
-     * @throws InvalidDataTypeException
481
-     * @throws EE_Error
482
-     */
483
-    public function order(): int
484
-    {
485
-        return $this->get('DTT_order');
486
-    }
487
-
488
-
489
-    /**
490
-     * This helper simply returns the parent id for the datetime
491
-     *
492
-     * @return int
493
-     * @throws ReflectionException
494
-     * @throws InvalidArgumentException
495
-     * @throws InvalidInterfaceException
496
-     * @throws InvalidDataTypeException
497
-     * @throws EE_Error
498
-     */
499
-    public function parent(): int
500
-    {
501
-        return $this->get('DTT_parent');
502
-    }
503
-
504
-
505
-    /**
506
-     * show date and/or time
507
-     *
508
-     * @param string $date_or_time    whether to display a date or time or both
509
-     * @param string $start_or_end    whether to display start or end datetimes
510
-     * @param string $dt_frmt
511
-     * @param string $tm_frmt
512
-     * @param bool   $echo            whether we echo or return (note echoing uses "pretty" formats,
513
-     *                                otherwise we use the standard formats)
514
-     * @return string|bool  string on success, FALSE on fail
515
-     * @throws ReflectionException
516
-     * @throws InvalidArgumentException
517
-     * @throws InvalidInterfaceException
518
-     * @throws InvalidDataTypeException
519
-     * @throws EE_Error
520
-     */
521
-    private function _show_datetime(
522
-        $date_or_time = null,
523
-        $start_or_end = 'start',
524
-        $dt_frmt = '',
525
-        $tm_frmt = '',
526
-        $echo = false
527
-    ) {
528
-        $field_name = "DTT_EVT_{$start_or_end}";
529
-        $dtt        = $this->_get_datetime(
530
-            $field_name,
531
-            $dt_frmt,
532
-            $tm_frmt,
533
-            $date_or_time,
534
-            $echo
535
-        );
536
-        if (! $echo) {
537
-            return $dtt;
538
-        }
539
-        return '';
540
-    }
541
-
542
-
543
-    /**
544
-     * get event start date.  Provide either the date format, or NULL to re-use the
545
-     * last-used format, or '' to use the default date format
546
-     *
547
-     * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
548
-     * @return mixed            string on success, FALSE on fail
549
-     * @throws ReflectionException
550
-     * @throws InvalidArgumentException
551
-     * @throws InvalidInterfaceException
552
-     * @throws InvalidDataTypeException
553
-     * @throws EE_Error
554
-     */
555
-    public function start_date($dt_frmt = '')
556
-    {
557
-        return $this->_show_datetime('D', 'start', $dt_frmt);
558
-    }
559
-
560
-
561
-    /**
562
-     * Echoes start_date()
563
-     *
564
-     * @param string $dt_frmt
565
-     * @throws ReflectionException
566
-     * @throws InvalidArgumentException
567
-     * @throws InvalidInterfaceException
568
-     * @throws InvalidDataTypeException
569
-     * @throws EE_Error
570
-     */
571
-    public function e_start_date($dt_frmt = '')
572
-    {
573
-        $this->_show_datetime('D', 'start', $dt_frmt, null, true);
574
-    }
575
-
576
-
577
-    /**
578
-     * get end date. Provide either the date format, or NULL to re-use the
579
-     * last-used format, or '' to use the default date format
580
-     *
581
-     * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
582
-     * @return mixed            string on success, FALSE on fail
583
-     * @throws ReflectionException
584
-     * @throws InvalidArgumentException
585
-     * @throws InvalidInterfaceException
586
-     * @throws InvalidDataTypeException
587
-     * @throws EE_Error
588
-     */
589
-    public function end_date($dt_frmt = '')
590
-    {
591
-        return $this->_show_datetime('D', 'end', $dt_frmt);
592
-    }
593
-
594
-
595
-    /**
596
-     * Echoes the end date. See end_date()
597
-     *
598
-     * @param string $dt_frmt
599
-     * @throws ReflectionException
600
-     * @throws InvalidArgumentException
601
-     * @throws InvalidInterfaceException
602
-     * @throws InvalidDataTypeException
603
-     * @throws EE_Error
604
-     */
605
-    public function e_end_date($dt_frmt = '')
606
-    {
607
-        $this->_show_datetime('D', 'end', $dt_frmt, null, true);
608
-    }
609
-
610
-
611
-    /**
612
-     * get date_range - meaning the start AND end date
613
-     *
614
-     * @access public
615
-     * @param string $dt_frmt     string representation of date format defaults to WP settings
616
-     * @param string $conjunction conjunction junction what's your function ?
617
-     *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
618
-     * @return mixed              string on success, FALSE on fail
619
-     * @throws ReflectionException
620
-     * @throws InvalidArgumentException
621
-     * @throws InvalidInterfaceException
622
-     * @throws InvalidDataTypeException
623
-     * @throws EE_Error
624
-     */
625
-    public function date_range($dt_frmt = '', $conjunction = ' - ')
626
-    {
627
-        $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
628
-        $start   = str_replace(
629
-            ' ',
630
-            '&nbsp;',
631
-            $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)
632
-        );
633
-        $end     = str_replace(
634
-            ' ',
635
-            '&nbsp;',
636
-            $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
637
-        );
638
-        return $start !== $end ? $start . $conjunction . $end : $start;
639
-    }
640
-
641
-
642
-    /**
643
-     * @param string $dt_frmt
644
-     * @param string $conjunction
645
-     * @throws ReflectionException
646
-     * @throws InvalidArgumentException
647
-     * @throws InvalidInterfaceException
648
-     * @throws InvalidDataTypeException
649
-     * @throws EE_Error
650
-     */
651
-    public function e_date_range($dt_frmt = '', $conjunction = ' - ')
652
-    {
653
-        echo esc_html($this->date_range($dt_frmt, $conjunction));
654
-    }
655
-
656
-
657
-    /**
658
-     * get start time
659
-     *
660
-     * @param string $tm_format - string representation of time format defaults to 'g:i a'
661
-     * @return mixed        string on success, FALSE on fail
662
-     * @throws ReflectionException
663
-     * @throws InvalidArgumentException
664
-     * @throws InvalidInterfaceException
665
-     * @throws InvalidDataTypeException
666
-     * @throws EE_Error
667
-     */
668
-    public function start_time($tm_format = '')
669
-    {
670
-        return $this->_show_datetime('T', 'start', null, $tm_format);
671
-    }
672
-
673
-
674
-    /**
675
-     * @param string $tm_format
676
-     * @throws ReflectionException
677
-     * @throws InvalidArgumentException
678
-     * @throws InvalidInterfaceException
679
-     * @throws InvalidDataTypeException
680
-     * @throws EE_Error
681
-     */
682
-    public function e_start_time($tm_format = '')
683
-    {
684
-        $this->_show_datetime('T', 'start', null, $tm_format, true);
685
-    }
686
-
687
-
688
-    /**
689
-     * get end time
690
-     *
691
-     * @param string $tm_format string representation of time format defaults to 'g:i a'
692
-     * @return mixed                string on success, FALSE on fail
693
-     * @throws ReflectionException
694
-     * @throws InvalidArgumentException
695
-     * @throws InvalidInterfaceException
696
-     * @throws InvalidDataTypeException
697
-     * @throws EE_Error
698
-     */
699
-    public function end_time($tm_format = '')
700
-    {
701
-        return $this->_show_datetime('T', 'end', null, $tm_format);
702
-    }
703
-
704
-
705
-    /**
706
-     * @param string $tm_format
707
-     * @throws ReflectionException
708
-     * @throws InvalidArgumentException
709
-     * @throws InvalidInterfaceException
710
-     * @throws InvalidDataTypeException
711
-     * @throws EE_Error
712
-     */
713
-    public function e_end_time($tm_format = '')
714
-    {
715
-        $this->_show_datetime('T', 'end', null, $tm_format, true);
716
-    }
717
-
718
-
719
-    /**
720
-     * get time_range
721
-     *
722
-     * @access public
723
-     * @param string $tm_format   string representation of time format defaults to 'g:i a'
724
-     * @param string $conjunction conjunction junction what's your function ?
725
-     *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
726
-     * @return mixed              string on success, FALSE on fail
727
-     * @throws ReflectionException
728
-     * @throws InvalidArgumentException
729
-     * @throws InvalidInterfaceException
730
-     * @throws InvalidDataTypeException
731
-     * @throws EE_Error
732
-     */
733
-    public function time_range($tm_format = '', $conjunction = ' - ')
734
-    {
735
-        $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
736
-        $start     = str_replace(
737
-            ' ',
738
-            '&nbsp;',
739
-            $this->get_i18n_datetime('DTT_EVT_start', $tm_format)
740
-        );
741
-        $end       = str_replace(
742
-            ' ',
743
-            '&nbsp;',
744
-            $this->get_i18n_datetime('DTT_EVT_end', $tm_format)
745
-        );
746
-        return $start !== $end ? $start . $conjunction . $end : $start;
747
-    }
748
-
749
-
750
-    /**
751
-     * @param string $tm_format
752
-     * @param string $conjunction
753
-     * @throws ReflectionException
754
-     * @throws InvalidArgumentException
755
-     * @throws InvalidInterfaceException
756
-     * @throws InvalidDataTypeException
757
-     * @throws EE_Error
758
-     */
759
-    public function e_time_range($tm_format = '', $conjunction = ' - ')
760
-    {
761
-        echo esc_html($this->time_range($tm_format, $conjunction));
762
-    }
763
-
764
-
765
-    /**
766
-     * This returns a range representation of the date and times.
767
-     * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end.
768
-     * Also, the return value is localized.
769
-     *
770
-     * @param string $dt_format
771
-     * @param string $tm_format
772
-     * @param string $conjunction used between two different dates or times.
773
-     *                            ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm
774
-     * @param string $separator   used between the date and time formats.
775
-     *                            ex: Dec 1, 2016{$separator}2pm
776
-     * @return string
777
-     * @throws ReflectionException
778
-     * @throws InvalidArgumentException
779
-     * @throws InvalidInterfaceException
780
-     * @throws InvalidDataTypeException
781
-     * @throws EE_Error
782
-     */
783
-    public function date_and_time_range(
784
-        $dt_format = '',
785
-        $tm_format = '',
786
-        $conjunction = ' - ',
787
-        $separator = ' '
788
-    ) {
789
-        $dt_format   = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
790
-        $tm_format   = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
791
-        $full_format = $dt_format . $separator . $tm_format;
792
-        // the range output depends on various conditions
793
-        switch (true) {
794
-            // start date timestamp and end date timestamp are the same.
795
-            case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')):
796
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format);
797
-                break;
798
-            // start and end date are the same but times are different
799
-            case ($this->start_date() === $this->end_date()):
800
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
801
-                          . $conjunction
802
-                          . $this->get_i18n_datetime('DTT_EVT_end', $tm_format);
803
-                break;
804
-            // all other conditions
805
-            default:
806
-                $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
807
-                          . $conjunction
808
-                          . $this->get_i18n_datetime('DTT_EVT_end', $full_format);
809
-                break;
810
-        }
811
-        return $output;
812
-    }
813
-
814
-
815
-    /**
816
-     * This echos the results of date and time range.
817
-     *
818
-     * @param string $dt_format
819
-     * @param string $tm_format
820
-     * @param string $conjunction
821
-     * @return void
822
-     * @throws ReflectionException
823
-     * @throws InvalidArgumentException
824
-     * @throws InvalidInterfaceException
825
-     * @throws InvalidDataTypeException
826
-     * @throws EE_Error
827
-     * @see date_and_time_range() for more details on purpose.
828
-     */
829
-    public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ')
830
-    {
831
-        echo esc_html($this->date_and_time_range($dt_format, $tm_format, $conjunction));
832
-    }
833
-
834
-
835
-    /**
836
-     * get start date and start time
837
-     *
838
-     * @param string $dt_format - string representation of date format defaults to 'F j, Y'
839
-     * @param string $tm_format - string representation of time format defaults to 'g:i a'
840
-     * @return    mixed    string on success, FALSE on fail
841
-     * @throws ReflectionException
842
-     * @throws InvalidArgumentException
843
-     * @throws InvalidInterfaceException
844
-     * @throws InvalidDataTypeException
845
-     * @throws EE_Error
846
-     */
847
-    public function start_date_and_time($dt_format = '', $tm_format = '')
848
-    {
849
-        return $this->_show_datetime('', 'start', $dt_format, $tm_format);
850
-    }
851
-
852
-
853
-    /**
854
-     * @param string $dt_frmt
855
-     * @param string $tm_format
856
-     * @throws ReflectionException
857
-     * @throws InvalidArgumentException
858
-     * @throws InvalidInterfaceException
859
-     * @throws InvalidDataTypeException
860
-     * @throws EE_Error
861
-     */
862
-    public function e_start_date_and_time($dt_frmt = '', $tm_format = '')
863
-    {
864
-        $this->_show_datetime('', 'start', $dt_frmt, $tm_format, true);
865
-    }
866
-
867
-
868
-    /**
869
-     * Shows the length of the event (start to end time).
870
-     * Can be shown in 'seconds','minutes','hours', or 'days'.
871
-     * By default, rounds up. (So if you use 'days', and then event
872
-     * only occurs for 1 hour, it will return 1 day).
873
-     *
874
-     * @param string $units 'seconds','minutes','hours','days'
875
-     * @param bool   $round_up
876
-     * @return float|int|mixed
877
-     * @throws ReflectionException
878
-     * @throws InvalidArgumentException
879
-     * @throws InvalidInterfaceException
880
-     * @throws InvalidDataTypeException
881
-     * @throws EE_Error
882
-     */
883
-    public function length($units = 'seconds', $round_up = false)
884
-    {
885
-        $start           = $this->get_raw('DTT_EVT_start');
886
-        $end             = $this->get_raw('DTT_EVT_end');
887
-        $length_in_units = $end - $start;
888
-        switch ($units) {
889
-            // NOTE: We purposefully don't use "break;" in order to chain the divisions
890
-            /** @noinspection PhpMissingBreakStatementInspection */
891
-            // phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
892
-            case 'days':
893
-                $length_in_units /= 24;
894
-            /** @noinspection PhpMissingBreakStatementInspection */
895
-            case 'hours':
896
-                // fall through is intentional
897
-                $length_in_units /= 60;
898
-            /** @noinspection PhpMissingBreakStatementInspection */
899
-            case 'minutes':
900
-                // fall through is intentional
901
-                $length_in_units /= 60;
902
-            case 'seconds':
903
-            default:
904
-                $length_in_units = ceil($length_in_units);
905
-        }
906
-        // phpcs:enable
907
-        if ($round_up) {
908
-            $length_in_units = max($length_in_units, 1);
909
-        }
910
-        return $length_in_units;
911
-    }
912
-
913
-
914
-    /**
915
-     *        get end date and time
916
-     *
917
-     * @param string $dt_frmt   - string representation of date format defaults to 'F j, Y'
918
-     * @param string $tm_format - string representation of time format defaults to 'g:i a'
919
-     * @return    mixed                string on success, FALSE on fail
920
-     * @throws ReflectionException
921
-     * @throws InvalidArgumentException
922
-     * @throws InvalidInterfaceException
923
-     * @throws InvalidDataTypeException
924
-     * @throws EE_Error
925
-     */
926
-    public function end_date_and_time($dt_frmt = '', $tm_format = '')
927
-    {
928
-        return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
929
-    }
930
-
931
-
932
-    /**
933
-     * @param string $dt_frmt
934
-     * @param string $tm_format
935
-     * @throws ReflectionException
936
-     * @throws InvalidArgumentException
937
-     * @throws InvalidInterfaceException
938
-     * @throws InvalidDataTypeException
939
-     * @throws EE_Error
940
-     */
941
-    public function e_end_date_and_time($dt_frmt = '', $tm_format = '')
942
-    {
943
-        $this->_show_datetime('', 'end', $dt_frmt, $tm_format, true);
944
-    }
945
-
946
-
947
-    /**
948
-     *        get start timestamp
949
-     *
950
-     * @return        int
951
-     * @throws ReflectionException
952
-     * @throws InvalidArgumentException
953
-     * @throws InvalidInterfaceException
954
-     * @throws InvalidDataTypeException
955
-     * @throws EE_Error
956
-     */
957
-    public function start()
958
-    {
959
-        return $this->get_raw('DTT_EVT_start');
960
-    }
961
-
962
-
963
-    /**
964
-     *        get end timestamp
965
-     *
966
-     * @return        int
967
-     * @throws ReflectionException
968
-     * @throws InvalidArgumentException
969
-     * @throws InvalidInterfaceException
970
-     * @throws InvalidDataTypeException
971
-     * @throws EE_Error
972
-     */
973
-    public function end()
974
-    {
975
-        return $this->get_raw('DTT_EVT_end');
976
-    }
977
-
978
-
979
-    /**
980
-     *    get the registration limit for this datetime slot
981
-     *
982
-     * @return int|float                int = finite limit   EE_INF(float) = unlimited
983
-     * @throws ReflectionException
984
-     * @throws InvalidArgumentException
985
-     * @throws InvalidInterfaceException
986
-     * @throws InvalidDataTypeException
987
-     * @throws EE_Error
988
-     */
989
-    public function reg_limit()
990
-    {
991
-        return $this->get_raw('DTT_reg_limit');
992
-    }
993
-
994
-
995
-    /**
996
-     *    have the tickets sold for this datetime, met or exceed the registration limit ?
997
-     *
998
-     * @return boolean
999
-     * @throws ReflectionException
1000
-     * @throws InvalidArgumentException
1001
-     * @throws InvalidInterfaceException
1002
-     * @throws InvalidDataTypeException
1003
-     * @throws EE_Error
1004
-     */
1005
-    public function sold_out()
1006
-    {
1007
-        return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit();
1008
-    }
1009
-
1010
-
1011
-    /**
1012
-     * return the total number of spaces remaining at this venue.
1013
-     * This only takes the venue's capacity into account, NOT the tickets available for sale
1014
-     *
1015
-     * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left
1016
-     *                               Because if all tickets attached to this datetime have no spaces left,
1017
-     *                               then this datetime IS effectively sold out.
1018
-     *                               However, there are cases where we just want to know the spaces
1019
-     *                               remaining for this particular datetime, hence the flag.
1020
-     * @return int|float
1021
-     * @throws ReflectionException
1022
-     * @throws InvalidArgumentException
1023
-     * @throws InvalidInterfaceException
1024
-     * @throws InvalidDataTypeException
1025
-     * @throws EE_Error
1026
-     */
1027
-    public function spaces_remaining($consider_tickets = false)
1028
-    {
1029
-        // tickets remaining available for purchase
1030
-        // no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1031
-        $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1032
-        if (! $consider_tickets) {
1033
-            return $dtt_remaining;
1034
-        }
1035
-        $tickets_remaining = $this->tickets_remaining();
1036
-        return min($dtt_remaining, $tickets_remaining);
1037
-    }
1038
-
1039
-
1040
-    /**
1041
-     * Counts the total tickets available
1042
-     * (from all the different types of tickets which are available for this datetime).
1043
-     *
1044
-     * @param array $query_params @see
1045
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1046
-     * @return int
1047
-     * @throws ReflectionException
1048
-     * @throws InvalidArgumentException
1049
-     * @throws InvalidInterfaceException
1050
-     * @throws InvalidDataTypeException
1051
-     * @throws EE_Error
1052
-     */
1053
-    public function tickets_remaining($query_params = [])
1054
-    {
1055
-        $sum     = 0;
1056
-        $tickets = $this->tickets($query_params);
1057
-        if (! empty($tickets)) {
1058
-            foreach ($tickets as $ticket) {
1059
-                if ($ticket instanceof EE_Ticket) {
1060
-                    // get the actual amount of tickets that can be sold
1061
-                    $qty = $ticket->qty('saleable');
1062
-                    if ($qty === EE_INF) {
1063
-                        return EE_INF;
1064
-                    }
1065
-                    // no negative ticket quantities plz
1066
-                    if ($qty > 0) {
1067
-                        $sum += $qty;
1068
-                    }
1069
-                }
1070
-            }
1071
-        }
1072
-        return $sum;
1073
-    }
1074
-
1075
-
1076
-    /**
1077
-     * Gets the count of all the tickets available at this datetime (not ticket types)
1078
-     * before any were sold
1079
-     *
1080
-     * @param array $query_params @see
1081
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1082
-     * @return int
1083
-     * @throws ReflectionException
1084
-     * @throws InvalidArgumentException
1085
-     * @throws InvalidInterfaceException
1086
-     * @throws InvalidDataTypeException
1087
-     * @throws EE_Error
1088
-     */
1089
-    public function sum_tickets_initially_available($query_params = [])
1090
-    {
1091
-        return $this->sum_related('Ticket', $query_params, 'TKT_qty');
1092
-    }
1093
-
1094
-
1095
-    /**
1096
-     * Returns the lesser-of-the two: spaces remaining at this datetime, or
1097
-     * the total tickets remaining (a sum of the tickets remaining for each ticket type
1098
-     * that is available for this datetime).
1099
-     *
1100
-     * @return int
1101
-     * @throws ReflectionException
1102
-     * @throws InvalidArgumentException
1103
-     * @throws InvalidInterfaceException
1104
-     * @throws InvalidDataTypeException
1105
-     * @throws EE_Error
1106
-     */
1107
-    public function total_tickets_available_at_this_datetime()
1108
-    {
1109
-        return $this->spaces_remaining(true);
1110
-    }
1111
-
1112
-
1113
-    /**
1114
-     * This simply compares the internal dtt for the given string with NOW
1115
-     * and determines if the date is upcoming or not.
1116
-     *
1117
-     * @access public
1118
-     * @return boolean
1119
-     * @throws ReflectionException
1120
-     * @throws InvalidArgumentException
1121
-     * @throws InvalidInterfaceException
1122
-     * @throws InvalidDataTypeException
1123
-     * @throws EE_Error
1124
-     */
1125
-    public function is_upcoming()
1126
-    {
1127
-        return ($this->get_raw('DTT_EVT_start') > time());
1128
-    }
1129
-
1130
-
1131
-    /**
1132
-     * This simply compares the internal datetime for the given string with NOW
1133
-     * and returns if the date is active (i.e. start and end time)
1134
-     *
1135
-     * @return boolean
1136
-     * @throws ReflectionException
1137
-     * @throws InvalidArgumentException
1138
-     * @throws InvalidInterfaceException
1139
-     * @throws InvalidDataTypeException
1140
-     * @throws EE_Error
1141
-     */
1142
-    public function is_active()
1143
-    {
1144
-        return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
1145
-    }
1146
-
1147
-
1148
-    /**
1149
-     * This simply compares the internal dtt for the given string with NOW
1150
-     * and determines if the date is expired or not.
1151
-     *
1152
-     * @return boolean
1153
-     * @throws ReflectionException
1154
-     * @throws InvalidArgumentException
1155
-     * @throws InvalidInterfaceException
1156
-     * @throws InvalidDataTypeException
1157
-     * @throws EE_Error
1158
-     */
1159
-    public function is_expired()
1160
-    {
1161
-        return ($this->get_raw('DTT_EVT_end') < time());
1162
-    }
1163
-
1164
-
1165
-    /**
1166
-     * This returns the active status for whether an event is active, upcoming, or expired
1167
-     *
1168
-     * @return int return value will be one of the EE_Datetime status constants.
1169
-     * @throws ReflectionException
1170
-     * @throws InvalidArgumentException
1171
-     * @throws InvalidInterfaceException
1172
-     * @throws InvalidDataTypeException
1173
-     * @throws EE_Error
1174
-     */
1175
-    public function get_active_status()
1176
-    {
1177
-        $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
1178
-        if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) {
1179
-            return EE_Datetime::sold_out;
1180
-        }
1181
-        if ($this->is_expired()) {
1182
-            return EE_Datetime::expired;
1183
-        }
1184
-        if ($this->is_upcoming()) {
1185
-            return EE_Datetime::upcoming;
1186
-        }
1187
-        if ($this->is_active()) {
1188
-            return EE_Datetime::active;
1189
-        }
1190
-        return null;
1191
-    }
1192
-
1193
-
1194
-    /**
1195
-     * This returns a nice display name for the datetime that is contingent on the span between the dates and times.
1196
-     *
1197
-     * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
1198
-     * @return string
1199
-     * @throws ReflectionException
1200
-     * @throws InvalidArgumentException
1201
-     * @throws InvalidInterfaceException
1202
-     * @throws InvalidDataTypeException
1203
-     * @throws EE_Error
1204
-     */
1205
-    public function get_dtt_display_name($use_dtt_name = false)
1206
-    {
1207
-        if ($use_dtt_name) {
1208
-            $dtt_name = $this->name();
1209
-            if (! empty($dtt_name)) {
1210
-                return $dtt_name;
1211
-            }
1212
-        }
1213
-        // first condition is to see if the months are different
1214
-        if (
1215
-            date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1216
-        ) {
1217
-            $display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1218
-            // next condition is if its the same month but different day
1219
-        } else {
1220
-            if (
1221
-                date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1222
-                && date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1223
-            ) {
1224
-                $display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1225
-            } else {
1226
-                $display_date = $this->start_date('F j\, Y')
1227
-                                . ' @ '
1228
-                                . $this->start_date('g:i a')
1229
-                                . ' - '
1230
-                                . $this->end_date('g:i a');
1231
-            }
1232
-        }
1233
-        return $display_date;
1234
-    }
1235
-
1236
-
1237
-    /**
1238
-     * Gets all the tickets for this datetime
1239
-     *
1240
-     * @param array $query_params @see
1241
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1242
-     * @return EE_Base_Class[]|EE_Ticket[]
1243
-     * @throws ReflectionException
1244
-     * @throws InvalidArgumentException
1245
-     * @throws InvalidInterfaceException
1246
-     * @throws InvalidDataTypeException
1247
-     * @throws EE_Error
1248
-     */
1249
-    public function tickets($query_params = [])
1250
-    {
1251
-        return $this->get_many_related('Ticket', $query_params);
1252
-    }
1253
-
1254
-
1255
-    /**
1256
-     * Gets all the ticket types currently available for purchase
1257
-     *
1258
-     * @param array $query_params @see
1259
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1260
-     * @return EE_Ticket[]
1261
-     * @throws ReflectionException
1262
-     * @throws InvalidArgumentException
1263
-     * @throws InvalidInterfaceException
1264
-     * @throws InvalidDataTypeException
1265
-     * @throws EE_Error
1266
-     */
1267
-    public function ticket_types_available_for_purchase($query_params = [])
1268
-    {
1269
-        // first check if datetime is valid
1270
-        if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) {
1271
-            return [];
1272
-        }
1273
-        if (empty($query_params)) {
1274
-            $query_params = [
1275
-                [
1276
-                    'TKT_start_date' => ['<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')],
1277
-                    'TKT_end_date'   => ['>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')],
1278
-                    'TKT_deleted'    => false,
1279
-                ],
1280
-            ];
1281
-        }
1282
-        return $this->tickets($query_params);
1283
-    }
1284
-
1285
-
1286
-    /**
1287
-     * @return EE_Base_Class|EE_Event
1288
-     * @throws ReflectionException
1289
-     * @throws InvalidArgumentException
1290
-     * @throws InvalidInterfaceException
1291
-     * @throws InvalidDataTypeException
1292
-     * @throws EE_Error
1293
-     */
1294
-    public function event()
1295
-    {
1296
-        return EEM_Event::instance()->get_one_by_ID($this->get('EVT_ID'));
1297
-    }
1298
-
1299
-
1300
-    /**
1301
-     * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime
1302
-     * (via the tickets).
1303
-     *
1304
-     * @return int
1305
-     * @throws ReflectionException
1306
-     * @throws InvalidArgumentException
1307
-     * @throws InvalidInterfaceException
1308
-     * @throws InvalidDataTypeException
1309
-     * @throws EE_Error
1310
-     */
1311
-    public function update_sold()
1312
-    {
1313
-        $count_regs_for_this_datetime = EEM_Registration::instance()->count(
1314
-            [
1315
-                [
1316
-                    'STS_ID'                 => RegStatus::APPROVED,
1317
-                    'REG_deleted'            => 0,
1318
-                    'Ticket.Datetime.DTT_ID' => $this->ID(),
1319
-                ],
1320
-            ]
1321
-        );
1322
-        $this->set_sold($count_regs_for_this_datetime);
1323
-        $this->save();
1324
-        return $count_regs_for_this_datetime;
1325
-    }
1326
-
1327
-
1328
-    /**
1329
-     * Adds a venue to this event
1330
-     *
1331
-     * @param int|EE_Venue /int $venue_id_or_obj
1332
-     * @return EE_Base_Class|EE_Venue
1333
-     * @throws EE_Error
1334
-     * @throws ReflectionException
1335
-     */
1336
-    public function add_venue($venue_id_or_obj): EE_Venue
1337
-    {
1338
-        return $this->_add_relation_to($venue_id_or_obj, 'Venue');
1339
-    }
1340
-
1341
-
1342
-    /**
1343
-     * Removes a venue from the event
1344
-     *
1345
-     * @param EE_Venue /int $venue_id_or_obj
1346
-     * @return EE_Base_Class|EE_Venue
1347
-     * @throws EE_Error
1348
-     * @throws ReflectionException
1349
-     */
1350
-    public function remove_venue($venue_id_or_obj): EE_Venue
1351
-    {
1352
-        $venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue();
1353
-        return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
1354
-    }
1355
-
1356
-
1357
-    /**
1358
-     * Gets the venue related to the event. May provide additional $query_params if desired
1359
-     *
1360
-     * @param array $query_params @see
1361
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1362
-     * @return int
1363
-     * @throws EE_Error
1364
-     * @throws ReflectionException
1365
-     */
1366
-    public function venue_ID(array $query_params = []): int
1367
-    {
1368
-        // If no $query_params have been passed, use the VNU_ID assigned to the Datetime itself
1369
-        if (empty($query_params)) {
1370
-            return (int) $this->get('VNU_ID');
1371
-        }
1372
-        // $query_params set, pull the first related venue using those
1373
-        $venue = $this->get_first_related('Venue', $query_params);
1374
-        return $venue instanceof EE_Venue
1375
-            ? $venue->ID()
1376
-            : 0;
1377
-    }
1378
-
1379
-
1380
-    /**
1381
-     * Gets the venue related to the event. May provide additional $query_params if desired
1382
-     *
1383
-     * @param array $query_params @see
1384
-     *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1385
-     * @return EE_Base_Class|EE_Venue|null
1386
-     * @throws EE_Error
1387
-     * @throws ReflectionException
1388
-     */
1389
-    public function venue(array $query_params = [])
1390
-    {
1391
-        // If no $query_params have been passed, use the VNU_ID assigned to the Datetime itself
1392
-        if (empty($query_params)) {
1393
-            $VNU_ID = $this->venue_ID();
1394
-            return $VNU_ID ? EEM_Venue::instance()->get_one_by_ID($VNU_ID) : null;
1395
-        }
1396
-        return $this->get_first_related('Venue', $query_params);
1397
-    }
1398
-
1399
-
1400
-    /**
1401
-     * @param EE_Base_Class|int|string $otherObjectModelObjectOrID
1402
-     * @param string                   $relationName
1403
-     * @param array                    $extra_join_model_fields_n_values
1404
-     * @param string|null              $cache_id
1405
-     * @return EE_Base_Class
1406
-     * @throws EE_Error
1407
-     * @throws ReflectionException
1408
-     * @since   5.0.0.p
1409
-     */
1410
-    public function _add_relation_to(
1411
-        $otherObjectModelObjectOrID,
1412
-        $relationName,
1413
-        $extra_join_model_fields_n_values = [],
1414
-        $cache_id = null
1415
-    ) {
1416
-        // if we're adding a new relation to a ticket
1417
-        if ($relationName === 'Ticket' && ! $this->hasRelation($otherObjectModelObjectOrID, $relationName)) {
1418
-            /** @var EE_Ticket $ticket */
1419
-            $ticket = EEM_Ticket::instance()->ensure_is_obj($otherObjectModelObjectOrID);
1420
-            $this->increaseSold($ticket->sold(), false);
1421
-            $this->increaseReserved($ticket->reserved());
1422
-            $this->save();
1423
-            $otherObjectModelObjectOrID = $ticket;
1424
-        }
1425
-        return parent::_add_relation_to(
1426
-            $otherObjectModelObjectOrID,
1427
-            $relationName,
1428
-            $extra_join_model_fields_n_values,
1429
-            $cache_id
1430
-        );
1431
-    }
1432
-
1433
-
1434
-    /**
1435
-     * @param EE_Base_Class|int|string $otherObjectModelObjectOrID
1436
-     * @param string                   $relationName
1437
-     * @param array                    $where_query
1438
-     * @return bool|EE_Base_Class|null
1439
-     * @throws EE_Error
1440
-     * @throws ReflectionException
1441
-     * @since   5.0.0.p
1442
-     */
1443
-    public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = [])
1444
-    {
1445
-        if ($relationName === 'Ticket' && $this->hasRelation($otherObjectModelObjectOrID, $relationName)) {
1446
-            /** @var EE_Ticket $ticket */
1447
-            $ticket = EEM_Ticket::instance()->ensure_is_obj($otherObjectModelObjectOrID);
1448
-            $this->decreaseSold($ticket->sold());
1449
-            $this->decreaseReserved($ticket->reserved());
1450
-            $this->save();
1451
-            $otherObjectModelObjectOrID = $ticket;
1452
-        }
1453
-        return parent::_remove_relation_to(
1454
-            $otherObjectModelObjectOrID,
1455
-            $relationName,
1456
-            $where_query
1457
-        );
1458
-    }
1459
-
1460
-
1461
-    /**
1462
-     * Removes ALL the related things for the $relationName.
1463
-     *
1464
-     * @param string $relationName
1465
-     * @param array  $where_query_params
1466
-     * @return EE_Base_Class
1467
-     * @throws ReflectionException
1468
-     * @throws InvalidArgumentException
1469
-     * @throws InvalidInterfaceException
1470
-     * @throws InvalidDataTypeException
1471
-     * @throws EE_Error
1472
-     * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
1473
-     */
1474
-    public function _remove_relations($relationName, $where_query_params = [])
1475
-    {
1476
-        if ($relationName === 'Ticket') {
1477
-            $tickets = $this->tickets();
1478
-            foreach ($tickets as $ticket) {
1479
-                $this->decreaseSold($ticket->sold());
1480
-                $this->decreaseReserved($ticket->reserved());
1481
-                $this->save();
1482
-            }
1483
-        }
1484
-        return parent::_remove_relations($relationName, $where_query_params);
1485
-    }
1486
-
1487
-
1488
-    /*******************************************************************
16
+	/**
17
+	 * constant used by get_active_status, indicates datetime has no more available spaces
18
+	 */
19
+	const sold_out = 'DTS';
20
+
21
+	/**
22
+	 * constant used by get_active_status, indicating datetime is still active (even is not over, can be registered-for)
23
+	 */
24
+	const active = 'DTA';
25
+
26
+	/**
27
+	 * constant used by get_active_status, indicating the datetime cannot be used for registrations yet, but has not
28
+	 * expired
29
+	 */
30
+	const upcoming = 'DTU';
31
+
32
+	/**
33
+	 * Datetime is postponed
34
+	 */
35
+	const postponed = 'DTP';
36
+
37
+	/**
38
+	 * Datetime is cancelled
39
+	 */
40
+	const cancelled = 'DTC';
41
+
42
+	/**
43
+	 * constant used by get_active_status, indicates datetime has expired (event is over)
44
+	 */
45
+	const expired = 'DTE';
46
+
47
+	/**
48
+	 * constant used in various places indicating that an event is INACTIVE (not yet ready to be published)
49
+	 */
50
+	const inactive = 'DTI';
51
+
52
+
53
+	/**
54
+	 * @param array  $props_n_values    incoming values
55
+	 * @param string $timezone          incoming timezone (if not set the timezone set for the website will be used.)
56
+	 * @param array  $date_formats      incoming date_formats in an array where the first value is the date_format
57
+	 *                                  and the second value is the time format
58
+	 * @return EE_Datetime
59
+	 * @throws ReflectionException
60
+	 * @throws InvalidArgumentException
61
+	 * @throws InvalidInterfaceException
62
+	 * @throws InvalidDataTypeException
63
+	 * @throws EE_Error
64
+	 */
65
+	public static function new_instance($props_n_values = [], $timezone = '', $date_formats = [])
66
+	{
67
+		$has_object = parent::_check_for_object(
68
+			$props_n_values,
69
+			__CLASS__,
70
+			$timezone,
71
+			$date_formats
72
+		);
73
+		return $has_object
74
+			? $has_object
75
+			: new self($props_n_values, false, $timezone, $date_formats);
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param array  $props_n_values  incoming values from the database
81
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
82
+	 *                                the website will be used.
83
+	 * @return EE_Datetime
84
+	 * @throws ReflectionException
85
+	 * @throws InvalidArgumentException
86
+	 * @throws InvalidInterfaceException
87
+	 * @throws InvalidDataTypeException
88
+	 * @throws EE_Error
89
+	 */
90
+	public static function new_instance_from_db($props_n_values = [], $timezone = '')
91
+	{
92
+		return new self($props_n_values, true, $timezone);
93
+	}
94
+
95
+
96
+	/**
97
+	 * @param $name
98
+	 * @throws ReflectionException
99
+	 * @throws InvalidArgumentException
100
+	 * @throws InvalidInterfaceException
101
+	 * @throws InvalidDataTypeException
102
+	 * @throws EE_Error
103
+	 */
104
+	public function set_name($name)
105
+	{
106
+		$this->set('DTT_name', $name);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @param $description
112
+	 * @throws ReflectionException
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws EE_Error
117
+	 */
118
+	public function set_description($description)
119
+	{
120
+		$this->set('DTT_description', $description);
121
+	}
122
+
123
+
124
+	/**
125
+	 * Set event start date
126
+	 * set the start date for an event
127
+	 *
128
+	 * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
129
+	 * @throws ReflectionException
130
+	 * @throws InvalidArgumentException
131
+	 * @throws InvalidInterfaceException
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws EE_Error
134
+	 */
135
+	public function set_start_date($date)
136
+	{
137
+		$this->_set_date_for($date, 'DTT_EVT_start');
138
+	}
139
+
140
+
141
+	/**
142
+	 * Set event start time
143
+	 * set the start time for an event
144
+	 *
145
+	 * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
146
+	 * @throws ReflectionException
147
+	 * @throws InvalidArgumentException
148
+	 * @throws InvalidInterfaceException
149
+	 * @throws InvalidDataTypeException
150
+	 * @throws EE_Error
151
+	 */
152
+	public function set_start_time($time)
153
+	{
154
+		$this->_set_time_for($time, 'DTT_EVT_start');
155
+	}
156
+
157
+
158
+	/**
159
+	 * Set event end date
160
+	 * set the end date for an event
161
+	 *
162
+	 * @param string $date a string representation of the event's date ex:  Dec. 25, 2025 or 12-25-2025
163
+	 * @throws ReflectionException
164
+	 * @throws InvalidArgumentException
165
+	 * @throws InvalidInterfaceException
166
+	 * @throws InvalidDataTypeException
167
+	 * @throws EE_Error
168
+	 */
169
+	public function set_end_date($date)
170
+	{
171
+		$this->_set_date_for($date, 'DTT_EVT_end');
172
+	}
173
+
174
+
175
+	/**
176
+	 * Set event end time
177
+	 * set the end time for an event
178
+	 *
179
+	 * @param string $time a string representation of the event time ex:  9am  or  7:30 PM
180
+	 * @throws ReflectionException
181
+	 * @throws InvalidArgumentException
182
+	 * @throws InvalidInterfaceException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws EE_Error
185
+	 */
186
+	public function set_end_time($time)
187
+	{
188
+		$this->_set_time_for($time, 'DTT_EVT_end');
189
+	}
190
+
191
+
192
+	/**
193
+	 * Set registration limit
194
+	 * set the maximum number of attendees that can be registered for this datetime slot
195
+	 *
196
+	 * @param int|float $reg_limit
197
+	 * @throws ReflectionException
198
+	 * @throws InvalidArgumentException
199
+	 * @throws InvalidInterfaceException
200
+	 * @throws InvalidDataTypeException
201
+	 * @throws EE_Error
202
+	 */
203
+	public function set_reg_limit($reg_limit)
204
+	{
205
+		$this->set('DTT_reg_limit', $reg_limit);
206
+	}
207
+
208
+
209
+	/**
210
+	 * get the number of tickets sold for this datetime slot
211
+	 *
212
+	 * @return mixed int on success, FALSE on fail
213
+	 * @throws ReflectionException
214
+	 * @throws InvalidArgumentException
215
+	 * @throws InvalidInterfaceException
216
+	 * @throws InvalidDataTypeException
217
+	 * @throws EE_Error
218
+	 */
219
+	public function sold()
220
+	{
221
+		return $this->get_raw('DTT_sold');
222
+	}
223
+
224
+
225
+	/**
226
+	 * @param int $sold
227
+	 * @throws ReflectionException
228
+	 * @throws InvalidArgumentException
229
+	 * @throws InvalidInterfaceException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws EE_Error
232
+	 */
233
+	public function set_sold($sold)
234
+	{
235
+		// sold can not go below zero
236
+		$sold = max(0, $sold);
237
+		$this->set('DTT_sold', $sold);
238
+	}
239
+
240
+
241
+	/**
242
+	 * Increments sold by amount passed by $qty, and persists it immediately to the database.
243
+	 * Simultaneously decreases the reserved count, unless $also_decrease_reserved is false.
244
+	 *
245
+	 * @param int     $qty
246
+	 * @param boolean $also_decrease_reserved
247
+	 * @return boolean indicating success
248
+	 * @throws ReflectionException
249
+	 * @throws InvalidArgumentException
250
+	 * @throws InvalidInterfaceException
251
+	 * @throws InvalidDataTypeException
252
+	 * @throws EE_Error
253
+	 */
254
+	public function increaseSold(int $qty = 1, bool $also_decrease_reserved = true): bool
255
+	{
256
+		$qty = absint($qty);
257
+		if ($also_decrease_reserved) {
258
+			$success = $this->adjustNumericFieldsInDb(
259
+				[
260
+					'DTT_reserved' => $qty * -1,
261
+					'DTT_sold'     => $qty,
262
+				]
263
+			);
264
+		} else {
265
+			$success = $this->adjustNumericFieldsInDb(
266
+				[
267
+					'DTT_sold' => $qty,
268
+				]
269
+			);
270
+		}
271
+
272
+		do_action(
273
+			'AHEE__EE_Datetime__increase_sold',
274
+			$this,
275
+			$qty,
276
+			$this->sold(),
277
+			$success
278
+		);
279
+		return $success;
280
+	}
281
+
282
+
283
+	/**
284
+	 * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
285
+	 * to save afterwards.)
286
+	 *
287
+	 * @param int $qty
288
+	 * @return boolean indicating success
289
+	 * @throws ReflectionException
290
+	 * @throws InvalidArgumentException
291
+	 * @throws InvalidInterfaceException
292
+	 * @throws InvalidDataTypeException
293
+	 * @throws EE_Error
294
+	 */
295
+	public function decreaseSold(int $qty = 1): bool
296
+	{
297
+		$qty     = absint($qty);
298
+		$success = $this->adjustNumericFieldsInDb(
299
+			[
300
+				'DTT_sold' => $qty * -1,
301
+			]
302
+		);
303
+		do_action(
304
+			'AHEE__EE_Datetime__decrease_sold',
305
+			$this,
306
+			$qty,
307
+			$this->sold(),
308
+			$success
309
+		);
310
+		return $success;
311
+	}
312
+
313
+
314
+	/**
315
+	 * Gets qty of reserved tickets for this datetime
316
+	 *
317
+	 * @return int
318
+	 * @throws ReflectionException
319
+	 * @throws InvalidArgumentException
320
+	 * @throws InvalidInterfaceException
321
+	 * @throws InvalidDataTypeException
322
+	 * @throws EE_Error
323
+	 */
324
+	public function reserved(): int
325
+	{
326
+		return $this->get_raw('DTT_reserved');
327
+	}
328
+
329
+
330
+	/**
331
+	 * Sets qty of reserved tickets for this datetime
332
+	 *
333
+	 * @param int $reserved
334
+	 * @throws ReflectionException
335
+	 * @throws InvalidArgumentException
336
+	 * @throws InvalidInterfaceException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws EE_Error
339
+	 */
340
+	public function set_reserved(int $reserved)
341
+	{
342
+		// reserved can not go below zero
343
+		$reserved = max(0, $reserved);
344
+		$this->set('DTT_reserved', $reserved);
345
+	}
346
+
347
+
348
+	/**
349
+	 * Increments reserved by amount passed by $qty, and persists it immediately to the database.
350
+	 *
351
+	 * @param int $qty
352
+	 * @return boolean indicating success
353
+	 * @throws ReflectionException
354
+	 * @throws InvalidArgumentException
355
+	 * @throws InvalidInterfaceException
356
+	 * @throws InvalidDataTypeException
357
+	 * @throws EE_Error
358
+	 */
359
+	public function increaseReserved(int $qty = 1): bool
360
+	{
361
+		$qty     = absint($qty);
362
+		$success = $this->incrementFieldConditionallyInDb(
363
+			'DTT_reserved',
364
+			'DTT_sold',
365
+			'DTT_reg_limit',
366
+			$qty
367
+		);
368
+		do_action(
369
+			'AHEE__EE_Datetime__increase_reserved',
370
+			$this,
371
+			$qty,
372
+			$this->reserved(),
373
+			$success
374
+		);
375
+		return $success;
376
+	}
377
+
378
+
379
+	/**
380
+	 * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
381
+	 *
382
+	 * @param int $qty
383
+	 * @return boolean indicating success
384
+	 * @throws ReflectionException
385
+	 * @throws InvalidArgumentException
386
+	 * @throws InvalidInterfaceException
387
+	 * @throws InvalidDataTypeException
388
+	 * @throws EE_Error
389
+	 */
390
+	public function decreaseReserved(int $qty = 1): bool
391
+	{
392
+		$qty     = absint($qty);
393
+		$success = $this->adjustNumericFieldsInDb(
394
+			[
395
+				'DTT_reserved' => $qty * -1,
396
+			]
397
+		);
398
+		do_action(
399
+			'AHEE__EE_Datetime__decrease_reserved',
400
+			$this,
401
+			$qty,
402
+			$this->reserved(),
403
+			$success
404
+		);
405
+		return $success;
406
+	}
407
+
408
+
409
+	/**
410
+	 * total sold and reserved tickets
411
+	 *
412
+	 * @return int
413
+	 * @throws ReflectionException
414
+	 * @throws InvalidArgumentException
415
+	 * @throws InvalidInterfaceException
416
+	 * @throws InvalidDataTypeException
417
+	 * @throws EE_Error
418
+	 */
419
+	public function sold_and_reserved(): int
420
+	{
421
+		return $this->sold() + $this->reserved();
422
+	}
423
+
424
+
425
+	/**
426
+	 * returns the datetime name
427
+	 *
428
+	 * @return string
429
+	 * @throws ReflectionException
430
+	 * @throws InvalidArgumentException
431
+	 * @throws InvalidInterfaceException
432
+	 * @throws InvalidDataTypeException
433
+	 * @throws EE_Error
434
+	 */
435
+	public function name(): string
436
+	{
437
+		return $this->get('DTT_name');
438
+	}
439
+
440
+
441
+	/**
442
+	 * returns the datetime description
443
+	 *
444
+	 * @return string
445
+	 * @throws ReflectionException
446
+	 * @throws InvalidArgumentException
447
+	 * @throws InvalidInterfaceException
448
+	 * @throws InvalidDataTypeException
449
+	 * @throws EE_Error
450
+	 */
451
+	public function description(): string
452
+	{
453
+		return $this->get('DTT_description');
454
+	}
455
+
456
+
457
+	/**
458
+	 * This helper simply returns whether the event_datetime for the current datetime is a primary datetime
459
+	 *
460
+	 * @return boolean  TRUE if is primary, FALSE if not.
461
+	 * @throws ReflectionException
462
+	 * @throws InvalidArgumentException
463
+	 * @throws InvalidInterfaceException
464
+	 * @throws InvalidDataTypeException
465
+	 * @throws EE_Error
466
+	 */
467
+	public function is_primary(): bool
468
+	{
469
+		return $this->get('DTT_is_primary');
470
+	}
471
+
472
+
473
+	/**
474
+	 * This helper simply returns the order for the datetime
475
+	 *
476
+	 * @return int  The order of the datetime for this event.
477
+	 * @throws ReflectionException
478
+	 * @throws InvalidArgumentException
479
+	 * @throws InvalidInterfaceException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws EE_Error
482
+	 */
483
+	public function order(): int
484
+	{
485
+		return $this->get('DTT_order');
486
+	}
487
+
488
+
489
+	/**
490
+	 * This helper simply returns the parent id for the datetime
491
+	 *
492
+	 * @return int
493
+	 * @throws ReflectionException
494
+	 * @throws InvalidArgumentException
495
+	 * @throws InvalidInterfaceException
496
+	 * @throws InvalidDataTypeException
497
+	 * @throws EE_Error
498
+	 */
499
+	public function parent(): int
500
+	{
501
+		return $this->get('DTT_parent');
502
+	}
503
+
504
+
505
+	/**
506
+	 * show date and/or time
507
+	 *
508
+	 * @param string $date_or_time    whether to display a date or time or both
509
+	 * @param string $start_or_end    whether to display start or end datetimes
510
+	 * @param string $dt_frmt
511
+	 * @param string $tm_frmt
512
+	 * @param bool   $echo            whether we echo or return (note echoing uses "pretty" formats,
513
+	 *                                otherwise we use the standard formats)
514
+	 * @return string|bool  string on success, FALSE on fail
515
+	 * @throws ReflectionException
516
+	 * @throws InvalidArgumentException
517
+	 * @throws InvalidInterfaceException
518
+	 * @throws InvalidDataTypeException
519
+	 * @throws EE_Error
520
+	 */
521
+	private function _show_datetime(
522
+		$date_or_time = null,
523
+		$start_or_end = 'start',
524
+		$dt_frmt = '',
525
+		$tm_frmt = '',
526
+		$echo = false
527
+	) {
528
+		$field_name = "DTT_EVT_{$start_or_end}";
529
+		$dtt        = $this->_get_datetime(
530
+			$field_name,
531
+			$dt_frmt,
532
+			$tm_frmt,
533
+			$date_or_time,
534
+			$echo
535
+		);
536
+		if (! $echo) {
537
+			return $dtt;
538
+		}
539
+		return '';
540
+	}
541
+
542
+
543
+	/**
544
+	 * get event start date.  Provide either the date format, or NULL to re-use the
545
+	 * last-used format, or '' to use the default date format
546
+	 *
547
+	 * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
548
+	 * @return mixed            string on success, FALSE on fail
549
+	 * @throws ReflectionException
550
+	 * @throws InvalidArgumentException
551
+	 * @throws InvalidInterfaceException
552
+	 * @throws InvalidDataTypeException
553
+	 * @throws EE_Error
554
+	 */
555
+	public function start_date($dt_frmt = '')
556
+	{
557
+		return $this->_show_datetime('D', 'start', $dt_frmt);
558
+	}
559
+
560
+
561
+	/**
562
+	 * Echoes start_date()
563
+	 *
564
+	 * @param string $dt_frmt
565
+	 * @throws ReflectionException
566
+	 * @throws InvalidArgumentException
567
+	 * @throws InvalidInterfaceException
568
+	 * @throws InvalidDataTypeException
569
+	 * @throws EE_Error
570
+	 */
571
+	public function e_start_date($dt_frmt = '')
572
+	{
573
+		$this->_show_datetime('D', 'start', $dt_frmt, null, true);
574
+	}
575
+
576
+
577
+	/**
578
+	 * get end date. Provide either the date format, or NULL to re-use the
579
+	 * last-used format, or '' to use the default date format
580
+	 *
581
+	 * @param string $dt_frmt string representation of date format defaults to 'F j, Y'
582
+	 * @return mixed            string on success, FALSE on fail
583
+	 * @throws ReflectionException
584
+	 * @throws InvalidArgumentException
585
+	 * @throws InvalidInterfaceException
586
+	 * @throws InvalidDataTypeException
587
+	 * @throws EE_Error
588
+	 */
589
+	public function end_date($dt_frmt = '')
590
+	{
591
+		return $this->_show_datetime('D', 'end', $dt_frmt);
592
+	}
593
+
594
+
595
+	/**
596
+	 * Echoes the end date. See end_date()
597
+	 *
598
+	 * @param string $dt_frmt
599
+	 * @throws ReflectionException
600
+	 * @throws InvalidArgumentException
601
+	 * @throws InvalidInterfaceException
602
+	 * @throws InvalidDataTypeException
603
+	 * @throws EE_Error
604
+	 */
605
+	public function e_end_date($dt_frmt = '')
606
+	{
607
+		$this->_show_datetime('D', 'end', $dt_frmt, null, true);
608
+	}
609
+
610
+
611
+	/**
612
+	 * get date_range - meaning the start AND end date
613
+	 *
614
+	 * @access public
615
+	 * @param string $dt_frmt     string representation of date format defaults to WP settings
616
+	 * @param string $conjunction conjunction junction what's your function ?
617
+	 *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
618
+	 * @return mixed              string on success, FALSE on fail
619
+	 * @throws ReflectionException
620
+	 * @throws InvalidArgumentException
621
+	 * @throws InvalidInterfaceException
622
+	 * @throws InvalidDataTypeException
623
+	 * @throws EE_Error
624
+	 */
625
+	public function date_range($dt_frmt = '', $conjunction = ' - ')
626
+	{
627
+		$dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt;
628
+		$start   = str_replace(
629
+			' ',
630
+			'&nbsp;',
631
+			$this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)
632
+		);
633
+		$end     = str_replace(
634
+			' ',
635
+			'&nbsp;',
636
+			$this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)
637
+		);
638
+		return $start !== $end ? $start . $conjunction . $end : $start;
639
+	}
640
+
641
+
642
+	/**
643
+	 * @param string $dt_frmt
644
+	 * @param string $conjunction
645
+	 * @throws ReflectionException
646
+	 * @throws InvalidArgumentException
647
+	 * @throws InvalidInterfaceException
648
+	 * @throws InvalidDataTypeException
649
+	 * @throws EE_Error
650
+	 */
651
+	public function e_date_range($dt_frmt = '', $conjunction = ' - ')
652
+	{
653
+		echo esc_html($this->date_range($dt_frmt, $conjunction));
654
+	}
655
+
656
+
657
+	/**
658
+	 * get start time
659
+	 *
660
+	 * @param string $tm_format - string representation of time format defaults to 'g:i a'
661
+	 * @return mixed        string on success, FALSE on fail
662
+	 * @throws ReflectionException
663
+	 * @throws InvalidArgumentException
664
+	 * @throws InvalidInterfaceException
665
+	 * @throws InvalidDataTypeException
666
+	 * @throws EE_Error
667
+	 */
668
+	public function start_time($tm_format = '')
669
+	{
670
+		return $this->_show_datetime('T', 'start', null, $tm_format);
671
+	}
672
+
673
+
674
+	/**
675
+	 * @param string $tm_format
676
+	 * @throws ReflectionException
677
+	 * @throws InvalidArgumentException
678
+	 * @throws InvalidInterfaceException
679
+	 * @throws InvalidDataTypeException
680
+	 * @throws EE_Error
681
+	 */
682
+	public function e_start_time($tm_format = '')
683
+	{
684
+		$this->_show_datetime('T', 'start', null, $tm_format, true);
685
+	}
686
+
687
+
688
+	/**
689
+	 * get end time
690
+	 *
691
+	 * @param string $tm_format string representation of time format defaults to 'g:i a'
692
+	 * @return mixed                string on success, FALSE on fail
693
+	 * @throws ReflectionException
694
+	 * @throws InvalidArgumentException
695
+	 * @throws InvalidInterfaceException
696
+	 * @throws InvalidDataTypeException
697
+	 * @throws EE_Error
698
+	 */
699
+	public function end_time($tm_format = '')
700
+	{
701
+		return $this->_show_datetime('T', 'end', null, $tm_format);
702
+	}
703
+
704
+
705
+	/**
706
+	 * @param string $tm_format
707
+	 * @throws ReflectionException
708
+	 * @throws InvalidArgumentException
709
+	 * @throws InvalidInterfaceException
710
+	 * @throws InvalidDataTypeException
711
+	 * @throws EE_Error
712
+	 */
713
+	public function e_end_time($tm_format = '')
714
+	{
715
+		$this->_show_datetime('T', 'end', null, $tm_format, true);
716
+	}
717
+
718
+
719
+	/**
720
+	 * get time_range
721
+	 *
722
+	 * @access public
723
+	 * @param string $tm_format   string representation of time format defaults to 'g:i a'
724
+	 * @param string $conjunction conjunction junction what's your function ?
725
+	 *                            this string joins the start date with the end date ie: Jan 01 "to" Dec 31
726
+	 * @return mixed              string on success, FALSE on fail
727
+	 * @throws ReflectionException
728
+	 * @throws InvalidArgumentException
729
+	 * @throws InvalidInterfaceException
730
+	 * @throws InvalidDataTypeException
731
+	 * @throws EE_Error
732
+	 */
733
+	public function time_range($tm_format = '', $conjunction = ' - ')
734
+	{
735
+		$tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
736
+		$start     = str_replace(
737
+			' ',
738
+			'&nbsp;',
739
+			$this->get_i18n_datetime('DTT_EVT_start', $tm_format)
740
+		);
741
+		$end       = str_replace(
742
+			' ',
743
+			'&nbsp;',
744
+			$this->get_i18n_datetime('DTT_EVT_end', $tm_format)
745
+		);
746
+		return $start !== $end ? $start . $conjunction . $end : $start;
747
+	}
748
+
749
+
750
+	/**
751
+	 * @param string $tm_format
752
+	 * @param string $conjunction
753
+	 * @throws ReflectionException
754
+	 * @throws InvalidArgumentException
755
+	 * @throws InvalidInterfaceException
756
+	 * @throws InvalidDataTypeException
757
+	 * @throws EE_Error
758
+	 */
759
+	public function e_time_range($tm_format = '', $conjunction = ' - ')
760
+	{
761
+		echo esc_html($this->time_range($tm_format, $conjunction));
762
+	}
763
+
764
+
765
+	/**
766
+	 * This returns a range representation of the date and times.
767
+	 * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end.
768
+	 * Also, the return value is localized.
769
+	 *
770
+	 * @param string $dt_format
771
+	 * @param string $tm_format
772
+	 * @param string $conjunction used between two different dates or times.
773
+	 *                            ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm
774
+	 * @param string $separator   used between the date and time formats.
775
+	 *                            ex: Dec 1, 2016{$separator}2pm
776
+	 * @return string
777
+	 * @throws ReflectionException
778
+	 * @throws InvalidArgumentException
779
+	 * @throws InvalidInterfaceException
780
+	 * @throws InvalidDataTypeException
781
+	 * @throws EE_Error
782
+	 */
783
+	public function date_and_time_range(
784
+		$dt_format = '',
785
+		$tm_format = '',
786
+		$conjunction = ' - ',
787
+		$separator = ' '
788
+	) {
789
+		$dt_format   = ! empty($dt_format) ? $dt_format : $this->_dt_frmt;
790
+		$tm_format   = ! empty($tm_format) ? $tm_format : $this->_tm_frmt;
791
+		$full_format = $dt_format . $separator . $tm_format;
792
+		// the range output depends on various conditions
793
+		switch (true) {
794
+			// start date timestamp and end date timestamp are the same.
795
+			case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')):
796
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format);
797
+				break;
798
+			// start and end date are the same but times are different
799
+			case ($this->start_date() === $this->end_date()):
800
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
801
+						  . $conjunction
802
+						  . $this->get_i18n_datetime('DTT_EVT_end', $tm_format);
803
+				break;
804
+			// all other conditions
805
+			default:
806
+				$output = $this->get_i18n_datetime('DTT_EVT_start', $full_format)
807
+						  . $conjunction
808
+						  . $this->get_i18n_datetime('DTT_EVT_end', $full_format);
809
+				break;
810
+		}
811
+		return $output;
812
+	}
813
+
814
+
815
+	/**
816
+	 * This echos the results of date and time range.
817
+	 *
818
+	 * @param string $dt_format
819
+	 * @param string $tm_format
820
+	 * @param string $conjunction
821
+	 * @return void
822
+	 * @throws ReflectionException
823
+	 * @throws InvalidArgumentException
824
+	 * @throws InvalidInterfaceException
825
+	 * @throws InvalidDataTypeException
826
+	 * @throws EE_Error
827
+	 * @see date_and_time_range() for more details on purpose.
828
+	 */
829
+	public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ')
830
+	{
831
+		echo esc_html($this->date_and_time_range($dt_format, $tm_format, $conjunction));
832
+	}
833
+
834
+
835
+	/**
836
+	 * get start date and start time
837
+	 *
838
+	 * @param string $dt_format - string representation of date format defaults to 'F j, Y'
839
+	 * @param string $tm_format - string representation of time format defaults to 'g:i a'
840
+	 * @return    mixed    string on success, FALSE on fail
841
+	 * @throws ReflectionException
842
+	 * @throws InvalidArgumentException
843
+	 * @throws InvalidInterfaceException
844
+	 * @throws InvalidDataTypeException
845
+	 * @throws EE_Error
846
+	 */
847
+	public function start_date_and_time($dt_format = '', $tm_format = '')
848
+	{
849
+		return $this->_show_datetime('', 'start', $dt_format, $tm_format);
850
+	}
851
+
852
+
853
+	/**
854
+	 * @param string $dt_frmt
855
+	 * @param string $tm_format
856
+	 * @throws ReflectionException
857
+	 * @throws InvalidArgumentException
858
+	 * @throws InvalidInterfaceException
859
+	 * @throws InvalidDataTypeException
860
+	 * @throws EE_Error
861
+	 */
862
+	public function e_start_date_and_time($dt_frmt = '', $tm_format = '')
863
+	{
864
+		$this->_show_datetime('', 'start', $dt_frmt, $tm_format, true);
865
+	}
866
+
867
+
868
+	/**
869
+	 * Shows the length of the event (start to end time).
870
+	 * Can be shown in 'seconds','minutes','hours', or 'days'.
871
+	 * By default, rounds up. (So if you use 'days', and then event
872
+	 * only occurs for 1 hour, it will return 1 day).
873
+	 *
874
+	 * @param string $units 'seconds','minutes','hours','days'
875
+	 * @param bool   $round_up
876
+	 * @return float|int|mixed
877
+	 * @throws ReflectionException
878
+	 * @throws InvalidArgumentException
879
+	 * @throws InvalidInterfaceException
880
+	 * @throws InvalidDataTypeException
881
+	 * @throws EE_Error
882
+	 */
883
+	public function length($units = 'seconds', $round_up = false)
884
+	{
885
+		$start           = $this->get_raw('DTT_EVT_start');
886
+		$end             = $this->get_raw('DTT_EVT_end');
887
+		$length_in_units = $end - $start;
888
+		switch ($units) {
889
+			// NOTE: We purposefully don't use "break;" in order to chain the divisions
890
+			/** @noinspection PhpMissingBreakStatementInspection */
891
+			// phpcs:disable PSR2.ControlStructures.SwitchDeclaration.TerminatingComment
892
+			case 'days':
893
+				$length_in_units /= 24;
894
+			/** @noinspection PhpMissingBreakStatementInspection */
895
+			case 'hours':
896
+				// fall through is intentional
897
+				$length_in_units /= 60;
898
+			/** @noinspection PhpMissingBreakStatementInspection */
899
+			case 'minutes':
900
+				// fall through is intentional
901
+				$length_in_units /= 60;
902
+			case 'seconds':
903
+			default:
904
+				$length_in_units = ceil($length_in_units);
905
+		}
906
+		// phpcs:enable
907
+		if ($round_up) {
908
+			$length_in_units = max($length_in_units, 1);
909
+		}
910
+		return $length_in_units;
911
+	}
912
+
913
+
914
+	/**
915
+	 *        get end date and time
916
+	 *
917
+	 * @param string $dt_frmt   - string representation of date format defaults to 'F j, Y'
918
+	 * @param string $tm_format - string representation of time format defaults to 'g:i a'
919
+	 * @return    mixed                string on success, FALSE on fail
920
+	 * @throws ReflectionException
921
+	 * @throws InvalidArgumentException
922
+	 * @throws InvalidInterfaceException
923
+	 * @throws InvalidDataTypeException
924
+	 * @throws EE_Error
925
+	 */
926
+	public function end_date_and_time($dt_frmt = '', $tm_format = '')
927
+	{
928
+		return $this->_show_datetime('', 'end', $dt_frmt, $tm_format);
929
+	}
930
+
931
+
932
+	/**
933
+	 * @param string $dt_frmt
934
+	 * @param string $tm_format
935
+	 * @throws ReflectionException
936
+	 * @throws InvalidArgumentException
937
+	 * @throws InvalidInterfaceException
938
+	 * @throws InvalidDataTypeException
939
+	 * @throws EE_Error
940
+	 */
941
+	public function e_end_date_and_time($dt_frmt = '', $tm_format = '')
942
+	{
943
+		$this->_show_datetime('', 'end', $dt_frmt, $tm_format, true);
944
+	}
945
+
946
+
947
+	/**
948
+	 *        get start timestamp
949
+	 *
950
+	 * @return        int
951
+	 * @throws ReflectionException
952
+	 * @throws InvalidArgumentException
953
+	 * @throws InvalidInterfaceException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws EE_Error
956
+	 */
957
+	public function start()
958
+	{
959
+		return $this->get_raw('DTT_EVT_start');
960
+	}
961
+
962
+
963
+	/**
964
+	 *        get end timestamp
965
+	 *
966
+	 * @return        int
967
+	 * @throws ReflectionException
968
+	 * @throws InvalidArgumentException
969
+	 * @throws InvalidInterfaceException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws EE_Error
972
+	 */
973
+	public function end()
974
+	{
975
+		return $this->get_raw('DTT_EVT_end');
976
+	}
977
+
978
+
979
+	/**
980
+	 *    get the registration limit for this datetime slot
981
+	 *
982
+	 * @return int|float                int = finite limit   EE_INF(float) = unlimited
983
+	 * @throws ReflectionException
984
+	 * @throws InvalidArgumentException
985
+	 * @throws InvalidInterfaceException
986
+	 * @throws InvalidDataTypeException
987
+	 * @throws EE_Error
988
+	 */
989
+	public function reg_limit()
990
+	{
991
+		return $this->get_raw('DTT_reg_limit');
992
+	}
993
+
994
+
995
+	/**
996
+	 *    have the tickets sold for this datetime, met or exceed the registration limit ?
997
+	 *
998
+	 * @return boolean
999
+	 * @throws ReflectionException
1000
+	 * @throws InvalidArgumentException
1001
+	 * @throws InvalidInterfaceException
1002
+	 * @throws InvalidDataTypeException
1003
+	 * @throws EE_Error
1004
+	 */
1005
+	public function sold_out()
1006
+	{
1007
+		return $this->reg_limit() > 0 && $this->sold() >= $this->reg_limit();
1008
+	}
1009
+
1010
+
1011
+	/**
1012
+	 * return the total number of spaces remaining at this venue.
1013
+	 * This only takes the venue's capacity into account, NOT the tickets available for sale
1014
+	 *
1015
+	 * @param bool $consider_tickets Whether to consider tickets remaining when determining if there are any spaces left
1016
+	 *                               Because if all tickets attached to this datetime have no spaces left,
1017
+	 *                               then this datetime IS effectively sold out.
1018
+	 *                               However, there are cases where we just want to know the spaces
1019
+	 *                               remaining for this particular datetime, hence the flag.
1020
+	 * @return int|float
1021
+	 * @throws ReflectionException
1022
+	 * @throws InvalidArgumentException
1023
+	 * @throws InvalidInterfaceException
1024
+	 * @throws InvalidDataTypeException
1025
+	 * @throws EE_Error
1026
+	 */
1027
+	public function spaces_remaining($consider_tickets = false)
1028
+	{
1029
+		// tickets remaining available for purchase
1030
+		// no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF
1031
+		$dtt_remaining = $this->reg_limit() - $this->sold_and_reserved();
1032
+		if (! $consider_tickets) {
1033
+			return $dtt_remaining;
1034
+		}
1035
+		$tickets_remaining = $this->tickets_remaining();
1036
+		return min($dtt_remaining, $tickets_remaining);
1037
+	}
1038
+
1039
+
1040
+	/**
1041
+	 * Counts the total tickets available
1042
+	 * (from all the different types of tickets which are available for this datetime).
1043
+	 *
1044
+	 * @param array $query_params @see
1045
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1046
+	 * @return int
1047
+	 * @throws ReflectionException
1048
+	 * @throws InvalidArgumentException
1049
+	 * @throws InvalidInterfaceException
1050
+	 * @throws InvalidDataTypeException
1051
+	 * @throws EE_Error
1052
+	 */
1053
+	public function tickets_remaining($query_params = [])
1054
+	{
1055
+		$sum     = 0;
1056
+		$tickets = $this->tickets($query_params);
1057
+		if (! empty($tickets)) {
1058
+			foreach ($tickets as $ticket) {
1059
+				if ($ticket instanceof EE_Ticket) {
1060
+					// get the actual amount of tickets that can be sold
1061
+					$qty = $ticket->qty('saleable');
1062
+					if ($qty === EE_INF) {
1063
+						return EE_INF;
1064
+					}
1065
+					// no negative ticket quantities plz
1066
+					if ($qty > 0) {
1067
+						$sum += $qty;
1068
+					}
1069
+				}
1070
+			}
1071
+		}
1072
+		return $sum;
1073
+	}
1074
+
1075
+
1076
+	/**
1077
+	 * Gets the count of all the tickets available at this datetime (not ticket types)
1078
+	 * before any were sold
1079
+	 *
1080
+	 * @param array $query_params @see
1081
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1082
+	 * @return int
1083
+	 * @throws ReflectionException
1084
+	 * @throws InvalidArgumentException
1085
+	 * @throws InvalidInterfaceException
1086
+	 * @throws InvalidDataTypeException
1087
+	 * @throws EE_Error
1088
+	 */
1089
+	public function sum_tickets_initially_available($query_params = [])
1090
+	{
1091
+		return $this->sum_related('Ticket', $query_params, 'TKT_qty');
1092
+	}
1093
+
1094
+
1095
+	/**
1096
+	 * Returns the lesser-of-the two: spaces remaining at this datetime, or
1097
+	 * the total tickets remaining (a sum of the tickets remaining for each ticket type
1098
+	 * that is available for this datetime).
1099
+	 *
1100
+	 * @return int
1101
+	 * @throws ReflectionException
1102
+	 * @throws InvalidArgumentException
1103
+	 * @throws InvalidInterfaceException
1104
+	 * @throws InvalidDataTypeException
1105
+	 * @throws EE_Error
1106
+	 */
1107
+	public function total_tickets_available_at_this_datetime()
1108
+	{
1109
+		return $this->spaces_remaining(true);
1110
+	}
1111
+
1112
+
1113
+	/**
1114
+	 * This simply compares the internal dtt for the given string with NOW
1115
+	 * and determines if the date is upcoming or not.
1116
+	 *
1117
+	 * @access public
1118
+	 * @return boolean
1119
+	 * @throws ReflectionException
1120
+	 * @throws InvalidArgumentException
1121
+	 * @throws InvalidInterfaceException
1122
+	 * @throws InvalidDataTypeException
1123
+	 * @throws EE_Error
1124
+	 */
1125
+	public function is_upcoming()
1126
+	{
1127
+		return ($this->get_raw('DTT_EVT_start') > time());
1128
+	}
1129
+
1130
+
1131
+	/**
1132
+	 * This simply compares the internal datetime for the given string with NOW
1133
+	 * and returns if the date is active (i.e. start and end time)
1134
+	 *
1135
+	 * @return boolean
1136
+	 * @throws ReflectionException
1137
+	 * @throws InvalidArgumentException
1138
+	 * @throws InvalidInterfaceException
1139
+	 * @throws InvalidDataTypeException
1140
+	 * @throws EE_Error
1141
+	 */
1142
+	public function is_active()
1143
+	{
1144
+		return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time());
1145
+	}
1146
+
1147
+
1148
+	/**
1149
+	 * This simply compares the internal dtt for the given string with NOW
1150
+	 * and determines if the date is expired or not.
1151
+	 *
1152
+	 * @return boolean
1153
+	 * @throws ReflectionException
1154
+	 * @throws InvalidArgumentException
1155
+	 * @throws InvalidInterfaceException
1156
+	 * @throws InvalidDataTypeException
1157
+	 * @throws EE_Error
1158
+	 */
1159
+	public function is_expired()
1160
+	{
1161
+		return ($this->get_raw('DTT_EVT_end') < time());
1162
+	}
1163
+
1164
+
1165
+	/**
1166
+	 * This returns the active status for whether an event is active, upcoming, or expired
1167
+	 *
1168
+	 * @return int return value will be one of the EE_Datetime status constants.
1169
+	 * @throws ReflectionException
1170
+	 * @throws InvalidArgumentException
1171
+	 * @throws InvalidInterfaceException
1172
+	 * @throws InvalidDataTypeException
1173
+	 * @throws EE_Error
1174
+	 */
1175
+	public function get_active_status()
1176
+	{
1177
+		$total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime();
1178
+		if ($total_tickets_for_this_dtt !== false && $total_tickets_for_this_dtt < 1) {
1179
+			return EE_Datetime::sold_out;
1180
+		}
1181
+		if ($this->is_expired()) {
1182
+			return EE_Datetime::expired;
1183
+		}
1184
+		if ($this->is_upcoming()) {
1185
+			return EE_Datetime::upcoming;
1186
+		}
1187
+		if ($this->is_active()) {
1188
+			return EE_Datetime::active;
1189
+		}
1190
+		return null;
1191
+	}
1192
+
1193
+
1194
+	/**
1195
+	 * This returns a nice display name for the datetime that is contingent on the span between the dates and times.
1196
+	 *
1197
+	 * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty.
1198
+	 * @return string
1199
+	 * @throws ReflectionException
1200
+	 * @throws InvalidArgumentException
1201
+	 * @throws InvalidInterfaceException
1202
+	 * @throws InvalidDataTypeException
1203
+	 * @throws EE_Error
1204
+	 */
1205
+	public function get_dtt_display_name($use_dtt_name = false)
1206
+	{
1207
+		if ($use_dtt_name) {
1208
+			$dtt_name = $this->name();
1209
+			if (! empty($dtt_name)) {
1210
+				return $dtt_name;
1211
+			}
1212
+		}
1213
+		// first condition is to see if the months are different
1214
+		if (
1215
+			date('m', $this->get_raw('DTT_EVT_start')) !== date('m', $this->get_raw('DTT_EVT_end'))
1216
+		) {
1217
+			$display_date = $this->start_date('M j\, Y g:i a') . ' - ' . $this->end_date('M j\, Y g:i a');
1218
+			// next condition is if its the same month but different day
1219
+		} else {
1220
+			if (
1221
+				date('m', $this->get_raw('DTT_EVT_start')) === date('m', $this->get_raw('DTT_EVT_end'))
1222
+				&& date('d', $this->get_raw('DTT_EVT_start')) !== date('d', $this->get_raw('DTT_EVT_end'))
1223
+			) {
1224
+				$display_date = $this->start_date('M j\, g:i a') . ' - ' . $this->end_date('M j\, g:i a Y');
1225
+			} else {
1226
+				$display_date = $this->start_date('F j\, Y')
1227
+								. ' @ '
1228
+								. $this->start_date('g:i a')
1229
+								. ' - '
1230
+								. $this->end_date('g:i a');
1231
+			}
1232
+		}
1233
+		return $display_date;
1234
+	}
1235
+
1236
+
1237
+	/**
1238
+	 * Gets all the tickets for this datetime
1239
+	 *
1240
+	 * @param array $query_params @see
1241
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1242
+	 * @return EE_Base_Class[]|EE_Ticket[]
1243
+	 * @throws ReflectionException
1244
+	 * @throws InvalidArgumentException
1245
+	 * @throws InvalidInterfaceException
1246
+	 * @throws InvalidDataTypeException
1247
+	 * @throws EE_Error
1248
+	 */
1249
+	public function tickets($query_params = [])
1250
+	{
1251
+		return $this->get_many_related('Ticket', $query_params);
1252
+	}
1253
+
1254
+
1255
+	/**
1256
+	 * Gets all the ticket types currently available for purchase
1257
+	 *
1258
+	 * @param array $query_params @see
1259
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1260
+	 * @return EE_Ticket[]
1261
+	 * @throws ReflectionException
1262
+	 * @throws InvalidArgumentException
1263
+	 * @throws InvalidInterfaceException
1264
+	 * @throws InvalidDataTypeException
1265
+	 * @throws EE_Error
1266
+	 */
1267
+	public function ticket_types_available_for_purchase($query_params = [])
1268
+	{
1269
+		// first check if datetime is valid
1270
+		if ($this->sold_out() || ! ($this->is_upcoming() || $this->is_active())) {
1271
+			return [];
1272
+		}
1273
+		if (empty($query_params)) {
1274
+			$query_params = [
1275
+				[
1276
+					'TKT_start_date' => ['<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')],
1277
+					'TKT_end_date'   => ['>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')],
1278
+					'TKT_deleted'    => false,
1279
+				],
1280
+			];
1281
+		}
1282
+		return $this->tickets($query_params);
1283
+	}
1284
+
1285
+
1286
+	/**
1287
+	 * @return EE_Base_Class|EE_Event
1288
+	 * @throws ReflectionException
1289
+	 * @throws InvalidArgumentException
1290
+	 * @throws InvalidInterfaceException
1291
+	 * @throws InvalidDataTypeException
1292
+	 * @throws EE_Error
1293
+	 */
1294
+	public function event()
1295
+	{
1296
+		return EEM_Event::instance()->get_one_by_ID($this->get('EVT_ID'));
1297
+	}
1298
+
1299
+
1300
+	/**
1301
+	 * Updates the DTT_sold attribute (and saves) based on the number of registrations for this datetime
1302
+	 * (via the tickets).
1303
+	 *
1304
+	 * @return int
1305
+	 * @throws ReflectionException
1306
+	 * @throws InvalidArgumentException
1307
+	 * @throws InvalidInterfaceException
1308
+	 * @throws InvalidDataTypeException
1309
+	 * @throws EE_Error
1310
+	 */
1311
+	public function update_sold()
1312
+	{
1313
+		$count_regs_for_this_datetime = EEM_Registration::instance()->count(
1314
+			[
1315
+				[
1316
+					'STS_ID'                 => RegStatus::APPROVED,
1317
+					'REG_deleted'            => 0,
1318
+					'Ticket.Datetime.DTT_ID' => $this->ID(),
1319
+				],
1320
+			]
1321
+		);
1322
+		$this->set_sold($count_regs_for_this_datetime);
1323
+		$this->save();
1324
+		return $count_regs_for_this_datetime;
1325
+	}
1326
+
1327
+
1328
+	/**
1329
+	 * Adds a venue to this event
1330
+	 *
1331
+	 * @param int|EE_Venue /int $venue_id_or_obj
1332
+	 * @return EE_Base_Class|EE_Venue
1333
+	 * @throws EE_Error
1334
+	 * @throws ReflectionException
1335
+	 */
1336
+	public function add_venue($venue_id_or_obj): EE_Venue
1337
+	{
1338
+		return $this->_add_relation_to($venue_id_or_obj, 'Venue');
1339
+	}
1340
+
1341
+
1342
+	/**
1343
+	 * Removes a venue from the event
1344
+	 *
1345
+	 * @param EE_Venue /int $venue_id_or_obj
1346
+	 * @return EE_Base_Class|EE_Venue
1347
+	 * @throws EE_Error
1348
+	 * @throws ReflectionException
1349
+	 */
1350
+	public function remove_venue($venue_id_or_obj): EE_Venue
1351
+	{
1352
+		$venue_id_or_obj = ! empty($venue_id_or_obj) ? $venue_id_or_obj : $this->venue();
1353
+		return $this->_remove_relation_to($venue_id_or_obj, 'Venue');
1354
+	}
1355
+
1356
+
1357
+	/**
1358
+	 * Gets the venue related to the event. May provide additional $query_params if desired
1359
+	 *
1360
+	 * @param array $query_params @see
1361
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1362
+	 * @return int
1363
+	 * @throws EE_Error
1364
+	 * @throws ReflectionException
1365
+	 */
1366
+	public function venue_ID(array $query_params = []): int
1367
+	{
1368
+		// If no $query_params have been passed, use the VNU_ID assigned to the Datetime itself
1369
+		if (empty($query_params)) {
1370
+			return (int) $this->get('VNU_ID');
1371
+		}
1372
+		// $query_params set, pull the first related venue using those
1373
+		$venue = $this->get_first_related('Venue', $query_params);
1374
+		return $venue instanceof EE_Venue
1375
+			? $venue->ID()
1376
+			: 0;
1377
+	}
1378
+
1379
+
1380
+	/**
1381
+	 * Gets the venue related to the event. May provide additional $query_params if desired
1382
+	 *
1383
+	 * @param array $query_params @see
1384
+	 *                            https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
1385
+	 * @return EE_Base_Class|EE_Venue|null
1386
+	 * @throws EE_Error
1387
+	 * @throws ReflectionException
1388
+	 */
1389
+	public function venue(array $query_params = [])
1390
+	{
1391
+		// If no $query_params have been passed, use the VNU_ID assigned to the Datetime itself
1392
+		if (empty($query_params)) {
1393
+			$VNU_ID = $this->venue_ID();
1394
+			return $VNU_ID ? EEM_Venue::instance()->get_one_by_ID($VNU_ID) : null;
1395
+		}
1396
+		return $this->get_first_related('Venue', $query_params);
1397
+	}
1398
+
1399
+
1400
+	/**
1401
+	 * @param EE_Base_Class|int|string $otherObjectModelObjectOrID
1402
+	 * @param string                   $relationName
1403
+	 * @param array                    $extra_join_model_fields_n_values
1404
+	 * @param string|null              $cache_id
1405
+	 * @return EE_Base_Class
1406
+	 * @throws EE_Error
1407
+	 * @throws ReflectionException
1408
+	 * @since   5.0.0.p
1409
+	 */
1410
+	public function _add_relation_to(
1411
+		$otherObjectModelObjectOrID,
1412
+		$relationName,
1413
+		$extra_join_model_fields_n_values = [],
1414
+		$cache_id = null
1415
+	) {
1416
+		// if we're adding a new relation to a ticket
1417
+		if ($relationName === 'Ticket' && ! $this->hasRelation($otherObjectModelObjectOrID, $relationName)) {
1418
+			/** @var EE_Ticket $ticket */
1419
+			$ticket = EEM_Ticket::instance()->ensure_is_obj($otherObjectModelObjectOrID);
1420
+			$this->increaseSold($ticket->sold(), false);
1421
+			$this->increaseReserved($ticket->reserved());
1422
+			$this->save();
1423
+			$otherObjectModelObjectOrID = $ticket;
1424
+		}
1425
+		return parent::_add_relation_to(
1426
+			$otherObjectModelObjectOrID,
1427
+			$relationName,
1428
+			$extra_join_model_fields_n_values,
1429
+			$cache_id
1430
+		);
1431
+	}
1432
+
1433
+
1434
+	/**
1435
+	 * @param EE_Base_Class|int|string $otherObjectModelObjectOrID
1436
+	 * @param string                   $relationName
1437
+	 * @param array                    $where_query
1438
+	 * @return bool|EE_Base_Class|null
1439
+	 * @throws EE_Error
1440
+	 * @throws ReflectionException
1441
+	 * @since   5.0.0.p
1442
+	 */
1443
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = [])
1444
+	{
1445
+		if ($relationName === 'Ticket' && $this->hasRelation($otherObjectModelObjectOrID, $relationName)) {
1446
+			/** @var EE_Ticket $ticket */
1447
+			$ticket = EEM_Ticket::instance()->ensure_is_obj($otherObjectModelObjectOrID);
1448
+			$this->decreaseSold($ticket->sold());
1449
+			$this->decreaseReserved($ticket->reserved());
1450
+			$this->save();
1451
+			$otherObjectModelObjectOrID = $ticket;
1452
+		}
1453
+		return parent::_remove_relation_to(
1454
+			$otherObjectModelObjectOrID,
1455
+			$relationName,
1456
+			$where_query
1457
+		);
1458
+	}
1459
+
1460
+
1461
+	/**
1462
+	 * Removes ALL the related things for the $relationName.
1463
+	 *
1464
+	 * @param string $relationName
1465
+	 * @param array  $where_query_params
1466
+	 * @return EE_Base_Class
1467
+	 * @throws ReflectionException
1468
+	 * @throws InvalidArgumentException
1469
+	 * @throws InvalidInterfaceException
1470
+	 * @throws InvalidDataTypeException
1471
+	 * @throws EE_Error
1472
+	 * @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions
1473
+	 */
1474
+	public function _remove_relations($relationName, $where_query_params = [])
1475
+	{
1476
+		if ($relationName === 'Ticket') {
1477
+			$tickets = $this->tickets();
1478
+			foreach ($tickets as $ticket) {
1479
+				$this->decreaseSold($ticket->sold());
1480
+				$this->decreaseReserved($ticket->reserved());
1481
+				$this->save();
1482
+			}
1483
+		}
1484
+		return parent::_remove_relations($relationName, $where_query_params);
1485
+	}
1486
+
1487
+
1488
+	/*******************************************************************
1489 1489
      ***********************  DEPRECATED METHODS  **********************
1490 1490
      *******************************************************************/
1491 1491
 
1492 1492
 
1493
-    /**
1494
-     * Increments sold by amount passed by $qty, and persists it immediately to the database.
1495
-     *
1496
-     * @param int $qty
1497
-     * @return boolean
1498
-     * @throws ReflectionException
1499
-     * @throws InvalidArgumentException
1500
-     * @throws InvalidInterfaceException
1501
-     * @throws InvalidDataTypeException
1502
-     * @throws EE_Error
1503
-     * @deprecated 4.9.80.p
1504
-     */
1505
-    public function increase_sold($qty = 1)
1506
-    {
1507
-        EE_Error::doing_it_wrong(
1508
-            __FUNCTION__,
1509
-            esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'),
1510
-            '4.9.80.p',
1511
-            '5.0.0.p'
1512
-        );
1513
-        return $this->increaseSold($qty);
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
1519
-     * to save afterwards.)
1520
-     *
1521
-     * @param int $qty
1522
-     * @return boolean
1523
-     * @throws ReflectionException
1524
-     * @throws InvalidArgumentException
1525
-     * @throws InvalidInterfaceException
1526
-     * @throws InvalidDataTypeException
1527
-     * @throws EE_Error
1528
-     * @deprecated 4.9.80.p
1529
-     */
1530
-    public function decrease_sold($qty = 1)
1531
-    {
1532
-        EE_Error::doing_it_wrong(
1533
-            __FUNCTION__,
1534
-            esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'),
1535
-            '4.9.80.p',
1536
-            '5.0.0.p'
1537
-        );
1538
-        return $this->decreaseSold($qty);
1539
-    }
1540
-
1541
-
1542
-    /**
1543
-     * Increments reserved by amount passed by $qty, and persists it immediately to the database.
1544
-     *
1545
-     * @param int $qty
1546
-     * @return boolean indicating success
1547
-     * @throws ReflectionException
1548
-     * @throws InvalidArgumentException
1549
-     * @throws InvalidInterfaceException
1550
-     * @throws InvalidDataTypeException
1551
-     * @throws EE_Error
1552
-     * @deprecated 4.9.80.p
1553
-     */
1554
-    public function increase_reserved($qty = 1)
1555
-    {
1556
-        EE_Error::doing_it_wrong(
1557
-            __FUNCTION__,
1558
-            esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'),
1559
-            '4.9.80.p',
1560
-            '5.0.0.p'
1561
-        );
1562
-        return $this->increaseReserved($qty);
1563
-    }
1564
-
1565
-
1566
-    /**
1567
-     * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
1568
-     *
1569
-     * @param int $qty
1570
-     * @return boolean
1571
-     * @throws ReflectionException
1572
-     * @throws InvalidArgumentException
1573
-     * @throws InvalidInterfaceException
1574
-     * @throws InvalidDataTypeException
1575
-     * @throws EE_Error
1576
-     * @deprecated 4.9.80.p
1577
-     */
1578
-    public function decrease_reserved($qty = 1)
1579
-    {
1580
-        EE_Error::doing_it_wrong(
1581
-            __FUNCTION__,
1582
-            esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'),
1583
-            '4.9.80.p',
1584
-            '5.0.0.p'
1585
-        );
1586
-        return $this->decreaseReserved($qty);
1587
-    }
1493
+	/**
1494
+	 * Increments sold by amount passed by $qty, and persists it immediately to the database.
1495
+	 *
1496
+	 * @param int $qty
1497
+	 * @return boolean
1498
+	 * @throws ReflectionException
1499
+	 * @throws InvalidArgumentException
1500
+	 * @throws InvalidInterfaceException
1501
+	 * @throws InvalidDataTypeException
1502
+	 * @throws EE_Error
1503
+	 * @deprecated 4.9.80.p
1504
+	 */
1505
+	public function increase_sold($qty = 1)
1506
+	{
1507
+		EE_Error::doing_it_wrong(
1508
+			__FUNCTION__,
1509
+			esc_html__('Please use EE_Datetime::increaseSold() instead', 'event_espresso'),
1510
+			'4.9.80.p',
1511
+			'5.0.0.p'
1512
+		);
1513
+		return $this->increaseSold($qty);
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Decrements (subtracts) sold amount passed by $qty directly in the DB and on the model object. (Ie, no need
1519
+	 * to save afterwards.)
1520
+	 *
1521
+	 * @param int $qty
1522
+	 * @return boolean
1523
+	 * @throws ReflectionException
1524
+	 * @throws InvalidArgumentException
1525
+	 * @throws InvalidInterfaceException
1526
+	 * @throws InvalidDataTypeException
1527
+	 * @throws EE_Error
1528
+	 * @deprecated 4.9.80.p
1529
+	 */
1530
+	public function decrease_sold($qty = 1)
1531
+	{
1532
+		EE_Error::doing_it_wrong(
1533
+			__FUNCTION__,
1534
+			esc_html__('Please use EE_Datetime::decreaseSold() instead', 'event_espresso'),
1535
+			'4.9.80.p',
1536
+			'5.0.0.p'
1537
+		);
1538
+		return $this->decreaseSold($qty);
1539
+	}
1540
+
1541
+
1542
+	/**
1543
+	 * Increments reserved by amount passed by $qty, and persists it immediately to the database.
1544
+	 *
1545
+	 * @param int $qty
1546
+	 * @return boolean indicating success
1547
+	 * @throws ReflectionException
1548
+	 * @throws InvalidArgumentException
1549
+	 * @throws InvalidInterfaceException
1550
+	 * @throws InvalidDataTypeException
1551
+	 * @throws EE_Error
1552
+	 * @deprecated 4.9.80.p
1553
+	 */
1554
+	public function increase_reserved($qty = 1)
1555
+	{
1556
+		EE_Error::doing_it_wrong(
1557
+			__FUNCTION__,
1558
+			esc_html__('Please use EE_Datetime::increaseReserved() instead', 'event_espresso'),
1559
+			'4.9.80.p',
1560
+			'5.0.0.p'
1561
+		);
1562
+		return $this->increaseReserved($qty);
1563
+	}
1564
+
1565
+
1566
+	/**
1567
+	 * Decrements (subtracts) reserved by amount passed by $qty, and persists it immediately to the database.
1568
+	 *
1569
+	 * @param int $qty
1570
+	 * @return boolean
1571
+	 * @throws ReflectionException
1572
+	 * @throws InvalidArgumentException
1573
+	 * @throws InvalidInterfaceException
1574
+	 * @throws InvalidDataTypeException
1575
+	 * @throws EE_Error
1576
+	 * @deprecated 4.9.80.p
1577
+	 */
1578
+	public function decrease_reserved($qty = 1)
1579
+	{
1580
+		EE_Error::doing_it_wrong(
1581
+			__FUNCTION__,
1582
+			esc_html__('Please use EE_Datetime::decreaseReserved() instead', 'event_espresso'),
1583
+			'4.9.80.p',
1584
+			'5.0.0.p'
1585
+		);
1586
+		return $this->decreaseReserved($qty);
1587
+	}
1588 1588
 }
Please login to merge, or discard this patch.
core/data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_answers.dmsstage.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@  discard block
 block discarded – undo
40 40
     {
41 41
         global $wpdb;
42 42
         $this->_pretty_name = esc_html__("Answers", "event_espresso");
43
-        $this->_old_table   = $wpdb->prefix . "events_answer";
43
+        $this->_old_table   = $wpdb->prefix."events_answer";
44 44
         // join to attendee and then join to events table
45 45
         $this->select_expression   = 'ans.*, e.event_status';
46 46
         $this->_extra_where_sql    = ' AS ans
47
-            INNER JOIN ' . $wpdb->prefix . 'events_attendee AS att ON ans.attendee_id = att.id
48
-            INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id = e.id
47
+            INNER JOIN ' . $wpdb->prefix.'events_attendee AS att ON ans.attendee_id = att.id
48
+            INNER JOIN ' . $wpdb->prefix.'events_detail AS e ON att.event_id = e.id
49 49
             WHERE e.event_status !="D"';
50
-        $this->_new_answer_table   = $wpdb->prefix . "esp_answer";
51
-        $this->_new_question_table = $wpdb->prefix . "esp_question";
50
+        $this->_new_answer_table   = $wpdb->prefix."esp_answer";
51
+        $this->_new_question_table = $wpdb->prefix."esp_question";
52 52
         parent::__construct();
53 53
     }
54 54
 
@@ -60,15 +60,15 @@  discard block
 block discarded – undo
60 60
     {
61 61
         // get the new REGs for the old answer
62 62
         global $wpdb;
63
-        $old_attendee_table = $wpdb->prefix . "events_attendee";
64
-        $new_reg_table      = $wpdb->prefix . "esp_registration";
63
+        $old_attendee_table = $wpdb->prefix."events_attendee";
64
+        $new_reg_table      = $wpdb->prefix."esp_registration";
65 65
         $regs               =
66 66
             $this->get_migration_script()->get_mapping_new_pk(
67 67
                 $old_attendee_table,
68 68
                 $old_row['attendee_id'],
69 69
                 $new_reg_table
70 70
             );
71
-        if (! $regs) {
71
+        if ( ! $regs) {
72 72
             $this->add_error(
73 73
                 sprintf(
74 74
                     esc_html__(
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     private function _insert_new_answer(array $old_answer, int $new_reg_id): void
99 99
     {
100 100
         global $wpdb;
101
-        $old_question_table = $wpdb->prefix . "events_question";
101
+        $old_question_table = $wpdb->prefix."events_question";
102 102
         $new_question_id    =
103 103
             $this->get_migration_script()->get_mapping_new_pk(
104 104
                 $old_question_table,
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
             'QST_ID'    => $new_question_id,
124 124
             'ANS_value' => $ans_value,
125 125
         ];
126
-        $data_types    = [
127
-            '%d',// REG_ID
128
-            '%d',// QST_ID
129
-            '%s',// ANS_value
126
+        $data_types = [
127
+            '%d', // REG_ID
128
+            '%d', // QST_ID
129
+            '%s', // ANS_value
130 130
         ];
131
-        $success       = $wpdb->insert($this->_new_answer_table, $cols_n_values, $data_types);
132
-        if (! $success) {
131
+        $success = $wpdb->insert($this->_new_answer_table, $cols_n_values, $data_types);
132
+        if ( ! $success) {
133 133
             $this->add_error(
134 134
                 $this->get_migration_script()->_create_error_message_for_db_insertion(
135 135
                     $this->_old_table,
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
         global $wpdb;
158 158
         return $wpdb->get_row(
159 159
             $wpdb->prepare(
160
-                "SELECT QST_type, QST_system FROM " . $this->_new_question_table . " WHERE QST_ID=%d LIMIT 1",
160
+                "SELECT QST_type, QST_system FROM ".$this->_new_question_table." WHERE QST_ID=%d LIMIT 1",
161 161
                 $question_id
162 162
             ),
163 163
             ARRAY_A
Please login to merge, or discard this patch.
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -30,142 +30,142 @@
 block discarded – undo
30 30
 
31 31
 class EE_DMS_4_1_0_answers extends EE_Data_Migration_Script_Stage_Table
32 32
 {
33
-    private string $_new_answer_table;
33
+	private string $_new_answer_table;
34 34
 
35
-    private string $_new_question_table;
35
+	private string $_new_question_table;
36 36
 
37 37
 
38
-    public function __construct()
39
-    {
40
-        global $wpdb;
41
-        $this->_pretty_name = esc_html__("Answers", "event_espresso");
42
-        $this->_old_table   = $wpdb->prefix . "events_answer";
43
-        // join to attendee and then join to events table
44
-        $this->select_expression   = 'ans.*, e.event_status';
45
-        $this->_extra_where_sql    = ' AS ans
38
+	public function __construct()
39
+	{
40
+		global $wpdb;
41
+		$this->_pretty_name = esc_html__("Answers", "event_espresso");
42
+		$this->_old_table   = $wpdb->prefix . "events_answer";
43
+		// join to attendee and then join to events table
44
+		$this->select_expression   = 'ans.*, e.event_status';
45
+		$this->_extra_where_sql    = ' AS ans
46 46
             INNER JOIN ' . $wpdb->prefix . 'events_attendee AS att ON ans.attendee_id = att.id
47 47
             INNER JOIN ' . $wpdb->prefix . 'events_detail AS e ON att.event_id = e.id
48 48
             WHERE e.event_status !="D"';
49
-        $this->_new_answer_table   = $wpdb->prefix . "esp_answer";
50
-        $this->_new_question_table = $wpdb->prefix . "esp_question";
51
-        parent::__construct();
52
-    }
49
+		$this->_new_answer_table   = $wpdb->prefix . "esp_answer";
50
+		$this->_new_question_table = $wpdb->prefix . "esp_question";
51
+		parent::__construct();
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * @throws EE_Error
57
-     */
58
-    protected function _migrate_old_row($old_row)
59
-    {
60
-        // get the new REGs for the old answer
61
-        global $wpdb;
62
-        $old_attendee_table = $wpdb->prefix . "events_attendee";
63
-        $new_reg_table      = $wpdb->prefix . "esp_registration";
64
-        $regs               =
65
-            $this->get_migration_script()->get_mapping_new_pk(
66
-                $old_attendee_table,
67
-                $old_row['attendee_id'],
68
-                $new_reg_table
69
-            );
70
-        if (! $regs) {
71
-            $this->add_error(
72
-                sprintf(
73
-                    esc_html__(
74
-                        "Could not find new registrations for old attendee %d when creating answer %s",
75
-                        "event_espresso"
76
-                    ),
77
-                    $old_row['attendee_id'],
78
-                    $this->_json_encode($old_row)
79
-                )
80
-            );
81
-            return;
82
-        }
83
-        // as inefficient as this sounds, we create an answer per REGISTRATION, (even if the registrations use the same attendee)
84
-        foreach ($regs as $new_reg_id) {
85
-            $this->_insert_new_answer($old_row, $new_reg_id);
86
-        }
87
-    }
55
+	/**
56
+	 * @throws EE_Error
57
+	 */
58
+	protected function _migrate_old_row($old_row)
59
+	{
60
+		// get the new REGs for the old answer
61
+		global $wpdb;
62
+		$old_attendee_table = $wpdb->prefix . "events_attendee";
63
+		$new_reg_table      = $wpdb->prefix . "esp_registration";
64
+		$regs               =
65
+			$this->get_migration_script()->get_mapping_new_pk(
66
+				$old_attendee_table,
67
+				$old_row['attendee_id'],
68
+				$new_reg_table
69
+			);
70
+		if (! $regs) {
71
+			$this->add_error(
72
+				sprintf(
73
+					esc_html__(
74
+						"Could not find new registrations for old attendee %d when creating answer %s",
75
+						"event_espresso"
76
+					),
77
+					$old_row['attendee_id'],
78
+					$this->_json_encode($old_row)
79
+				)
80
+			);
81
+			return;
82
+		}
83
+		// as inefficient as this sounds, we create an answer per REGISTRATION, (even if the registrations use the same attendee)
84
+		foreach ($regs as $new_reg_id) {
85
+			$this->_insert_new_answer($old_row, $new_reg_id);
86
+		}
87
+	}
88 88
 
89 89
 
90
-    /**
91
-     * @param array $old_answer
92
-     * @param int   $new_reg_id
93
-     * @return void
94
-     * @throws EE_Error
95
-     * @global wpdb $wpdb
96
-     */
97
-    private function _insert_new_answer(array $old_answer, int $new_reg_id): void
98
-    {
99
-        global $wpdb;
100
-        $old_question_table = $wpdb->prefix . "events_question";
101
-        $new_question_id    =
102
-            $this->get_migration_script()->get_mapping_new_pk(
103
-                $old_question_table,
104
-                $old_answer['question_id'],
105
-                $this->_new_question_table
106
-            );
90
+	/**
91
+	 * @param array $old_answer
92
+	 * @param int   $new_reg_id
93
+	 * @return void
94
+	 * @throws EE_Error
95
+	 * @global wpdb $wpdb
96
+	 */
97
+	private function _insert_new_answer(array $old_answer, int $new_reg_id): void
98
+	{
99
+		global $wpdb;
100
+		$old_question_table = $wpdb->prefix . "events_question";
101
+		$new_question_id    =
102
+			$this->get_migration_script()->get_mapping_new_pk(
103
+				$old_question_table,
104
+				$old_answer['question_id'],
105
+				$this->_new_question_table
106
+			);
107 107
 
108
-        // If we don't have a mapped question_id we don't have an EE4 question to migrate this answer to.
109
-        // The EE3 question may have been deleted but registration answers remain in the DB.
110
-        if (empty($new_question_id)) {
111
-            return;
112
-        }
108
+		// If we don't have a mapped question_id we don't have an EE4 question to migrate this answer to.
109
+		// The EE3 question may have been deleted but registration answers remain in the DB.
110
+		if (empty($new_question_id)) {
111
+			return;
112
+		}
113 113
 
114
-        $question_row = $this->_get_question_type_and_system($new_question_id);
115
-        if ($question_row['QST_system']) {
116
-            // It's an answer to a system question? EE3 used to store that on both the attendee and the answers column,
117
-            // but not EE4! It's just stored in the attendee meta table. The answers table is ONLY for answers to custom
118
-            // questions.
119
-            return;
120
-        }
121
-        if ($question_row['QST_type'] == 'MULTIPLE') {
122
-            $ans_value = serialize(explode(",", stripslashes($old_answer['answer'])));
123
-        } else {
124
-            $ans_value = stripslashes($old_answer['answer']);
125
-        }
126
-        $cols_n_values = [
127
-            'REG_ID'    => $new_reg_id,
128
-            'QST_ID'    => $new_question_id,
129
-            'ANS_value' => $ans_value,
130
-        ];
131
-        $data_types    = [
132
-            '%d',// REG_ID
133
-            '%d',// QST_ID
134
-            '%s',// ANS_value
135
-        ];
136
-        $success       = $wpdb->insert($this->_new_answer_table, $cols_n_values, $data_types);
137
-        if (! $success) {
138
-            $this->add_error(
139
-                $this->get_migration_script()->_create_error_message_for_db_insertion(
140
-                    $this->_old_table,
141
-                    $old_answer,
142
-                    $this->_new_answer_table,
143
-                    $cols_n_values,
144
-                    $data_types
145
-                )
146
-            );
147
-        }
148
-    }
114
+		$question_row = $this->_get_question_type_and_system($new_question_id);
115
+		if ($question_row['QST_system']) {
116
+			// It's an answer to a system question? EE3 used to store that on both the attendee and the answers column,
117
+			// but not EE4! It's just stored in the attendee meta table. The answers table is ONLY for answers to custom
118
+			// questions.
119
+			return;
120
+		}
121
+		if ($question_row['QST_type'] == 'MULTIPLE') {
122
+			$ans_value = serialize(explode(",", stripslashes($old_answer['answer'])));
123
+		} else {
124
+			$ans_value = stripslashes($old_answer['answer']);
125
+		}
126
+		$cols_n_values = [
127
+			'REG_ID'    => $new_reg_id,
128
+			'QST_ID'    => $new_question_id,
129
+			'ANS_value' => $ans_value,
130
+		];
131
+		$data_types    = [
132
+			'%d',// REG_ID
133
+			'%d',// QST_ID
134
+			'%s',// ANS_value
135
+		];
136
+		$success       = $wpdb->insert($this->_new_answer_table, $cols_n_values, $data_types);
137
+		if (! $success) {
138
+			$this->add_error(
139
+				$this->get_migration_script()->_create_error_message_for_db_insertion(
140
+					$this->_old_table,
141
+					$old_answer,
142
+					$this->_new_answer_table,
143
+					$cols_n_values,
144
+					$data_types
145
+				)
146
+			);
147
+		}
148
+	}
149 149
 
150 150
 
151
-    /**
152
-     * Gets the question's type
153
-     *
154
-     * @param int   $question_id
155
-     * @return array
156
-     *  - @type string $QST_type
157
-     *  - @type string $QST_system
158
-     * @global wpdb $wpdb
159
-     */
160
-    private function _get_question_type_and_system(int $question_id): array
161
-    {
162
-        global $wpdb;
163
-        return $wpdb->get_row(
164
-            $wpdb->prepare(
165
-                "SELECT QST_type, QST_system FROM " . $this->_new_question_table . " WHERE QST_ID=%d LIMIT 1",
166
-                $question_id
167
-            ),
168
-            ARRAY_A
169
-        );
170
-    }
151
+	/**
152
+	 * Gets the question's type
153
+	 *
154
+	 * @param int   $question_id
155
+	 * @return array
156
+	 *  - @type string $QST_type
157
+	 *  - @type string $QST_system
158
+	 * @global wpdb $wpdb
159
+	 */
160
+	private function _get_question_type_and_system(int $question_id): array
161
+	{
162
+		global $wpdb;
163
+		return $wpdb->get_row(
164
+			$wpdb->prepare(
165
+				"SELECT QST_type, QST_system FROM " . $this->_new_question_table . " WHERE QST_ID=%d LIMIT 1",
166
+				$question_id
167
+			),
168
+			ARRAY_A
169
+		);
170
+	}
171 171
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -37,138 +37,138 @@
 block discarded – undo
37 37
  * @since           4.0
38 38
  */
39 39
 if (function_exists('espresso_version')) {
40
-    if (! function_exists('espresso_duplicate_plugin_error')) {
41
-        /**
42
-         *    espresso_duplicate_plugin_error
43
-         *    displays if more than one version of EE is activated at the same time.
44
-         */
45
-        function espresso_duplicate_plugin_error()
46
-        {
47
-            ?>
40
+	if (! function_exists('espresso_duplicate_plugin_error')) {
41
+		/**
42
+		 *    espresso_duplicate_plugin_error
43
+		 *    displays if more than one version of EE is activated at the same time.
44
+		 */
45
+		function espresso_duplicate_plugin_error()
46
+		{
47
+			?>
48 48
 <div class="error">
49 49
     <p>
50 50
         <?php
51
-                    echo esc_html__(
52
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
-                        'event_espresso'
54
-                    ); ?>
51
+					echo esc_html__(
52
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
53
+						'event_espresso'
54
+					); ?>
55 55
     </p>
56 56
 </div>
57 57
 <?php
58
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
59
-        }
60
-    }
61
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
58
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
59
+		}
60
+	}
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 } else {
63
-    define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
-        /**
66
-         * espresso_minimum_php_version_error
67
-         *
68
-         * @return void
69
-         */
70
-        function espresso_minimum_php_version_error()
71
-        {
72
-            ?>
63
+	define('EE_MIN_PHP_VER_REQUIRED', '7.4.0');
64
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
65
+		/**
66
+		 * espresso_minimum_php_version_error
67
+		 *
68
+		 * @return void
69
+		 */
70
+		function espresso_minimum_php_version_error()
71
+		{
72
+			?>
73 73
 <div class="error">
74 74
     <p>
75 75
         <?php
76
-                    printf(
77
-                        esc_html__(
78
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
-                            'event_espresso'
80
-                        ),
81
-                        EE_MIN_PHP_VER_REQUIRED,
82
-                        PHP_VERSION,
83
-                        '<br/>',
84
-                        '<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
-                    );
86
-        ?>
76
+					printf(
77
+						esc_html__(
78
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
79
+							'event_espresso'
80
+						),
81
+						EE_MIN_PHP_VER_REQUIRED,
82
+						PHP_VERSION,
83
+						'<br/>',
84
+						'<a href="https://www.php.net/downloads.php">https://php.net/downloads.php</a>'
85
+					);
86
+		?>
87 87
     </p>
88 88
 </div>
89 89
 <?php
90
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
91
-        }
90
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
91
+		}
92 92
 
93
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
-    } else {
95
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
93
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
94
+	} else {
95
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
96 96
 
97
-        require_once __DIR__ . '/vendor/autoload.php';
97
+		require_once __DIR__ . '/vendor/autoload.php';
98 98
 
99
-        /**
100
-         * espresso_version
101
-         * Returns the plugin version
102
-         *
103
-         * @return string
104
-         */
105
-        function espresso_version(): string
106
-        {
107
-            return apply_filters('FHEE__espresso__espresso_version', '5.0.28.rc.000');
108
-        }
99
+		/**
100
+		 * espresso_version
101
+		 * Returns the plugin version
102
+		 *
103
+		 * @return string
104
+		 */
105
+		function espresso_version(): string
106
+		{
107
+			return apply_filters('FHEE__espresso__espresso_version', '5.0.28.rc.000');
108
+		}
109 109
 
110
-        /**
111
-         * espresso_plugin_activation
112
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
-         */
114
-        function espresso_plugin_activation()
115
-        {
116
-            update_option('ee_espresso_activation', true);
117
-            update_option('event-espresso-core_allow_tracking', 'no');
118
-            update_option('event-espresso-core_tracking_notice', 'hide');
119
-            // Run WP GraphQL activation callback
120
-            espressoLoadWpGraphQL();
121
-            graphql_activation_callback();
122
-        }
110
+		/**
111
+		 * espresso_plugin_activation
112
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
113
+		 */
114
+		function espresso_plugin_activation()
115
+		{
116
+			update_option('ee_espresso_activation', true);
117
+			update_option('event-espresso-core_allow_tracking', 'no');
118
+			update_option('event-espresso-core_tracking_notice', 'hide');
119
+			// Run WP GraphQL activation callback
120
+			espressoLoadWpGraphQL();
121
+			graphql_activation_callback();
122
+		}
123 123
 
124
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
124
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
125 125
 
126
-        /**
127
-         * espresso_plugin_deactivation
128
-         */
129
-        function espresso_plugin_deactivation()
130
-        {
131
-            // Run WP GraphQL deactivation callback
132
-            espressoLoadWpGraphQL();
133
-            graphql_deactivation_callback();
134
-            delete_option('event-espresso-core_allow_tracking');
135
-            delete_option('event-espresso-core_tracking_notice');
136
-        }
137
-        register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
126
+		/**
127
+		 * espresso_plugin_deactivation
128
+		 */
129
+		function espresso_plugin_deactivation()
130
+		{
131
+			// Run WP GraphQL deactivation callback
132
+			espressoLoadWpGraphQL();
133
+			graphql_deactivation_callback();
134
+			delete_option('event-espresso-core_allow_tracking');
135
+			delete_option('event-espresso-core_tracking_notice');
136
+		}
137
+		register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
138 138
 
139
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
140
-        bootstrap_espresso();
141
-    }
139
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
140
+		bootstrap_espresso();
141
+	}
142 142
 }
143 143
 
144 144
 if (! function_exists('espresso_deactivate_plugin')) {
145
-    /**
146
-     *    deactivate_plugin
147
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
-     *
149
-     * @access public
150
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
-     * @return    void
152
-     */
153
-    function espresso_deactivate_plugin(string $plugin_basename = '')
154
-    {
155
-        if (! function_exists('deactivate_plugins')) {
156
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
-        }
158
-        unset($_GET['activate'], $_REQUEST['activate']);
159
-        deactivate_plugins($plugin_basename);
160
-    }
145
+	/**
146
+	 *    deactivate_plugin
147
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
148
+	 *
149
+	 * @access public
150
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
151
+	 * @return    void
152
+	 */
153
+	function espresso_deactivate_plugin(string $plugin_basename = '')
154
+	{
155
+		if (! function_exists('deactivate_plugins')) {
156
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
157
+		}
158
+		unset($_GET['activate'], $_REQUEST['activate']);
159
+		deactivate_plugins($plugin_basename);
160
+	}
161 161
 }
162 162
 
163 163
 
164 164
 if (! function_exists('espressoLoadWpGraphQL')) {
165
-    function espressoLoadWpGraphQL()
166
-    {
167
-        if (
168
-            ! class_exists('WPGraphQL')
169
-            && is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
-        ) {
171
-            require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
-        }
173
-    }
165
+	function espressoLoadWpGraphQL()
166
+	{
167
+		if (
168
+			! class_exists('WPGraphQL')
169
+			&& is_readable(__DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php')
170
+		) {
171
+			require_once __DIR__ . '/vendor/wp-graphql/wp-graphql/wp-graphql.php';
172
+		}
173
+	}
174 174
 }
Please login to merge, or discard this patch.